?

Log in

No account? Create an account
To The Side

Ooh, I Made Coding Horror :-D

A friend just pointed out this post, to me. :-) I'm honored to be showing up on Coding Horror. :-) It's funny, because I was just thinking of adding it to my aggregator the other day.

Anyhow, this is my response:

Software Quality: Code vs. Interface

I actually have a lot to say on this subject. I wrote a blog post about software quality a little while ago.

I think the ideal situation is that people design their code correctly from the beginning, and also make a good user interface to go with it.

Of course, in the "marketplace" (whether it's paying customers or just free downloaders) what the program does is king. A program that works better for the user will be used by more users (barring a highly effective marketing campaign by the inferior software). Every currently successful software company knows this. Most of the code I've ever read, for any product anywhere, is horrific.

But personally, I'm more concerned with whether or not people are still going to be using my software in five years, not whether they're going to be using it right now.

The reason that Bugzilla 3.0 has so many new features and also saw about a 5x increase in downloads over any other version is that we spent three years refactoring. Before that refactoring, I think we were in real danger of being blown away by the competition.

But then, at the same time, the reason that we weren't blown away was that we added new user-visible features, not purely because we refactored.

A Bit More About Perl

Since the "problems of Perl" post, I've had the opportunity to start a brand-new project in Perl that was entirely my own, VCI. I did it in Perl because it has to interact with Bugzilla, but also because I wanted to see if using all the modern techniques of Perl development could lead to well-architected code from the start.

I found that Moose is the best object system in any language I've ever used. I find it weird that when I go to write in other languages again, I'll probably think, "Gee, I wish this had Moose." I used to think, "I'm so glad this language isn't Perl" (except when dealing with regular expressions, which are so much easier to use in Perl than in other languages). But with Moose, I just wish everything had Moose.

The problem with Perl, I think, is that the basic documentation that everybody reads doesn't say, "Okay, here's the Good Way To Do Things. Use Moose and Be Object Oriented." I had to really go out of my way and research the best way to do things in modern Perl. There are ten thousand (or more) modules on CPAN, which is great, but...there are ten thousand modules on CPAN. Thankfully we have IRC and blogs, or it'd be pretty tough to find out what the current "best" way to do things is, with Perl.

On the other hand, when you read up on Python objects, it's pretty straightforward: "Here's how you do it. This is the way. It's the only way, and if you don't like it, tough, but at least it's basically a good way." It's not as good as Moose, but it's the way that everybody does it, because it's the One True Way from the documentation. So everywhere you go, Python code is at least consistent in that respect.

So Perl isn't fundamentally flawed, but it's kind of flawed in practical terms, in the way that it's commonly used. Imagine that you had a book that taught you how to write, and then after you were done with it, somebody had to come up to you and say, "Okay, that's not really how you write. I mean, you could write that way, but everybody would laugh at you. Also, you can't use that pencil, you should use this special pen, because it makes life a lot easier." There's nothing wrong with the language you're using to write, but there is something wrong with the instructions you were given and the tools you were handed.

Now, I'm still concerned about the popularity of Perl and the ability to find new contributors. Perl has a fairly big user base right now, but I don't know that it's growing in the same way that the Ruby and Python communities are growing. With my five-year view on things, that's a real concern to me.

Because the "problems of Perl" blog post was so popular, the subject does come up again and again, and so it is something that's on my mind from time to time. Perl actually has a lot of great attributes, but unless developers broadly realize that Moose is great and that they can use DBIx::Class and Catalyst for their web applications, and the Perl community welcomes them kindly and with the understanding that they do not already know everything, I'm concerned about the future of Perl.

-Max
Tags: ,

Comments

Any chance on getting a summary of the advantages of moose over python's oo system?
Hrm.

The big advantages are type checking, simple automatic creation of attributes and accessors, "roles" (much like Java's Interfaces), automatic creation of constructors, a modular system for creating defaults for attributes, "type coercion" where you can specify ways to change one type into another (for example, a string into a DateTime object) automatically when supplied to your constructor or setters, the ability to have method modifiers like "before" and "after" that run code before or after the superclass's or subclass's method, ways of "modifying" a subclass method from the superclass, and a kick-ass introspection system.

I might be missing some things, but I think that covers it pretty nicely.

-Max

(Anonymous)

Interfaces? Pah!

Roles are at least ten times as awesome as Java interfaces. See my "Composable Units of Object Behavior" weblog for more.

Re: Interfaces? Pah!

Hahaha. :-) Yes, Moose's Roles are definitely cool. :-) I just used Interfaces as the closest example that most people would understand.

-Max

(Anonymous)

Uh... besides "before" and "after" pretty much *every* modern typed OO language has what you're describing.

The absolute best OO system on the planet at the moment is Lisp's CLOS (where :before and :after came from).

I suspect Ruby could do everything mentioned here as well except for the typing part (which could easily be written as least as good as this).
Modern typed OO language. But even for things like Java, type validation is painful for custom types--I have to create whole new classes for them. With Moose it's easy.

CLOS was one of the primary inspirations for Moose, yes.

Ruby cannot do everything mentioned there, at least not as easily or as simply as Moose.

-Max

(Anonymous)

So you mean: has some features of CLOS but not all, and one has use perl to get it? No sale here. :)
It's inspired partly by CLOS, and partly by type theory and a paper on Roles., I believe.

-Max