"Strong typing vs. strong testing"

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Oct 2 02:18:15 EDT 2010


On Fri, 01 Oct 2010 11:56:24 +0200, Pascal J. Bourguignon wrote:

> Actually, it's hard to find a language that has no compiler generating
> faster code than C...

Perl. Python. Ruby. Applescript. Hypertalk. Tcl. RPL. Frink. Inform 7. 
ActionScript. Dylan. Emerald. And hundreds more serious languages, to say 
nothing of dozens of esoteric languages like Chef, Oook, Whitespace, 
Shakespeare, and Intercal.

It's actually hard to think of languages with implementations that 
*consistently* beat or match the gcc C compiler: C++ and Forth come to 
mind immediately. Lua and Javascript sometimes manages to beat C. Scala, 
Java, Pascal, Fortran, Ada often come close, where "close" means within a 
factor of 5 times slower.

See http://shootout.alioth.debian.org/ for more benchmarks.

Of course, all benchmarks are flawed, if not broken. The very concept of 
"which language is faster" is nonsense. High-level languages aren't 
executed directly, and if they were, the parse/interpret/execute cycle is 
*so slow* that they would all lose (Think of the speed of scripting 
languages like bash.) That's why virtually all languages are compiled, to 
byte-code that is executed in a virtual machine, or machine code that is 
executed directly in a real machine. So the real questions are:

* which virtual machines are faster when performing a certain task?
* which compilers generate the best (virtual or real) machine code for a 
given task?

and most interestingly:

* given the competing demands of ease of development and maintenance, 
versus the demands of speed of execution, versus correctness of code, 
which language is best for my specific needs?

Which is why we're not all writing in COBOL.


-- 
Steven



More information about the Python-list mailing list