Code Bloat Comparison

By Deane Barker on September 18, 2005

Are All Programming Languages The Same?: Python wins with Perl and Ruby close on its heels.

Fair enough. Des Traynor wondered if this table was valid, so he performed a simple test: he provides examples of a tiny “read a file and print it to the console” app in Java, Perl, Python, and Ruby. I’ll reprint the smallest version here, which happens to be the Python implementation […]

Java was the big loser at almost 4x the lines of the Python version. However, see the comments for some complaints about whether or not to count bracket-only lines — a problem from which Python does not suffer. Ruby either, for that matter.

Gadgetopia

Comments

  1. This guy wrote too much Ruby code. I can do it in one line:

     puts File.open('file.txt').read
    

    Done. His version contains some exception handling, but if you’re just going to print it to the screen anyway, may as well just let ‘er fail.

Comments are closed. If you have something you really want to say, email editors@gadgetopia.com and we‘ll get it added for you.