Tuesday, January 13, 2009

From the Wreckage Known as Perl...

Many years ago, I was setting up cvsweb to display CVS repositories on my web server. There was something funky going on (don't recall what), and so I went to go and fix the script. No problem, right? It's Open Source, after all!

Yeah. Right.

Hey, I'm no slouch as a programmer, and can actually get around a bit in Perl. But that cvsweb script is an absolute disaster!! (I suspect the FreeBSD peeps have fixed it tremendously; it was core to their version control for many years; but I'm talking back in 1999).

I'll repeat that again: DISASTER

Global variables. Functions with strange side effects. Sloppy organization. Poorly named functions and variables. Few comments.

One of the things that I've learned about Perl over the years is that it takes an advanced Perl programmer to produce maintainable code. Novice or intermediate programmers produce crap. The language is just so fluid and forgiving, that it is easy to create write-only code. I recommend Python to people because you only need to reach an intermediate level to produce reasonable code.

Back to cvsweb. After staring at the depths of hell for a while, I realized there was really one solution to the problem: rewrite it all in Python. I spent a weekend doing just that. About 2500 lines of Perl became 2500 lines of Python, and I published it as "ViewCVS".

That tool has since grown support for Subversion, been renamed to ViewVC, and is being further developed and maintained by some friends.

No comments: