Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

  (email not shown publicly)

Blog Information [] Profile for chr0matic []

Journal of chromatic (983)

Thursday November 17, 2005
01:33 AM

Dumb Comments about Readability

[ #27612 ]

I'm okay with people promoting Ruby to Java programmers, in the theory that Java isn't the be-all end-all of applications. However, I'm fairly not okay with amazingly stupid claims such as:

PHP and Perl haven't consistently produced readable code for larger applications.

What exactly does that even mean? Are PHP and Perl somehow preventing people from writing maintainable code? Does Ruby somehow enforce good design, good naming conventions, encapsulation, and consistent interfaces where PHP and Perl don't?

Okay, I've often pointed out that PHP has a lot of flaws that make it difficult to write and maintain applications beyond a few pages -- lack of namespaces, inconsistencies in the standard library, backwards incompatibilities, and weird syntax issues. However, the most important work is that of the programmer. Programming languages and libraries are just tools. If you're a deranged ape with no sense of design or style, of course you're not going to write maintainable code, whether PHP, Perl, Ruby, Java, Lisp, or even XSLT.

It's probably never going to happen, but a debate worth having is whether one language can be an order of magnitude more maintainable than another. Aside from the obvious non-contenders (Malbolge, BF, and Befunge, for example), are there any mainstream programming languages that really enforce any sort of meaningfully good style that actively prevents people from writing bad code? Frankly, Python's enforced indentation is a heck of a lot less useful than enforced meaningful identifiers.

Why are there so many unmaintainable applications written in PHP and Perl? Because PHP and Perl let undisciplined, inexperienced programmers write useful code. So does Ruby -- but give it the popularity and longevity of PHP and Perl (at least in English-speaking circles) and I bet you'll see plenty of bad code written in Ruby too.

This seems like a variant of the Hackers and Painters fallacy. (Paul Graham is rich. Paul Graham writes Lisp. Therefore everyone who writes Lisp will get rich.) "All of the good, smart programmers I know are using Ruby. They write good code. Therefore you can't write bad code in Ruby!"

It feels like there's another fallacy in there somewhere. I want to call it the Pre-Post-Java Blindspot, where Java was the beginning of Serious Programming Languages and only its successor will unseat it. (Like any good fallacy, you have to ignore history, such as the fact that Ruby's between 10 and 12 years old.)

(I mean, if you really just can't read regular expressions, why not admit it? You could start a twelve-step program or something.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I keep looking at their Ruby examples and wondering what I'm missing. How is this going to enforce readability? It looks just as loose and full of punctuation and freaky syntax as Perl, yet they keep talking about how easy it is to read.

    The whole readability issue would make more sense if they were talking about Python. Python at least makes an attempt to eliminate TMTOWTDI, which is an active attempt to make it more maintainable (although it may be misguided, depending on who you ask).

    I just have to a

    • You might care to take a look at:

      it builds on Chromatic's view that the quality of a program rests with the skill of the programmer and not the choice of programming language. Again, it has a pop at Ruby in this regard.

      The drink-me document also shows how it is possible to combine perl-python-ruby re-entrantly, using program folds, and so there is no point squabbling over which language is best. When push comes to shove: a program is just a bunch of charact

  • The Ada programming language [] was specifically designed to generate sound code that was consistent and readable. I think that experiment shows you what happens when you have a language so tight there is only one way to do anything. It has many strong features, but can be difficult to program. It's also very difficult for beginners, which I think illustrates your point about the low barrier to entry for PHP and Perl.
    • OO baked right in
    • Rails
    • Was there something else?

    I seem to remember that Ruby used to be compared to Perl by using the statement "Ruby is an object-oriented Perl" or something close to that.

    I have been programming Perl for 1 year now. I and those I work with can look at my programs and see what is going on. Just because Perl can be used to write ecclectic line noise, doesn't mean you have to. I made a decision when I started my Perl would not be unreadable.

    • Ruby does five things much better than Perl.

      Ruby blocks are very convenient. There's a lot of goodness in making closure-passing simple, easy, and syntactically lightweight. There's also a tremendous amount of goodness from making the language core aware of such constructs.

      The strong built-in object orientation gives Ruby a lot of power too. I credit Smalltalk. Though I'm still unsure how I feel about the looks the append operator in general, being able to declare objects that respond to it, or the

    • “Ecclectic line noise” is my new favourite phrase.
  • Ruby's a cute language for OO, if only for the easy of handling arguments. If I never have to type

    my $self = shift;
    my(@arg1, @arg2, @arg3) = @_;

    again, I shall be a happy man. But sigillessness does not automagically imply readability, not by a long chalk. And every time I find myself doing: results = [anobject.some_call].flatten because ruby doesn't have context and the author of the framework I'm using didn't make the return signature of 'some_call' consistent across all subclasses... well... it's annoying
  • Great post! I've been thinking about readable languages. It seems like the selling point of Ruby/Python/Java/etc is the code is more readable because it doesn't have built-in language support for regex syntax, therefore the code is more elegant looking because you don't have inline regular expressions. But these languages factor all that out into libraries, and as soon as you use the libraries, the code has regexes in it and looks about the same as Perl. The Ruby/Python/etc samples look clean and OO but if