Why do people still say Java is slow?
programmers.stackexchange.com
programmers.stackexchange.com
Yes in theory Java will elliminate most of those checks, but difference between theory and practice is more than what theory would suggest.
For simple loops for (i==; i < n; ++i) where n is a compile time constant (or something that can be proved to be a constant) this would work. But one encounters a lot of loops where n isnt a constant. This is just one example of what slows Java down, there are others. It overspecifies semantics (think order of evaluation of arguments), gaining safety but losing on performance.
That said I think the JVM is one of the best optimized runtime that we have. Overall JVM is a great platform, but Java is not necessarily the best way to exploit it. Coming back to Java performance, in my experience it would get to around 80% of the speed of a C or C++ code but would use 3~4 times the memory. No careful benchmarking this, just anecdotal experience.
JVM developers, in case you are reading this, please add tail call ellimination and SIMD.
I am not a "3 cheers for dynamically typed languages" person, but for Java I am willing to concede that the type system comes with the drawbacks but little benefit. In C++, and D you can pull the gloves off when required. And please dont get me started on JINI.
A problem is that Java based systems are slow both in the big (I am looking at you Hadoop) and the small. You can run some of the C++ based mapreduce implementations (http://sector.sourceforge.net/) and draw your own conclusion.
I expect you mean JNI and not Apache JINI...
That probably highlights the difference between Java and other languages you like to mention, it may use more memory and be marginally slower computationally, but when you take that the most interesting applications these days are distributed the ability to sort an array and save a few clock cycles fades into insignificance compared to network latency and connection times.
Not to mention also, you can optimize your CPU's workload or you can optimize your personal workload. Java lets you pick great libraries off the shelf. Or you can choose to manually do your own array bounds checking and pick up your own garbage.
Java also messed up and was too preoccupied on getting faster throughput (in too specialized circumstances) and didn't focus much on latency/user-responsiveness.
End users don't care about theory. The only care about their individual user experience. When they see slow launch times, long unresponsive pauses (due to garbage collection), and similar apps written in native languages running faster and being more responsive as a general trend, people are going to rightly blame Java.
Java also eats a lot of RAM in many applications (J2EE apps can easily eat a few GB of RAM), so combined with the multi-second latency for startup, you're basically confined to a single programming model: One giant, long-running, multithreaded program.
We recently went live with a suite of applications (5 apps all together, both web and backend), processing tons of data in "real-time" in multiple threads and after a few days of usage someone noticed it was running with default 512M of RAM (8gb planned).
Considering the load it is processing - it is very impressive. And yes, it is using all of J2EE in WebSphere with mq, hibernate, spring core, spring integration, etc.
BUT I could not make JIRA work with 512 linode, had to upgrade to 1m and later on switch to jira-cloud as it was failing all the time.
That, and I think Java has huge internal libraries, full of redundancy, that get recompiled on every run, because nothing gets done without them.
The fundamental problem is that Java can't decide whether it wants to be a low level or high level language. It tries to be both at once, and one casualty is performance.
Apart from writing your own memory arena, you would need to put local objects on the heap in Java. It is possible to write high performance Java, but like a previous comment mentioned, that code looks more and more like C++, so why not just write C++?
I make that last point because I think new people coming into large C++ projects often take longer to ramp up and understand the code than in large Java code bases. But that is purely anecdotal.
For small command line utilities the startup overhead can be massive compared to the actual running time of the program, even if the <insert algorithm> runs 100ms faster in Java compared to C/C++/Go/<insert other> it won't matter if the startup time takes 400ms longer.
Stop being a secret society (sorry again) type of community and start putting more projects on Github (that are easy to use and get started with), writing more tutorials on visible places, being more active.
I am sure I will hurt some feelings here. Get easy on the comments ;)
Java devs are not too vocal on HN lists, but this is the nature of HN, which is not a fair reflection of the state of things in the industry....
Do people still say Java is slow?
As far as scripting languages used in game platforms, it's one thing to use a scripting for minor tasks within a system written in other languages, it's something else entirely to write an entire game in that language.
Having used Minecraft for a pretty long time, I don't feel like it's the sort of thing someone should hold up as exemplary of how fast Java is / can be. Instead, for me at least, it's more evidence of Java apps having troubles making use of available system resources (particularly many cores and/or larger amounts of RAM) as well as demonstrating that portability still can be a problem with Java apps (as in OpenGL v OpenGL ES; MCPC v. MCPE, MCPI & MC360; and even windows v Linux & Mac).
I get that it is possible to write Java such that certain things run pretty fast. I also don't think that these sorts of metrics should be used as the only metric every developer uses to decide what language to use for their projects. Therefore, I don't feel that these are reasons to conclude that someone else should or shouldn't use java for their project (as surely they have their own priorities which they base their own decisions on).
On the other-hand I don't think that any software programming language having advanced features which allow for efficient use of these various other system resources matters much, if many (most?, most popular?, many popular?) projects don't use them (or perhaps don't use them correctly). For that matter the same goes with hardware... it hardly matters if some chip has amazing super powers, if few projects use them.
Back to why people think Java app can be slower than they ought to be. My experience has been that when Java first began to become popular, it became the language of choice in many universities. Not long after that it was common to find poorly designed & implemented projects to be written in Java. While this has changed by now, nearly all of the Java projects, that I have experience with don't have an obvious priority of maximising performance by using all available system resources as efficiently as they can be.
Lots of people say that Minecraft has minimal requirements; but then a lot of people say that Minecraft has terrible performance because it's written in Java and 'Java is slow'.
Many of those people (both groups) are naive users who don't know much about computing or programming or games. Or they're games players so they have a different idea of what "minimal requirements" means. (A dual core 1.8 GHz processor; 3 GB ram; don't feel 'minimal' to me, but perhaps that's my age.)