7 ms·
Wouldn't Erlang be much more efficient if it simply compiled to the JVM?
by amelius 4y ago
Wouldn't Erlang be much more efficient if it simply compiled to the JVM?
- lenkite 4y agoJVM standard does not support isolates so it won't work. Java's father Gosling wanted to get isolation into the Java spec but he failed. The modern GraalVM does have isolates but its a VM specific feature and not a java standard feature.
- nesarkvechnep 4y agoNo.
- vcryan 4y agoHa! Absolutely no
- amelius 4y agoWhy not? JVM has a highly optimized concurrent GC.
- omginternets 4y agoIt’s a GC tuned for imperative languages that prefer mutation over allocation, which is the exact inverse of what BEAM needs.
- pron 4y agoOpenJDK's GCs do have elaborate mechanisms to support mutation, but if they're unused they impose no extra overhead.
- omginternets 4y agoI think you may be missing the point. What the JVM doesn't have is elaborate optimizations to support copies, e.g. a generational GC.
- NobleExpress 4y agoHm? G1 is a generational GC? And so is Serial/Parallel. And work on generational ZGC is ongoing [1]. Not sure what you're referring to here. [1]: https://openjdk.org/jeps/439 https://openjdk.org/jeps/439
- omginternets 4y agoI was mistaken!
- pron 4y agoThe JVM has a selection of four generational GCs. Two of them are the most sophisticated GCs available anywhere. It's not a matter of some unique brilliance. Java is simply in such high demand that it has the sufficient resources to have state of the art optimising compilers and GCs.
- omginternets 4y agoReally? I had no idea. Can you suggest further reading?
- pron 4y agohttps://docs.oracle.com/en/java/javase/20/gctuning/available-collectors.html https://docs.oracle.com/en/java/javase/20/gctuning/available... https://youtu.be/OhPGN2Av44E https://youtu.be/OhPGN2Av44E https://youtu.be/bLJJ3CY1aE8 https://youtu.be/bLJJ3CY1aE8
- toast0 4y agoErlang has a highly optimized concurrent GC as well. It's just optimized for different things. And maybe the concurrency of the GC is different; Erlang has one heap per process (aka green thread), and no concurrency within a heap. Erlang GC is also very simple and easy to understand because language features only allow references in one direction. Much of JVM GC complexity would be wasted as there's no need to look for reference loops and such, since they're not possible.
- _old_dude_ 4y agoAlmost 10 years ago, i've tested erjang [1] using a medium sized application. Throughput was better than BEAM but latency was terrible. [1] https://github.com/trifork/erjang/ https://github.com/trifork/erjang/
- pron 4y agoTen years ago was two whole technological generations ago in the implementation of OpenJDK's GCs. OpenJDK now has a maximum pause time of under 1ms for heaps up to 16TB.
- bitwalker 4y agoI really strongly doubt that GC is a bottleneck for Erlang programs on either the BEAM or the JVM - the sophistication of the scheduler, and the way various language primitives interact with it, is where the BEAM is almost certainly gaining an edge over the JVM. That said, I'm sure there are a subset of programs that _would_ be faster on the JVM, just depends on what metrics are being compared.
- pron 4y ago> the sophistication of the scheduler, and the way various language primitives interact with it That was brought over to the JDK six months ago. The JDK can now spawn millions of Erlang-like processes ("virtual threads") per second. Erlang is a great inspiration and it does incredibly well with the development resources available to it, but it's hard to compete with the level of engineering investment in the JDK and its state-of-the-art GCs, optimising JIT compilers, and low-overhead in-production tracing and profiling.
- weatherlight 4y agoBEAM doesn't support mutation, the JVM does. that's a big plus in the BEAMs corner. Also when two BEAM VM speak to each other its as if they are just one machine. no serialization de serialization of data, no protobufs, etc. It's all just primitives being sent between processes regardless of their location.
- jlouis 4y agoIt likely would. But efficiency is only one factor. Many Erlang applications are far more concerned with consistent latency than throughput efficiency. So a switch to the JVM is a lot of cost.
- amelius 4y agoAre these folks also running their software on a real-time OS?
- weatherlight 4y agoErlang can be run bare metal.
- vkatsuba 4y agoYou can take a look to the interview with Francesco Cesarini https://www.youtube.com/watch?v=-m31ag9z4VY https://www.youtube.com/watch?v=-m31ag9z4VY for more details - here is provided a part where compared JVM with a BEAM.
- weatherlight 4y agoSure on a single machine, perhaps. but once you have multiple machines, the JVM would have to do what the BEAM does today; copy messages between processes regardless of location. That's going to slow down throughput.