4 ms·
Javascript in V8 is more performant than Java on a lot of tasks, and almost always 'sooner'. V8 is focused on 'getting going quickly' and it does, very fast. Ja
by jollybean 5y ago
Javascript in V8 is more performant than Java on a lot of tasks, and almost always 'sooner'. V8 is focused on 'getting going quickly' and it does, very fast. Java takes some time to optimize for most tasks.
Also, 'performance' isn't really an issue once you are past 'good enough'.
I don't think most devs are worried about Java/Node/Python/Golang performance on the backend for most apps. Obviously not always the case, but in most instances, it's not a primary concern.
Frankly, these days, when I think about 'performance' I think about 'developer performance!'. Java downsides in that its bureaucratic by convention, but at least it's super solid and reliable. I really, really wish it were a bight lighter however.
- azth 5y ago> Javascript in V8 is more performant than Java on a lot of tasks, Source? I constantly see companies switching from the likes of python and javascript to compiled languages after they reach a certain scale. I find Java to be extremely developer friendly, especially nowadays with features like pattern matching, records, switch expressions, and the upcoming project Loom Modern frameworks like quarkus.io are also a step in that direction. You might also want to check out https://jodd.org/ https://jodd.org/.
- kaba0 5y agoJavascript is much closer to java than to python in terms of performance. And due to the variability of the JIT compilers, it can sometimes be faster than java, but generally the latter wins out. But the parent poster is right that the two teams did choose a different workload to optimize for, V8 being fast faster while java taking more time to JIT compile a region, but that is mostly due to the difference between their most-common uses, running websites’ code as soon as they load vs mostly running on huge—ass servers with sometimes terabytes of RAM.
- jollybean 5y agoSource? Reality! :) I've built V8 instances and run some tests, but you don't need to do that. Just write some roughly equivalent code and run it in Chrome vs. JVM and see for yourself. It's not nuance or controversial, it will really 'stick out'. In basically all cases, V8 will 'get fast very quickly', it reaches a high level of performance on the second or 3rd iteration of a bit of code, whereas Java takes thousands of iterations. That's a very, very broad and crude generalisation, but you'll see it very clearly if you just try it yourself. It actually does make a difference depending on what you are doing as well - if you're running as server that uses the same code paths all day long, and executes them 1K times per minute, well then Java is fine. But for things like UI I particular where yo need the code to react it's a problem. 'Developer friendly' and 'modern frameworks' are a another question.
- pulse7 5y agoJava is typed, JavaScript is not typed. You can make more performance optimizations if you know types. So this claim is unlikely to hold...
- jollybean 5y agoSorry, but this is textbook. Go ahead and run some code on V8 and the equivalent Java. You'll notice V8 is 'extremely fast' at getting up and running, while Java takes quite some time - often thousands of iterations of a specific bit of code before it optimises.
- igouy 5y ago> Go ahead and run some code… https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/javascript.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- jollybean 5y agoOi Vei, I literally said 'fast at getting up and going' and 'over time Java is more optimised'. Those tests ultimately measure 'peak performance'. Java takes much longer to reach that level than V8. Given the fact that a lot of software does not run for a long period of time, and especially UI/Web code (and possibly serverless), the net result is that V8 is basically faster. It gets too near 100% performance after 1 or 2 iterations. Java takes 1000's of iterations. For many applications, the 'advantage of being fast soon' considerably outweighs any kind of incremental performance benefit that Java might offer over time. This is mostly true for UI software. V8 'is fairly quick, and right away'. Java is 'sticky and slow for a bit, and then a bit faster over time but it's not noticeable'. V8 is a regular car: stops and starts as needed. Java is a race-track stock car - accelerates up to a high speed and stays there. You don't need a race-track car to do food delivery, because the added peak performance is pointless.
- igouy 5y agoYou "literally said" so much, but not anything specific that you've measured and others could measure.