在我的工作中,我们最近完成了控制应用程序的系统架构,其最大延迟大约为一到两秒.它分布在通过IP LAN进行通信的小型ARM片上盒中.
我们最初预见到我们会使用C或C,因为它是一种经典的控制系统语言.在讨论了如何实现应用程序之后,我们现在意识到C具有相当有限的库,缺乏内省,并且具有可能减慢开发的一些其他属性.我的同事随后建议Java可能会胜任这项工作.
我真的害怕为控制应用程序运行GC的延迟,我也不愿意放弃RAII,因为应用程序将使用大量外部资源(套接字,文件句柄,外部库等句柄等).
pro / con列表目前如下:
C++ + RAII - Easy resource management - it will be a complex system + System language - speed if we cant't find a JIT VM for our ARM + No GC - no big worst case latencies from the GC + Easy to integrate with some shared mem libs that we have to interface with - Fewer free as in beer libs - Lacks introspection - Mapping classes to DB and external data formats (XML) would benefit from this (ORM /JAXB) approach - Easy to shoot one self in the foot - hard and expensive to find programmers which don't make big mistakes - Memory fragmentation - needs tuning and workarounds Java + Huge amount of libs + Introspection - serialization becomes a breeze (see C++ section) + Easier to find 'good enough' programmers - No RAII - Client has to remember finally or you leak resources. IMO Java programmers tend to ignore this problem unless they have server app background. - No System Language - possibly slower although ARMj could alleviate this - GC - latency might go up (don't know if parallel GC will work - seems that you might get fragmentation,see note below). - Need to write JNI for the shared mem libs that we interface with - Maybe ORACLE will eat us
使用并行GC的内存碎片被提到in this AMD article
如果GC延迟不成问题,我很乐意使用Java,我们可以获得RAII.因此
我也研究了其他有RAII并且可以作为替代品的langs,到目前为止我发现D,Ada,VB,Perl,Python(C),PHP,tcl和Lua似乎有某种超出范围的回调.我的自然反应可能是D,Python和ADA可能适合控制应用程序. D和ADA是我的最爱.
所以,我的问题是:你有什么建议吗? Java是一个可行的选择,如果你可以选择任何语言,它会是什么?