3 ms·
It's eye opening how most trivial functionally equivalent code generates practically identical native binary output regardless of the language, be it C, Java, J
by vardump 6y ago
It's eye opening how most trivial functionally equivalent code generates practically identical native binary output regardless of the language, be it C, Java, Javascript or .NET.
- pjc50 6y agoWhy is that eye-opening? That things might converge on the same optimal result?
- vardump 6y agoIt's eye opening, because it shows how small the actual differences in executed code really are. When I first tried this about 10 years ago, I was very surprised how good code Javascript JITs generated. I expected there to be type checks, lots of unnecessary memory accesses, etc. all over, but to my surprise the inner loop was practically same as gcc -O2 output when compiling an equivalent C program. Of course the same is not true when it comes to bigger blocks of code, because Javascript does need to do a lot of bookkeeping behind the scenes.
- pjmlp 6y agoI guess it is more like that many are still unaware of it when mixing languages with implementations, while arguing language X vs Y.
- _448 6y agoA brilliant insight on these similar lines was exploited by a very brilliant engineer(https://news.ycombinator.com/user?id=jart https://news.ycombinator.com/user?id=jart) to go even deeper and generate single cross-platform binary of a program (https://news.ycombinator.com/item?id=26271117 https://news.ycombinator.com/item?id=26271117)! This magic is achieved using this: https://news.ycombinator.com/item?id=25952540 https://news.ycombinator.com/item?id=25952540