@oaktree I think this overhead does not come much from the compilation, but all the high level constructors. Whenever you write one python line that doe a lot of stuff... it is actually doing a lot of stuff under the hood.... because, at the end, the processor does what it can do... some basic logic/arithmetic operations, moving data around, jumping and that is roughly it.
I think that the same happens to C++. The standard library is just big, and the trade-off between memory usage and speed is well-known.
And I also agree with you that this samples are not representative for the general case. I think they are interesting for cases where a small tool for a modest platform has to be used... 2Mb in a router may be quite some memory...
Java is not much popular around here, but it a different beast. In addition to the original bytecode compilation (original as first... it was not original when Sun introduced it... yes Sun), Java soon integrated a JIT compiler and later on the so-called Hot-Spot.
The JIT compiler actually compiles the bytes codes to real machine code. The hotspot is in principle, able to analyze the program at run-time and decide which parts are used more frequently (the hotspot) and selectively compile only what is required. Advocates of this approach usually claims that run-time optimizations can be better than compile-time optiomizations, as more information is available.
But all that is speed related... memory-wise, it use to take a look, I do not know nowadays.
@Cromical are you working in a bot for the forum????