7 ms·
Java is mature and regarded as high performance, even if it is a memory glutton.
by networkimprov 6y ago
Java is mature and regarded as high performance, even if it is a memory glutton.
- jolux 6y agoRust has significantly less overhead than Java
- lmm 6y agoLike a factor of 2 at best. Nice to have, but not the difference between usable and unusable.
- scottlamb 6y agoDo you really think at any time in Chrome's lifespan that its developers would accept a decision that is so foundational (aka hard to reverse) and slows everything down by a factor of 2? I don't. If they had, I don't think it would be the most popular browser today, and arguably it wouldn't even still be around. IIRC, speed was a major selling point when it was released. (I also don't really think Java is that much slower but substitute a more precise guess and my statement stands. And I think Java and other GCed languages really do use ~2X as much RAM which is also unacceptable.)
- lmm 6y agoThe speed of Chrome's from-scratch JavaScript engine was a major selling point when released, yes. But that speed came from a lot of places - after all, competing JavaScript engines were also written in C++, and in particular areas V8 was thousands of times faster than them. Using Java over C++ would have meant a factor of 2 up-front performance cost. But it would also have meant significantly less time debugging, easier testing, faster iteration, better automated refactoring support... all of which would have added up to being able to spend more development effort finding the kind of algorithmic improvements that give you those 1000x speedups. I'm not at all convinced that the end result would have been slower.
- scottlamb 6y agoIn particular areas (short timespans, specific tasks), Java can be thousands of times slower than C++/Rust. (Warmup/pre-JIT function evaluation, GC pauses, etc.) I have these kinds of performance rough spots, but I'm surprised to hear you do. It doesn't seem consistent with an argument for Java.
- scottlamb 6y agos/have/hate/
- lmm 6y agoI don't think you'll find a realistic case where Java is thousands of times slower than C++/Rust. You're even less likely to find a case where it's a worse order of asymptotic complexity. Whereas you'll find plenty of cases where (at least 2008-era) SpiderMonkey is in a worse complexity order than V8.
- jolux 6y agoClient warmup times are not great. Java is incredibly fast but attempts to write an HTML engine in it in the past didn’t really pan out. Also, WebKit was already written in C++.
- scottlamb 6y agoYou don't have to look far at all to find such cases. Startup takes forever. It's not that there's a specific small operation that programs in both languages do and is O(log n) in C++ and O(n^2) in Java. It's more that the Java programs do work that is unthinkable with C++. They run an optimizing compiler (once they decide its worthwhile on a given function). That's not something C++ programs do. [1] Until that happens, they may be running completely unoptimized interpreted code. They might go through the whole thing again if they fill their perm gen (or whatever it's called) and evict the optimized version of the code. They run a garbage collector which sometimes stops the world. Your tiny function might have to wait for gigabytes of heap to be scanned. Over sufficiently long runs, throughput is easily within the factor of 2 you mentioned. But over short timescales, thousands of times slower is completely plausible. Some C++ CLI application might run in 5 ms where the equivalent Java program takes 5 seconds. IIRC there was some article recently challenging the assumption that Java programs commonly reach the optimized steady state at all. I can't find it though. [1] Except V8 of course on the user-supplied JavaScript. I'd call that quite different than optimizing all Chrome's own code.
- kelnos 6y agoA factor of 2 is a lot. Especially when considering that web browsers are already memory hogs and aren't all that fast.
- kllrnohj 6y agoJava when written like C is within a factor of 2 at best. Java when written like Java isn't anywhere close to C/C++. And the gap is getting _wider_ as Java is an increasingly bad fit for modern CPUs due to the heavy pointer chasing nature of it. It desperately needs value types to stay competitive in a performance battle.
- _ph_ 6y agoThe previous posters were talking about languages available when chromium was started. So while Rust probably would be the language of choice today (see Firefox), it wasn't an option, but Java was already around and mature.
- jolux 6y agoI don’t think Java is an option either for writing a web browser specifically for reasons of overheard. Rust is probably an option now but bringing up Java in this context was weird.
- erichocean 6y ago> regarded as high performance LOL. Is this LinkedIn? People on HN actually know Java requires mountains of C++ to be performant (c.f. Cassandra). Even then, actual C++ is 10x faster/lower latency (c.f. ScyllaDB). Update: Downvote all you want, Cassandra has tons of C++ to work around terrible Java performance, and the native C++ ScyllaDB absolutely smokes it in benchmarks. Not even close.
- nurettin 6y agoJudging from your lol, you must surely remember debian aliot comparison pages, or various coding competition websites ranking the times for java solutions very close to c++ solutions back in the 2000s.
- kllrnohj 6y agoThose comparison pages still exist: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/gpp-java.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... Time has not been kind it seems. Not just the gap in performance, but also the gap in memory usage.
- tom_mellior 6y agoThe C and C++ versions of those benchmarks are manually vectorized to death using vector intrinsics. You don't have those in Java, nor in the standard versions of C and C++. So yes, those speedups are real, if you invest a lot of work. But if you don't, there is no magical 5x speedup of C++ over Java.
- unrealhoang 6y agoThat is, if you write your program for the benchmark, i.e. writing C in Java by writing procedural code with packed primitives, or juggling and write all magic hacks just to make the code falls into correct JIT path. Otherwise, if you write normal OOP Java, 10x should be the performance gap.
- entha_saava 6y agoHehe.. Lol no value types.. Lol virtual by default. Lol believing JIT can be efficient.