且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java或C ++用于机器人编程?

更新时间:2023-11-19 10:58:46

如果性能真的很重要,那么别无选择:C++Java快(前提是算法相同,比几乎所有其他方法都快).
If performance really matters, then there is no choice: C++ is faster than Java (provided the algorithm is the same, C++ is faster than almost everything else).


//我在处理这两种方法上都有经验

用自己的秒表尝试两者,
这可能是您的第一步:)
// I have experience in working both of them

Try both of them by your own stopwatch,
it could be your first move :)


对于许多应用程序,Java的运行速度几乎与C ++一样.
程序员喜欢它的一个功能是它在后台进行垃圾回收.这意味着可以建立废弃的内存,并且有时您会看到大量性能下降,因为该内存被清理了.

对于Web应用程序来说,这并不是什么大问题,但是对于要长时间连续运行的应用程序来说,这可能是个问题.

当然,作为应用程序开发人员,Java确实为您提供了管理垃圾回收的工具,但是,您失去了不必担心垃圾回收的好处.您回到了管理内存的C/C ++范式.

操作系统和许多服务器系统仍然使用C/C ++编写是有原因的.您可以针对应用程序的大小和性能进行微调,并且可以更好地控制内存管理.

我的投票是针对C/C ++的.它会提供您需要的所有功能,并具有从庞大的代码库中提取代码的能力,同时最大程度地减少了代码占用.

我相信其他人也会为Java提供出色的论据.两种语言都有优点和缺点.
Java runs nearly as fast as C++ for many applications.

One feature that programmers love about it, is that it does garbage collection in the background. This means that discarded memory can build up, and occasionally you may see large performance hits, as that memory gets cleaned up.

This isn''t a big deal for web apps, but it can be a problem for applications that will run continuously over long periods of time.

And of course, as an application developer, Java does give you facilities for managing the garbage collection, but then, you lose the benefit of not having to worry over it. You''re back in the C/C++ paradigm of managing memory.

There is a reason that operating systems and many server systems are still written in C/C++. You can finely tune your application for size and performance, and you have better control over memory management.

My vote is for C/C++. It will provide every feature you will need, and give you the capacity to draw from a huge code base, while minimizing your code footprint.

I''m sure other folks will provide excellent arguments for Java. Both languages have advantages and disadvantages.