5 ms·
Try compiling a program that prints Hello World to the console and see how many bytes it takes in both source and shipped form. JS/TS will indeed win every time
by fidgewidge 4y ago
Try compiling a program that prints Hello World to the console and see how many bytes it takes in both source and shipped form. JS/TS will indeed win every time in those metrics.
- vips7L 4y agoWhy is that a metric that matters?
- fidgewidge 4y agoDownload latency is important in many contexts.
- vips7L 4y agoBut isn’t important in the hello world context and in other contexts I don’t think it’s a great comparison. Typical node apps will ship with megabytes of extra files for functionality that would be present in the Java standard library. Even if I take your claim as fact, programming languages are about trade offs. While Java might suffer from download latency it will more than likely beat TS on execution time and gc latencies.
- fidgewidge 4y agoBut recall that Java was once pushed heavily in the form of applets, where code size and download time are critical. That's why Sun developed pack200.
- vips7L 4y agoThis is 2023 not 1996. Applets have been deprecated for a long time.
- fidgewidge 4y agoYou asked for specific examples of where these metrics matter, the web is clearly a specific example.
- Jtsummers 4y agoIt isn't. It tells you nothing about how the language scales up, only how simple it can get when you want to print a value. https://rosettacode.org/wiki/Hello_world/Text https://rosettacode.org/wiki/Hello_world/Text You can see that some languages are simpler than others (even JS can be beat by this useless metric, check out APL). But it gives you no idea how the language scales up for complex tasks.
- SillyUsername 4y agoHelloWorld doesn't. These do (make sure to scroll): https://programming-language-benchmarks.vercel.app/java-vs-typescript https://programming-language-benchmarks.vercel.app/java-vs-t...
- mrighele 4y agoAn 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 ago
- peterashford 4y agoIs that really what you feel is a useful metric for a programming language?