6 ms·
I'm not sure that there's a myth to be debunked, is there? Java's known to be high performance as a web application server, if good architectural choices are ma
by flavor8 9y ago
I'm not sure that there's a myth to be debunked, is there? Java's known to be high performance as a web application server, if good architectural choices are made. The well referred to https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/ reliably has some of the better Java frameworks ranking near the top along with C and C++ servers.
- mikeash 9y agoYeah, the title confuses me greatly. I assumed this was going to be an article about how Java is slow, debunking the myth that it’s really fast.
- whois 9y agoReally? You've never heard people joke about Java being slow? Half the programmers I've met have this cult like hate of java and cite performance as the main reason.
- timthelion 9y agoJava is slow, but not in this case. Tight loop java is fast. Anything that touches memory is slow. Anything that involves loading jar files is slow. Anything that involves starting the VM is slow. But tight loop java is fast, indeed, being a JIT, potentially faster than C (better branch prediction given that the JIT can optimize at runtime). So the claim that Java is slow is true. That's why so many people hate it. The fact that Java is fast is also true.
- tsmarsh 9y agoJava is slow compared to C/C++ and Fortran and comparable with SBCL / Rust. But it is fast compared to Python, JavaScript, PHP and Ruby. It's the rise of these languages that confuses me. They somehow got away with the 'fast enough' argument whilst Java is constantly being compared to languages that are designed for fine tuning for the target architecture. In my mind it is Java that is 'fast enough' and,with Java 8, very expressive. The continued success of these incredibly slow interpreted languages in enterprises where you need to buy servers feels like an anti-pattern.
- mjw1007 9y agoFrom my perspective, choosing Python over Java (on Linux) around 2001: It was easy to find benchmarks showing that Java was fast. But Java turned out to be slower in every situation we might consider using it. Command-line applications were slower because the JVM took ages to start. GUI applications were slower, apparently because Python would use C-implemented widgets while Java would do much of the drawing itself. Web applications were slower without any good excuse as far as I could see, but something in the application server that was the mainstream way of doing things added more per-request overhead than starting a whole new Python interpreter via CGI. CPU-intensive operations (I remember image resizing in particular) were slower because, again, you ended up comparing the JVM against a well-written C extension.
- jacques_chester 9y agoI would say that of these, most are still true-ish, except web apps and some CPU-intensive cases. Where you have a long-running service, Java shines. Java marketing was a disaster. Remember when it was going to be the replacement for browsers? It was not a great way to engender goodwill.
- jghn 9y agoI think that the part this is missing is that when comparing Java to Python/Ruby part of the argument for the latter is the dynamic language aspect. To the folks making these statements, Java is seen as involving all the headaches of those faster languages but none of the advantages whereas Python/Ruby have slower runtimes but come with potentially faster development time, etc. I personally don't like this comparison but it's how I see it made typically. Random anecdote which led me to stop calling Java slow: I'll never forget the time I took a 3000ish line Python program which had been heavily performance tuned and thus completely impenetrable. I converted it to a dumbest-scheme-possible naive implementation in Java weighing in at roughly 100 lines , expecting that to be a first pass. It turned out that the Java implementation was many times faster so we called it good enough and moved on with life. Obviously YMMV and all of that
- 9y ago
- mohaine 9y agoTo be more fair, java is mostly slow on startup which which is mostly due to: 1) Swing. I have no idea what this does on startup but it is bad. This is what killed most java GUI apps. A simple AWT or SWT app will pop open while a simple swing app will take a few seconds to get started 2) Jars on systems with virus scanners. Jars are just zip files. Many virus scanners will unzip and scan a zip on every open which leads to each jar being unziped at least 2 times and often more if the app has to load more things from the jar at a later time. 3) Spring. Really spring is just a bad idea all the way through and most of the reason people hate java is Spring. Huge XML configuration files instead of code? Spring (mostly annotations now). Stupid names like AbstractSingletonProxyFactoryBean? Spring. That aside, on startup Spring will auto generate classes which really slows things down. This could have been done during the last build but spring does it at each startup which is really slow. Spring Boot has helped with startup times but it is still slower. After startup Spring continues to kill performance. The underling code is full of maps to control request lifecycle so instead of just calling a method it has to ask "who all is configured to do something at step PreParseRequestEncoding?" then again at ParseRequestEncoding, PostParseRequestEncoding, PrePareRequestBody, ParseRequestBody.... Not real names but the idea and number of steps is. Most of the time the answer is "nobody" but it has to ask for every step that might ever need something done. Add on top of this JPA which is super easy but quickly breaks down to a lot of DB calls. JPA is great for people who don't want to learn SQL and simple CRUD apps but anything with any amount of data will quickly slow down to thousands of DB round trips.
- karmakaze 9y ago> JPA I'd like to see some reallife-ish comparisons with Jooq
- nova22033 9y ago>JPA is great for people who don't want to learn SQL That's like saying Java is for people who don't want to learn C...or C is for people who don't want to learn assembly. It's the right tool for the right job. If you use it for everything, it's no so good.
- jacques_chester 9y ago
- JepZ 9y agoActually, Java was very slow 15 years ago and that might be the reason for that cult.
- rsynnott 9y agoI think it’s possibly an age thing. Java really _was_ pretty slow in the mid 90s, and the reputation has never quite gone away for people exposed to it then. People only exposed in, say, the mid-noughties have less reason to ever get that impression, though.
- mikeash 9y agoDecades ago, when Java was new, the VMs were not very good, and the comparison was with C and C++, it was commonly said that Java was slow. But these days, Java VMs are vastly better and Java is competing with languages like Python and Ruby. The way things are today, the assumption is that Java is faster than its competition.
- anon335dtzbvc 9y agoyup me too
- jackmott 9y agoJava desktop applications tend to be slow and bloated. Java server applications tend to be pretty ok if well designed. For desktop applications you suffer some more from innate disadvantages of JITs and the common graphics libs. People experience Java when using eclipse and minecraft and so perceive it as slow. When a java server provided data fast to a wevsite, people don't know that is java.
- sempron64 9y ago"If good architectural choices are made" is a high bar, considering that many popular Java frameworks (not the ones high up on the list) have already made bad choices (performance-wise) for you.
- flavor8 9y agoWell, true - but the highest ranked Python(#1) framework is at 25%, with probably a dozen or so Java configurations above it in the list. If low latency and high throughput is a primary goal (i.e. you really need scale) then you're probably going to know about gemini, undertow, grizzly, etc if you're in the Java ecosystem. (#1 mentioned since it's one of the two languages compared to Java in TFA).
- TheCoelacanth 9y agoI think Java being slow was the reality 20 years ago, a widely believed myth 10 years ago, and something that no one but dinosaurs believes now.