11 ms·
I no longer accept the idea that languages don't have speeds. Languages place an upper bound on realistic speed. If this isn't true in theory, it certainly is t
by jerf 13y ago
I no longer accept the idea that languages don't have speeds. Languages place an upper bound on realistic speed. If this isn't true in theory, it certainly is true in practice. Python will forever be slower than C. If nothing else, any hypothetical Python implementation that blows the socks off of PyPy must still be executing code to verify that the fast paths are still valid and that nobody has added an unexpected method override to a particular object or something, which is an example of something in Python that makes it fundamentally slower than a language that does not permit that sort of thing.
The "misconception" may be the casual assumption that the runtimes we have today are necessarily the optimal runtimes, which is not generally true. But after the past 5-10 years, in which enormous amounts of effort have been poured into salvaging our "dynamic" language's (Python, JS, etc.) run speeds, which has pretty much resulted in them flatlining around ~5 times slower than C with what strikes me as little realistic prospect of getting much lower than that, it's really getting time to admit that language design decisions do in fact impact the ultimate speed a language will be capable of running at. (For an example in the opposite direction, see LuaJIT, a "dynamic" language that due to careful design can often run at near-C.)
(BTW, before someone jumps in, no, current Javascript VMs do NOT run at speeds comparable to C. This is a common misconception. On trivial code that manipulates numbers only you can get a particular benchmark to run at C speeds, but no current JS VM runs at C speeds in general, nor really comes even close. That's why we need asm.js... if JS VMs were already at C speeds you wouldn't be able to get such speed improvements from asm.js.)
- pjmlp 13y agoIt is always a matter of ROI, how far one is willing to invest, money and time, in a compiler/interpreter/JIT implementation for the use cases a language is targeted for. As for the current state of native compilers for dynamic languages, they suffer from the fact that past the Smalltalk/Lisp Machines days, very little focus has given to them in the industry. Hence little money for research, while optimizing compilers for static typed languages where getting improved. Dylan was the last dynamic language with a AOT compiler targeted to the industry as system programming language, before being canceled by Apple. If it wasn't for the JavaScript JIT wars, probably the situation of compilers for dynamic languages would be much worse.
- jerf 13y ago"It is always a matter of ROI, how far one is willing to invest, money and time, in a compiler/interpreter/JIT implementation for the use cases a language is targeted for." That's just a long way of agreeing with me. If one language can require a great deal more effort than another to run quickly (and I'm not assuming the slow language even makes it to the fast language's speed here), then it is therefore the case that languages designs do impact the experienced run time performance. That's the entire point. And given where the plateau on the dynamic languages seems to be getting drawn, I see no reason to even hope that a dynamic language will ever run as fast as C in general. They are plateauing way too high for that to be the case, probably even with infinite investment on current hardware.
- lispm 13y agoLisp Machines never had sophisticated compilers. The compilers for the Lisp Machines were primitive in their capabilities. The compiled to a mostly stack architecture, where some speed was recovered in hardware from generic instructions. The work on better compilers for Lisp came most from other places: CMU for their Unix-based CMUCL, Franz with Allegro CL, Harlequin with LispWorks, Lucid had a very good compiler with Lucid CL, Dylan at Apple for early ARM, CLICC in Germany, SBCL as a clean up of CMUCL, Scieneer CL as a multi-core version of CMUCL, mocl as a version of CLICC for iOS/Android, ... plus a few special purpose compilers... Once you add sophisticated compilation, dynamic languages implementations are no longer 'dynamic'. This topic is pretty much solved for Lisp. On one extreme we have fully dynamic interpreters + then dynamic AOT compiler based ones. For delivery there are static delivery modes available (for example with treeshakers as in LispWorks). On the extreme side you get full program compilers like Stalin (for a subset of Scheme) or like mocl (a recent compiler for a static subset of Common Lisp, for iOS and Android).
- userbinator 13y agoThis is also related to the "sufficiently smart compiler" argument - to have a Python compiler that can produce output equal to C, it would basically have to output nearly identical binaries to ones that an expert C programmer and compiler would produce. That looks to me to be an almost practically impossible task, since there are so many things you can do in C, which can improve performance drastically (e.g. avoiding dynamic allocation, pointer tricks, etc.) and simply can't be done in Python code, "Pythonic" or otherwise, and it would have to recognise and apply all of these rules. Even with C -> Asm which is a far more direct mapping, and on which a great deal of effort has been expended, the compilers still have nowhere near the intelligence to make use of the machine's instructions in a way an Asm programmer would.