Settings

Theme

Boilerplate Tax – Ranking popular programming languages by density

boyter.org

14 points by nnx a month ago · 14 comments

Reader

so-cal-schemer a month ago

"Clojure and indeed all lisp style languages are the final boss of density here though. Almost every line is an expression of business logic. I never really got into it myself, but looking at these results are starting to make me rethink that decision.

If you compare Clojure (77.91%) to C# (58.4%), it seems the average C# developer writes 20% more redundant code every single day just to satisfy the compiler. Even with tools like resharper and LLM’s to help thats not a insignificant amount of effort."

  • mrsmrtss a month ago

    C'mon, this is a bs "research".

    Fore example, is this Java (65.72% dryness)

        if (condition){
          Blah();
        }
    
    really more dense than this C# (58.4% dryness)?

        if (condition)
        {
          Blah();
        }
    
    Now, does this Clojure 77.91 dryness) really beats them both to that margin?

       (if (condition) 
          (blah)))
    
    This metric measures formatting more than anything else. I don't even go to other more nuanced details.
    • so-cal-schemer a month ago

      Good point. They should treat stand-alone braces and parens as empty lines and rerun the analysis. I'd like to see the results.

      But still.. are 41.6% the lines of C# code stand-alone braces?

      • mrsmrtss a month ago

        Probably not, but it’d be closer to Clojure. Depending on codebase you’ll likely have also many repeating namespace imports (can be avoided whith implicit usings in modern C#) etc.

        • so-cal-schemer 20 days ago

          Here's a better gauge for code density:

          https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

          How source-code size is measured

          We start with the source-code markup you can see, remove comments, remove duplicate whitespace characters, and then apply minimum GZip compression. The measurement is the size in bytes of that GZip compressed source-code file.

          Thanks to Brian Hurt for the idea of using size of compressed source-code instead of lines of code.

            median
            February 2025
            ===============
            Toit        558
            Perl        570
            Lua         580
            PHP         581
            Ruby        583
            Python 3    585
            Julia       634
            Chapel      646
            Racket      696
            JavaScript  698
            OCaml       741
            Erlang      798
            Go          831
            Dart        847
            Smalltalk   871
            Haskell     892
            Java        910
            Lisp        938
            Swift       939
            F#          943
            Pascal      959
            Fortran    1091
            C#         1117
            C          1121
            C++        1129
            Rust       1235
            Ada        1825
          • mrsmrtss 20 days ago

            The Benchmarks Game has some highly optimized implementations and is not a good representation of typical code. Some languages allow you to go a lot lower than others if needed, which adds verbosity, that does not mean typical code must be verbose. There are things possible in C# that you just can't do in Java, for example. That does not mean typical Java code is more concise than C#. On the contrary, typical C# would be probably considerably more "dense".

            • so-cal-schemer 19 days ago

              Good points.

              There is a trade-off.

              Outside hotspots, readability / maintainability should take precedence.

            • igouy 19 days ago

              > … is not a good representation of typical code.

              afaict that's unknown and "typical" weasel word and median.

        • so-cal-schemer a month ago

          I'd expect programming style to have a lot to do with it. Many modern languages are evolving toward Lisp and support ever more of its features. Generic programming and meta programming for instance.

          (I think the tool used accounts for imports and defines.)

so-cal-schemer a month ago

Succinctness is Power

https://paulgraham.com/power.html

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection