3 ms·
An Hello World in java is a single class file of a few hundred bytes so I am not sure that is the right example. Source code is more verbose, and although I do
by mrighele 4y ago
An Hello World in java is a single class file of a few hundred bytes so I am not sure that is the right example. Source code is more verbose, and although I do prefer Typescript I don't find it a tragic issue.
In both cases for anything more complex you will end up with a truckload of libraries, so even there there isn't much difference.
I think that were Java is not streamlined at all is in memory usage, because you will probably be able to get the same result with a fraction of memory in Javascript (and many other languages). I'm not sure if the problem is more on the JVM (heavyweight objects and no value types?) or the libraries, I suspect both.
- vips7L 4y ago> I'm not sure if the problem is more on the JVM (heavyweight objects and no value types?) Value types are being worked on with project Valhalla, but also the VM doesn’t give memory back to the OS. It holds on to it up until -Xmx, which by default if i recall correctly is 25% of the machine, so it’s hard to really know how much your program is actually using. It’s actually one of my biggest gripes about the JVM.
- nayuki 4y agoThe HotSpot JVM does return memory to the operating system. https://stackoverflow.com/a/30464183/839689 https://stackoverflow.com/a/30464183/839689 , https://www.stefankrause.net/wp/?p=14 https://www.stefankrause.net/wp/?p=14 , https://shipilev.net/jvm/anatomy-quarks/21-heap-uncommit/ https://shipilev.net/jvm/anatomy-quarks/21-heap-uncommit/ , https://openjdk.org/jeps/346 https://openjdk.org/jeps/346 , https://openjdk.org/jeps/351 https://openjdk.org/jeps/351 , https://malloc.se/blog/zgc-jdk15#incremental-uncommit https://malloc.se/blog/zgc-jdk15#incremental-uncommit
- vips7L 4y agoObviously it does. I said that typically it will expand the heap until Xmx is reached, which according to your links is exactly what G1 will do.
- kaba0 4y agoJavascript is quite hungry for memory as well, but that’s simply the way of performant tracing GCs - the bigger space overhead they have, the less work they have to do.