Which programming languages are the fastest?(shootout.alioth.debian.org) Surprised that LISP is 20x faster than PHP or Perl in this benchmark (median times). It is even faster than Python and of course Ruby. |
Which programming languages are the fastest?(shootout.alioth.debian.org) Surprised that LISP is 20x faster than PHP or Perl in this benchmark (median times). It is even faster than Python and of course Ruby. |
Which begs the question - aside from macho bragging rights, exactly what good is this kind of information?
Assume I did have a specific problem case for which performance in terms of memory, time or LoC mattered. As a first step, I'd write a specific benchmarkable implementation of my own problem (or one very like it.) Then I'd need to profile and optimise that implementation in my chosen language(s), as well as stop and think laterally about ways I might be able to optimise around that specific problem.
This is all assuming I'm working on a greenfields project where I have absolute free choice of language & runtime environment. Which happens for my personal projects, but never yet for a professional one.
Not to mention that in all other cases apart from this hypothetical where performance matters, I would take the most human-readable program over the most fast, lean or concise one.
Long story short, at no point can I see myself stopping and saying to myself. "You know what I need now? I need to see which programming language can generate a Mandelbrot set bitmap with the smallest memory footprint, without using any 'unfair' optimisation techniques."
A while back, I wrote a program to solve a puzzle. The more complex the puzzle, the longer it took to solve. Today, I might come up with a better algorithm, but back then, all I could find was a brute-force approach. The most complex puzzle I had seen at the time was taking hours to run.
The program was written in VB6, and it was just wasn't mean for CPU-intensive programs like that. If I were to write that program again today, I'd be looking at optimizing the code for speed, starting with the language.
So yes, the question -does- matter. Sometimes.
I bet that you could come up with a better algorithm now, even in VB6 if you had to, to get the run time down. I've seen people take "optimised" C solutions that run in hours and make them run in minutes, just by rewriting the algorithm and rethinking basic assumptions.
> ... I would take the most human-readable program over the most fast, lean or concise one
And some people do look at the source code for 2 dozen languages.
However, this was still posted under the title "Which programming language is the fastest?" - so I think it's worth exploring in exactly what ways that is or isn't useful information. Just as their own reason #3 says - "To show how difficult it can be to make meaningful comparisons"
I'd also question exactly how useful reading toy benchmark solution code is to real problems. The code to the benchmark problems is often nicely written, but if I have a problem to solve then wouldn't I be better off looking for samples of readable code that solve problems related to my specific problem domain?
You have to optimise to your use case, not some arbitrary general use case like "render a Mandelbrot set" or "calculate pi". If I have a slow On^2 Erlang algorithm, then I'm a lot better off looking at ways to rewrite it as Olog(n) instead of scrapping Erlang and moving to Java because it had a better score on the programming language shootout.
Sure, but the benchmark has to fit the use case. If you're designing a large web application, find benchmarks for large web applications or write benchmark cases yourself that match the use cases you're going to see and think you need to optimise for.
Anyone have any details on why that happened? These destroyed my ability to link to the shootout as data for showing that languages don't matter as much as implementations do, a nuance many newbies miss :(
http://thread.gmane.org/gmane.comp.python.pypy/7303/focus=73...
The help page has your answer, anyway. "Because I want to do fewer chores not more!" http://shootout.alioth.debian.org/help.php
http://shootout.alioth.debian.org/u32/compare.php?lang=cint
But let's note that here CINT is only being used as a C interpreter but a CINT script can call compiled classes/functions and compiled code can make callbacks to CINT interpreted functions - which I'm sure you understand would make it a lot faster.
http://shootout.alioth.debian.org/dont-jump-to-conclusions.p...
> scrapping Erlang and moving to Java
"Most (all?) large systems developed using Erlang make heavy use of C for low-level code, leaving Erlang to manage the parts which tend to be complex in other languages, like controlling systems spread across several machines and implementing complex protocol logic."
I know, when programming in Erlang I have unsurprisingly done exactly this. If I had an On^2 solution in Erlang that I knew I couldn't rewrite in Erlang to be faster, then that's my last resort - I'd write a C port to perform my particular inner loop performance-limited code, and leave the rest in Erlang.
However, I wouldn't either (a) go directly to C without trying to optimise the solution in Erlang first, or (b) look at a list of other languages and wonder which one I could move my entire program to.
Now consider how you could use the varying performance on different tasks, and the varying performance on the same task of programs written in the same programming language, as examples (as a resource) for exploring (and showing to others) in what ways you think that is or isn't useful information.
If we just consider those "Which programming language is the fastest?" pages, then I think - simply getting someone to look away from a single number ranking (the median) and notice that for some language implementations the performance range is relatively small but for others the range is enormous - is useful.
> I'd also question exactly how useful reading toy benchmark solution code is to real problems.
Someone's told me that n-body pretty much is what they get paid to work on. Someone's told me that k-nucleotide and reverse-complement are pretty much is what they get paid to work on. The question as usual is who's "real" problems?
> wouldn't I be better off looking for samples of readable code that solve problems related to my specific problem domain?
Perhaps - and yet for some people what they see in those tiny tiny programs will be enough for a personal opinion about whether X is "the most human-readable".
Given that this sounds like its your own project, I have a vague idea that you might find interesting: Is there a way to present the results in an additional way which is framed initially as "look at the different ways to solve subproblem X" rather than "look at the graph of performance differences"? It could be an interesting approach to have an alternative additional interface that makes browsing the sample code (maybe with annotations?) front and centre, with a focus on programming techniques as a major differentiator, with scores as an adjunct. At present the visitor is encouraged to start from benchmark scores (either for everything, for a problem, or for a language) and from there move to source code later, but there might be a way to frame it as "let me flip through solutions to problems like X and tag the ones I like the look of, then let's see how they performed"
It's a pretty vague idea, and I don't have much of a handle on how it'd work from a UI perspective, but its seems like it might head off some of the kneejerk responses you get from kneejerkers like me ;), plus it could help encourage some of the uses you're describing in your post.
At present, even from the home page, source code is only 2 or 3 clicks.
Who would write those annotations? Currently there are 1100 programs, but they change as new programs are contributed and others removed.
Who would do the work to create a series of blog posts discussing the development of each and every program?
http://adventuresinmercury.blogspot.com/2011/04/shootout-spe...
Yes, but it's always at the "bottom" of the interface when you drill down. For instance, all of the content is there to make an interface which allows side-by-side comparisons of the implementation of the same problem in different languages. At the moment, you can do that but it involves opening two tabs and clicking forward and back through each language.
Who would write those annotations?
The annotations were just a throwaway idea. I noticed some of the programs are very well commented, some aren't. Probably good commenting & structure covers a lot of it.
Who would do the work to create a series of blog posts discussing the development of each and every program?
I'm confused by the rhetorical questions. You seem to be suggesting noone would ever do the work to explain the creation of a program, then you link to a blog post which does just that.
Or opening two browser windows and looking side by side - by design the page layouts are narrow to enable side by side comparisons (often I've reformated programs to 80 char width), it wasn't that I foresaw the emergence of small screen iPhone browsing ;-)
> suggesting noone would ever do the work to explain
When something seems peculiar I've pursued contributors for some text to explain what's going on with their program - so my thoughts about this are based on my experiences
http://shootout.alioth.debian.org/u32/program.php?test=threa...
> a blog post which does just that
As an example of something that's been done well, and done independently of the benchmarks game.
Anyone can make that kind of analysis and publish on their blog.
The benchmarks game is a starting point and a source of questions, rather than a definitive answer to every question.
Updated the Help page