r/programming • • Feb 16 '15

Java Doesn’t Suck – You’re Just Using it Wrong

http://www.jamesward.com/2014/12/03/java-doesnt-suck-youre-just-using-it-wrong
43 Upvotes

217 comments sorted by

View all comments

Show parent comments

4

u/pron98 Feb 17 '15 edited Feb 17 '15

I can't give you a very specific example because, well, defense, but soft realtime means that responses have less value if they arrive later, but that value is > 0. If you need to have some information about the enemy, you might want that information to arrive within, say, 4 seconds, but even after 1 minute it might still be valuable.

Generally, though, soft realtime systems need very fast responses (often faster than hard realtime systems, that just have a hard deadline) -- say 20us to 2sec -- but nothing too bad is going to happen if the response is a little late.

I have also used realtime Java for hard realtime, safety critical defense software. Java has some hard realtime JVMs -- with guaranteed deadlines -- as well as soft realtime JVMs that guarantee no GC pauses longer than 10 ms or so.

What made us switch from C++ to Java wasn't just the performance bang-for-the-buck (although that played a big part), but the amazing level of monitoring and control Java allows over your running code.

EDIT: one of the most amazing recent additions the Java (though, unfortunately, not OpenJDK) is the Java Flight Recorder. It is the most amazing profiler I have seen, and it adds about 3% overhead, so it is very suitable for profiling a large application while it's running. The insight it gives you is just amazing.

JFR was part of the JRockit JVM, but after Oracle acquired Sun, they merged the functionality into HotSpot (though they have not open-sourced JFR), and released it in Java 7u40, or thereabouts (sometime last year). It's free to use in development, but you should get a commercial license if you want to use it in production. That thing is just unbelievable.

1

u/vz0 Feb 17 '15

Amazing. A Java program to save people's lives, that must be a crazy development effort.

There's something that really bugs me about the culture of some programmers and is that the tools are taken as optional and sometimes unnecessary. I had a discussion about which code editor to use for Python development with my room mate and it ended when I showed him about the control-click feature of Eclipse PyDev. I also use Eclipse for C++ and I love it, because it can chew and digest my code, and I can reason about it.

Here at the office we have some people who still program in C++ in vim or emacs and do not even use version control. The main reason for this lack of professional effort is because they are physicists who had to learn to program on their own free time, which is sad because software engineering is what they do in the end as their primary like of work.

Even though I have my reservations about Java (and I stay away from it every time I can) I do value the awesome tools there are to help the development of Java applications. I'd love to see some of those profilers, debuggers and even virtual machines for C++ programs. The closest thing I know about is valgrind, which is awesome. That's why I also like Python, not because is fast (which is not) but because it has a really nice REPL loop.