HACKER Q&A
📣 divs1210

Why do mainstream dynamic languages not ship with compilers?


I often wonder how one-man projects like Gambit/Chicken Scheme come with static compilers that produce small and efficient binaries but in the world of mainstream languages like Python/Ruby/JS this is basically unheard of?

Do Python/Ruby/JS programmers not like small, fast binaries?


  👤 sfgweilr4f Accepted Answer ✓
I think you'll have a deeper appreciation of the issues when you make an honest attempt at a python-to-C compiler yourself. The result you will get will be full of compromises and trade-offs.

Other attempts like Cython already exist. Perhaps you believe they missed something obvious? This is an excellent way to advance the state-of-the-art when you finish your compiler.


👤 rzzzwilson
You are assuming that a compiler for a dynamic language would produce small, fast binaries. There is so much that can't be assumed in a simplistic compiler for a dynamic language that the resultant binary would mainly consist of calls to support code written in C, which is pretty much what we have now in cpython minus the small interpretation overhead.

Even pypy[0], which isn't a simple compiler by any means, is only 4.4 times faster than cpython by their own measurements.

In short, languages like cpython aren't slow because they are interpreted, they are slow because they are dynamic. There's a lot happening "under the hood".

[0] https://www.pypy.org/


👤 gjvc
Probably because compilation to native code and linking to a native runtime were not part of the original goals of the project, and the designers were more interested matters such as the grammar.