Hacker News new | ask | show | jobs
by kjksf 5693 days ago
Compare on what basis?

Speed? http://shootout.alioth.debian.org/ is an up-to-date, super detailed answer to that question. A rule of thumb simplification I go by is: current Python and Ruby implementations are at least 10x slower than C doing algorithmic work.

A really good bytecode VM can, of course, get much closer to C performance (as shown by Java, C# or even modern JavaScript implementations) especially if JIT is given enough time to profile the app at runtime and generate highly optimized code based on that profile data.

There are of course other aspect you can compare. Bytecode is, inherently, cross-platform and machine code isn't.

Bytecode is usually more compact than equivalent machine code (but then you need the constant overhead of the runtime to interpret that bytecode).

2 comments

Python is my main language, and I think you underestimate the speed different for a same implementation by an order of magnitude. That is, CPU-boud tasks will most likely be around 100x slower.

The realy argument, of course, is that in a given time frame, with people of similar skills, you will not have the same implementation unless your team contains only vulcans. Several people in the scipy community have reported having gone from C++ to numpy/scipy and went faster at the same time - because C++ is so hard to use correctly, people whose job is not even programming ended up doing things very fast but one millions times because they don't understand their code.

This point is surprisingly not understood by a majority of programmers. Most of the time, you see benchmarks for some trivial or even non trivial algorithms, well specified, and get "look, this language is N times faster". But in my experience, this almost never happens in real life - code specification keeps changing, you need to redesign constantly what you're doing.

I think 10x understates the difference. Python (not familiar with Ruby) eats memory so for a lot of the number crunching I do it turns into a swap disaster. End up with Python using up 10% of the processor waiting around for disk I/O.