Slashdot Mirror


Comparing the Size, Speed, and Dependability of Programming Languages

In this blog post, the author plots the results of 19 different benchmark tests across 72 programming languages to create a quantitative comparison between them. The resulting visualizations give insight into how the languages perform across a variety of tasks, and also how some some languages perform in relation to others. "If you drew the benchmark results on an XY chart you could name the four corners. The fast but verbose languages would cluster at the top left. Let's call them system languages. The elegantly concise but sluggish languages would cluster at the bottom right. Let's call them script languages. On the top right you would find the obsolete languages. That is, languages which have since been outclassed by newer languages, unless they offer some quirky attraction that is not captured by the data here. And finally, in the bottom left corner you would find probably nothing, since this is the space of the ideal language, the one which is at the same time fast and short and a joy to use."

34 of 491 comments (clear)

  1. Why is Verbosity Bad? by eldavojohn · · Score: 5, Insightful
    This plots verbosity against slowness making:

    And finally, in the bottom left corner you would find probably nothing, since this is the space of the ideal language, the one which is at the same time fast and short and a joy to use.

    I must ask why the author assumes that verbosity is bad and why lack thereof makes it a "joy to use."

    I think verbosity in moderation is necessary. I have read many an article with developers arguing that they don't need to document their code when their code is self-documenting. Do you make all of your variables and class/function/methods a single character for the sake of verbosity? I hope not. And I would think that reading and maintaining that code would be far less than a joy.

    I don't even need to argue this, according to his graphs we should all be using Regina, Mlton or Stalin (a scheme implementation). But instead languages like Java and Perl and C++ prevail. And I would guess that support and a mediocre range of verbosity are what causes that.

    Great work in these graphs! But in my opinion, verbosity when used in moderation--like a lot things--is far better than either extreme.

    --
    My work here is dung.
    1. Re:Why is Verbosity Bad? by xZgf6xHx2uhoAj9D · · Score: 5, Insightful

      I agree totally about the need for verbosity. I'm a fan of Donald Knuth in this regard.

    2. Re:Why is Verbosity Bad? by jbolden · · Score: 4, Insightful

      Look where those languages are on the chart.

      Java mostly against the left wall (i.e. mostly as fast as C). Perl right against the bottom (i.e. very small code).

      It appears to me what this showed was that people like the walls.

    3. Re:Why is Verbosity Bad? by ucblockhead · · Score: 5, Insightful

      The author is not talking about verbosity in bytes. He's talking about verbosity in code points. Talked about in this way, a thirty character variable name is no more verbose than a single character variable name.

      --
      The cake is a pie
    4. Re:Why is Verbosity Bad? by A+beautiful+mind · · Score: 4, Funny

      It appears to me what this showed was that people like the walls.

      True enough, but my favourite is Larry Wall.

      --
      It takes a man to suffer ignorance and smile
      Be yourself no matter what they say
    5. Re:Why is Verbosity Bad? by timeOday · · Score: 5, Insightful

      I'm not sure we're sharing a definition of "verbosity. Perhaps the useful definition here is "the inverse of expressiveness." Of course expressiveness is inherently relative to what is important in a given application. For most purposes, assembler is hopelessly verbose, or lacking in expressiveness, since most of what you're writing out is meaningless detail. But for certain other purposes (performance) those details become crucial, so for that application only assembler has the necessary expressiveness. Again, I am not contradicting myself by saying assembler is both lacking in expressiveness and high in expressiveness, it depends on the application. I've heard German is a fantastic language for writing technical legal documents, whereas the Inuit language is supposedly very good for describing cold weather and snow.

    6. Re:Why is Verbosity Bad? by bcrowell · · Score: 4, Informative

      whereas the Inuit language is supposedly very good for describing cold weather and snow.

      That's a myth.

    7. Re:Why is Verbosity Bad? by ArcadeNut · · Score: 4, Insightful

      verbosity != self-documented

      Ruby example:
      do_something() if some_time 7.days.ago

      To me, this line of Ruby code is perfectly clear and self-documented. It is also about as short as you could make it. If I had to write the same code in Java, it would be long enough that I would feel it required a comment.

      This is where so many programers go wrong. The code is self documenting in the respect that you know it's checking the age of something to see if it was 7 days ago, but you have no idea WHY it's checking that. Why not 6 days ago? What if it's 8 days ago?

      Comments should say WHAT and WHY you are doing something not HOW you are doing it. The HOW is the code itself. If someone was to look at that code, do they know what your intent was? Were you looking for something that was exactly 7 days old, or something 7 days old or older.

      --
      Visit the Arcade Restoration Workshop @ http://www.arcaderestoration.com
    8. Re:Why is Verbosity Bad? by KangKong · · Score: 4, Informative
    9. Re:Why is Verbosity Bad? by dpilot · · Score: 4, Insightful

      Vermont ski areas have more words for "snow" than the Inuit.

      But they all mean "ice".

      --
      The living have better things to do than to continue hating the dead.
  2. Related site... by viyh · · Score: 4, Informative

    This site is awesome. It's very simple. They have over code in over 1200 different languages that spits out the lyrics to the "99 bottles of beer on the wall" song. Check out the perl example (yes, it really does work): http://99-bottles-of-beer.net/language-perl-737.html

    --
    "I have never let my schooling interfere with my education." --Mark Twain
    1. Re:Related site... by alvinrod · · Score: 4, Insightful

      What's so special about it? It looks just like a regular perl program to me. /ducks

    2. Re:Related site... by viyh · · Score: 4, Insightful

      Perl is all of the above; it is what you want it to be. That's the beauty of it. It can be a completely obfuscated ASCII art drawing or it can be a very concise, to-the-point one-liner or anything in between. It's the Swiss army chainsaw.

      --
      "I have never let my schooling interfere with my education." --Mark Twain
    3. Re:Related site... by Anonymous Coward · · Score: 5, Interesting

      Show me a language impossible to write ugly code in, and I'll show you a language which is unnecessarily restrictive.

      If you can't recognize the beauty in near infinite flexibility and the associated amount of power provided, you're not qualified to participate in such a discussion. Come back when you've gotten to know some actual talented programmers. One way to identify those programmers is that they don't blame their tools for their own incompetence.

  3. The perfect language exists, you ignorant clod! by tomhudson · · Score: 5, Funny

    And finally, in the bottom left corner you would find probably nothing, since this is the space of the ideal language, the one which is at the same time fast and short and a joy to use."

    Plain ASCII. The shorter and faster it is, the more joy it is to use.

    What can compare to the joy and speed of, for example, the command "Go fuck yourself!"

    Even shorter and faster syntax: the command "F.U.!"

    And for conciseness of comments - "SHIT!" and "oops!" and "WTF???"

    Looping constructs: "Sit on it and rotate!"

    If-else constructs: "Dat so? F.U. 2!"

    foreach: "You, your mamma, and the horse you rode into town on!"

    Exit statements : Just fuck off!"

    c-style assertions: "Eat shit and DIE!"

    #defines: "#define YOU One dumb motherfucka"

    conditional #includes "#ifdef YO_MAMMA"

    real-time peremption: "I OWN you, beotch!"

  4. Pet peeve by QuoteMstr · · Score: 5, Insightful

    Programming languages don't have attributes like size and speed: implementations of these languages do. Take Common Lisp for example: SBCL is blazing fast, while CLISP is rather pudgy (albeit smaller). Any conforming Common Lisp program will run on both. Or consider Python --- IronPython and CPython have different performance characteristics. (I'm too lazy to link these now.)

    Point being, describing a programming language as "fast" makes about as much senese as describing a natural, human language as "smart".

    1. Re:Pet peeve by Anonymous Coward · · Score: 4, Insightful

      A badly-written Assembler program will never achieve the speed of a reasonably-written C++ program. And most people cannot write good Assembler code.

  5. Forth, the RPN notational programming language by RichMan · · Score: 4, Informative

    http://en.wikipedia.org/wiki/Forth_(programming_language)

    --
    Forth is a simple yet extensible language; its modularity and extensibility permit the writing of high-level programs such as CAD systems. However, extensibility also helps poor programmers to write incomprehensible code, which has given Forth a reputation as a "write-only language". Forth has been used successfully in large, complex projects, while applications developed by competent, disciplined professionals have proven to be easily maintained on evolving hardware platforms over decades of use
    --
    Forth is still used today in many embedded systems (small computerized devices) because of its portability, efficient memory use, short development time, and fast execution speed. It has been implemented efficiently on modern RISC processors, and processors that use Forth as machine language have been produced
    --

    1. Re:Forth, the RPN notational programming language by rbrander · · Score: 5, Insightful

      I fell hard for FORTH in the mid-80's - it was the programming language of some instrumentation I had to work with. I never did program the instrumentation, but got all the books on the language and interpreters/compilers (the distinction blurs in FORTH...) for it for a number of computers. I did some useful utilities for the PC using "HS/FORTH". I benchmarked it against some other solutions for a course in comparitive computer languages about 1985, and for heavily stack-based (ie very recursive) programs, nothing could touch it. I'm talking QuickSort faster than C.

      But I have to admit: though I busted butt, re-writing and re-re-writing programs to make them as clear and readable as possible, though I re-read the remarkable "Thinking FORTH" by Leo Brodie many times (and would recommend it to anybody who wants to understand the craft of programming, whether they want to learn FORTH or not)....despite it all, most of my FORTH programs were hard to read a few months later.

      There were things it was really good at - that is, the programs WERE readable later, the problem and language were a match - and others where I could just not seem to decompose the problem into FORTH words that fitted well together without a lot of "glue" to manipulate the parameters on the stack.

      That was the most frequent problem with my FORTH programming - one ends up trying to manage several parameters on the stack and doing a lot of stack "DUP SWAP ROTATE" - actions to line up the parameters to hand to the next word. I would re-compose the words and the parameters they wanted to clean up some code, and find I'd made some other code all hard to read.

      FORTH was also profoundly command-line oriented, and when the word went all GUI-centric on me with no good "Visual FORTH" or "Tk/FORTH" on the horizon, I slipped from grace. I can't see getting back to it now, either; lets face it, a huge bonus for any programming language choice is its popularity, so that others will maintain your code, so that you can get help and code fragments with a quick google.

      But I still think that FORTH should be a completely MANDATORY learning experience in all University and Tech CompSci degrees. You can jump from C to Perl to Python far more easily than to FORTH - it really comes at problems from another angle and working with it for years has been an enormous asset to my non-linear thinking when it comes to problem-solving.

      And perhaps if more students learned it, FORTH would rise in popularity for some problems, out of its decades-long sinecure in embedded systems (it started off programming radio telescopes, and undoubtedly still does...) Since it is inherently object-oriented (yes, an assembler-sized OO language from the 1970's, you heard that correctly) it would be an excellent interpretive, experimentation-friendly scripting language for applications. I'm currently needing to do a lot of VBA in Excel at work, and I have a strong suspicion I'd be twice as productive in "FORTH for Applications". It's a tragedy Bill Gates fell for BASIC (of all languages) instead.

  6. Where are the real lanaguages??? by jackb_guppy · · Score: 4, Interesting

    Where Cobol and RPG, the languages that run business?

    1. Re:Where are the real lanaguages??? by DoofusOfDeath · · Score: 5, Funny

      Where Cobol and RPG, the languages that run business?

      They were so far off the top and right axes, the algorithm discarded them as outliers.

  7. What kind of verbosity? by Timothy+Brownawell · · Score: 5, Interesting

    I think verbosity in moderation is necessary. I have read many an article with developers arguing that they don't need to document their code when their code is self-documenting. Do you make all of your variables and class/function/methods a single character for the sake of verbosity? I hope not. And I would think that reading and maintaining that code would be far less than a joy.

    Long meaningful identifiers are useful. Needing 5 lines of setup for each API call is annoying, particularly if those 5 lines are usually the same. Requiring lots of redundant long keywords to "look more like English" is annoying. Large standard libraries that let you remove most of the tedious parts from your code are useful.

    1. Re:What kind of verbosity? by ucblockhead · · Score: 5, Informative

      Exactly.  As an example:

      for item in list:
        print list

      for(object o in list) {
        Item item = (Item) o;
        System.Out.Println(item);
      }

      for(std::list<Item*> it=list.begin();it!=list.end();it++) {
         cout << (*it)->name << "\n";
      }

      Three languages.  Same identifiers.  Big difference in both verbosity and readability.

      --
      The cake is a pie
    2. Re:What kind of verbosity? by Anonymous Coward · · Score: 5, Funny

      And yet you managed to write buggy code in the most terse and readable of them. So much for dynamic languages.

  8. Re:Scala by jbolden · · Score: 4, Insightful

    Functional languages in practice often implement nlog n algorithms in quadratic time or memory. One of those in a bench mark is devastating. We really understand how to optimize imperative languages well, we don't have the same level of knowledge / experience regarding functional.

    I agree this is a pity, but there doesn't seem to be any easy solution. Hopefully this gets fixed over the next generation.

  9. HAI by Anonymous Coward · · Score: 4, Funny

    CAN HAS LOLCODE?
    KTHXBYE

  10. I think it depends more on what you want to achiev by ledow · · Score: 5, Interesting

    This kind of fits in with my thinking.

    When I was starting out in programming, I just wanted results. I wasn't concerned about performance because the computer was a million times faster than me. I was most concerned about how many "non-vital" keywords were necessary to describe what I wanted the machine to do (e.g. "void main(...)" isn't *vital* because it's just boilerplate. However "if", "for", "while" etc. would be vital - and even for/while are just cousins), and how many of the vital keywords (i.e. those that specifically interfered with the way my program would *actually* operate... a "static" here or there would hardly matter in the course of most programs) were "obvious". Java failed miserably at this... I mean, come on: System.out.println() and the standard wrapping take up too much room.

    So, BASIC was an *ideal* first language (sorry, but it was, and the reason nobody uses it much now is because EVERYONE has used it and moved on to something else - doesn't mean it "breaks" people). In this regard, even things like C aren't too bad - 30-50 keywords / operators depending on the flavour, all quite simple - you could memorise them perfectly in an afternoon. However things like Forth and Perl can be hideous.

    And even C++ is tending towards the stupid. Believe it or not, even things like bash scripting come out quite well under that test. And, to me, that correlates with the amount of effort I have to put in to write in a particular language. If I just want to automate something, bash scripting is fast and easy. Most of the stuff I write is a "one-job program" that will never be reused. If I want to write a program to work something out or show somebody how something is done programmatically, BASIC is a *perfect* prototyping language (no standard boilerplate, no guessing obscure keywords, etc.). If I want to write a program that does things fast, or accurately, or precisely, or for something else to build upon, C is perfect.

    I see no real need to learn other languages in depth past what I'm required to know for my work. I have *zero* interest in spending weeks and weeks and weeks learning YAPL (Yet Another Programming Language) just to spent 90% of that time memorising obscure keywords, boilerplate and the language's shortcuts to things like vectors, string parsing, etc. If I was going to do that, I'd just learn a C library or similar.

    I think that these graphs correlate quite well with that thinking. Let's be honest, 99% of programming is reusing other code or shortcuts - short of programming in a Turing machine, C is one of the simplest languages to learn because it *doesn't* have a million shortcuts... you want to iterate over an array or create a hash / linked list, etc. you have to do it yourself from basic elements. In modern programming, that means a one line include of a well-written library. As far as I was concerned when learning it, even the "pointer++ increases by the size of the pointer" was far too smarty-pants for me, but incredibly useful.

    But with C++, I instantly lost interest because it's just too damn verbose to do a simple job. Java OOP is slightly better but still nasty once things get complicated and the underlying "functional" language is basically a C-a-like.

    I'm a fuddy-duddy. Old fashioned. If I write a program, the damn computer will damn well do instruction 1 followed by instruction 2 with the minimum of flying off into libraries and class systems. If I want 4 bytes of memory to change type, then I will damn well have them change type. And I'll even get to specify *what* 4 bytes of RAM if I want and I'll clean up after them if it's necessary. That's how I think, so things like C match perfectly when I want to code. The fact that C is damn powerful, fast, low-level and so common also add to it's appeal.

    I worry about what will happen when people *only* code in OOP languages. The abstraction is so large that people forget that they are still telling a computer to handle bits and bytes and suddenly they get lazy. M

  11. Ruby by RiotXIX · · Score: 4, Insightful

    On the plus side, both versions of Python can claim many of the smallest programs in the collection. Ruby (8, 1) might also compete for titles, but unfortunately its performance is so bad its star falls off the performance chart.

    Then why the fuck is the Ruby community hyping it so much, and drawing nieve young developers in to a trap?

    Not flamebait.

    Why can't they make a language, or extend a language like Ruby, such that one can program it as a scripting language, but then add verbosity optionally (i.e. declaring the data types and their sizes, private / static etc. & whatever the hell makes a program light weight and fast) optionally? It's my hope that if I stick with Ruby one day it I won't be forced to learn Python because performance won't be "Ruby's big issue" in every discussion, but really, that is *just* a hope. I hope this isn't a mistake.

    --
    "You know you don't act like a scientist, you're more like a game show host." Dana Barret
  12. Re:what about APL by mdmkolbe · · Score: 4, Informative

    If you would like APL to be on the list, then submit benchmarks for APL to the Shootout (the blog got its data fro there). The Shootout is mainly driven by user submissions. They do have some fairly strict rules about how to submit. However, if you can name an implementation (along with enough guidelines to make installing it easy) and provide a reasonably full set of benchmarks, then the language will generally be added.

    One tip about submitting though: try to make life as easy as possible for the guy who runs it. He doesn't have time to figure out typos or to fix "easy" bugs in some programming language they he may not even know.

  13. Re:Ada by Ada_Rules · · Score: 4, Informative

    Where's Ada?

    One item in the list is gnat which is one particular implementation of Ada. So, there is at least one Ada implementation on the list. I did not recognize any others.

    --
    --- Liberty in our Lifetime
  14. This is totaly stupid by FlyingGuy · · Score: 4, Interesting

    These sorts of things never fail to to amaze me.

    The verbs, nouns, semantics and such used in a given programming language have nothing, I repeat... NOTHING to do with performance!

    What does have to do with performance is the talent of the compiler / interpreter author, nothing more, nothing less.

    C implements ++ and so forth and so on. Pascal does not, you have to express it as var := var + x or in some implementations as inc(var) or inc(var,100). The smart compiler / interpreter author would implement those in the fastest possible way regardless of the particular language.

    The one metric that has real meaning is programmer enjoyment. Do you prefer terseness over verbosity or something in between. Does this languages flow amke you truly appreciate working with it.

    The only other real metric that has any true meaning is again the talent of the compiler / interpreter author. Was the the language parser built so that it can unfold complex statements that are often required to express certain ideas and perform certain operations. Does the language implement your favorite expression, eg: ++ , or something like that, which again harkens back to programmer enjoyment.

    So what it really leaves us with is, "Do you enjoy using that language?" and only you, the programmer can asnwer that question.

    --
    Hey KID! Yeah you, get the fuck off my lawn!
  15. Re:Ocaml by Anonymous Coward · · Score: 4, Interesting

    To be honest, I have the same reaction. I love OCaml, and am frustrated by the fact it hasn't been adopted more. It seems like a no-brainer to me.

    I've been following it over time, and I think the reasons for it have become clearer to me.

    1. I think the biggest reason is hard to articulate well, but basically I think the OCaml developers are sort of unresponsive to the community, which has been embryonic as it is, and as a result there's a sense that it's not moving in directions it should be. Numerical applications, for example, are one domain where OCaml interest has really been high, but the developers have been pretty unresponsive to concerns about matrix implementations. Comments by the developers on concurrency have also puzzled a lot of people. I don't mean to sound like a troll, but I have gotten the sense over time that while OCaml is wonderful as it is, it's not changing or moving anywhere, at least as quickly as it should be (in a bad way). Haskell is a good comparison to me in this regard, as it's a language that is also functional, but not as useful in applications than it is theoretically. However, Haskell has a wonderfully strong community, it is almost a model of how a language and its implementations can grow in a productive way.

    2. OCaml is occupying a difficult position, in that people who want cold, hard performance with stable implementations will go somewhere else (e.g., C); people who want theoretically elegant implementations will go somewhere else (e.g., Lisp, haskell), and people who want something simple will go somewhere else still (e.g., Python, Ruby). OCaml in many ways occupies all three places, but not quite as well as any one of them.

    Having said all of that, it's important to keep in mind that Microsoft is sort of pushing F# for 2010. F# is essentially a Microsoft implementation of OCaml for the CLR--very very close to OCaml--so maybe if F# takes off, there will be a big push toward OCaml.

    It's one of the few times I could say that Microsoft is really on target technically, and might actually move the numerical computing field forward.

  16. Re:Verbosity is bad because by Goaway · · Score: 4, Insightful

    Nowhere near true. Objective-C is more verbose than C, yet still more expressive, and largely self-documenting to boot.

  17. island paradise by epine · · Score: 5, Insightful

    When the first 4K TRS-80 showed up at my high school, I had the option to learn BASIC, Z80 machine code, or APL up the street at the local university.

    One of my early exercises with BASIC was writing a set of nested for loops which called a subroutine (gosub). I put the next statement that controlled the for loop iteration inside the subroutine, and the return statement for the subroutine inside the nested for loops. It still worked! At that point I understood that there were mechanistic languages and languages with a solid conceptual basis.

    APL's reputation for inscrutability was only halfway deserved. Often the problems arose when you were trying to shoe-horn a data structure that didn't want to be an array into an array, because that was your only hammer. Later APL supported nested arrays, which increased the data structuring options, but I think by then the PR battle was lost.

    In the original APL, it was kind of painful to pass more than two arguments to an APL function. This lead to programmers passing in flags to the function encoded in the array's rank, which were extracted to the tune of rho rho rho, while imaging the knapsack folding problem in Colossal Cave Adventure. As brutal as any language I've used. But you have to give APL a bit of a pass in some respects. Like vi, it was designed in 1963 to work well within the constraints of a paper teletype.

    The next level of inscrutability arose because the APL primitives could often be combined in novel ways to yield surprisingly powerful algorithms. IIRC, the IBM 370 APL included a JIT compiler for certain common APL idioms. A one line program I wrote in APL to find primes (sieve of Eratosthenes) ran ten times faster than the compiled PASCAL program by the CS student sitting next to me.

    Understanding APL was a lot easier if you were familiar with functional programming languages, but these hadn't been invented yet. Hey, I didn't know this: the Wikipedia page credits APL as a direct influence on FP, which I first heard of in 1982. Father knows best.

    So you encounter this unfamiliar pattern of 15 familiar symbols for the first time, and you brain is polluted with horrible iterative solutions from BASIC or PASCAL, and the beauty of the expression is denied to your limited frame of consciousness.

    Like solving a Suduko? Hardly. It takes me twenty minutes to solve a typical five star Sudoku. It used to take me about the same amount of time to puzzle out an unfamiliar APL one liner, which might be anywhere from 10 to 40 characters. There is one small difference: after decoding the APL algorithm, I usually slapped myself across the head and moaned to myself, "I am unworthy to drool on the shoe laces of the grand designer, but I will learn!" Never got that feeling from Sudoku.

    Wrestling with the higher art of APL was like giving your ignorance a root canal. Sometimes the root canal made me barf up my milk: when the highest art of APL was applied to shoe horn a data structure unsuitable to array representation into an array representation anyway, like the Beethoven scene in Clockwork Orange.

    The third case is where the one liner isn't all that difficult, but it's doing it in more dimensions than the brain wishes to visualize. This is a case where a picture is worth a thousand words. Your 20 character APL function would have been better presented as a caption on a one page UML diagram. Never figured out how to embed a UML diagram in an APL lamp statement on my VT100 terminal.

    Another problem APL suffered was too much kinship with Forth. To thrive in APL, you needed to create hundreds of tiny APL functions, which the implementations of the day mashed together into a single unmaintainable workspace.

    And the system interface tended to suck.

    But other than that, what's not to like?

    I could have composed instead a tedious, but germane post on Shannon's first law: concision is a function of preconception. It's a rare breed of programmer who thrives in a language which provides su