Monday, February 06, 2006

I like Perl.

Normally I'm an OO purist. I also favor the C-family-style syntax. This is why i love C# and dig C++. But perl is fun. Just fun. And also quite brilliant.

Consider the UNIX command cat. It reads from standard input OR from files specified as arguments and outputs the content to the console.

In perl you could implement a basic cut command like this:

foreach (<>) { print; }

That's it. Try to do the same in C/C#/Java/whatever and you'll end up writing quite a few lines of code. Another example: the UNIX command sort.

foreach (sort <>) { print; }

Bloody brilliant. The cool thing about perl is that it makes easy stuff really easy. I wouldn't use it to code larger programs but for simple suff it's amazing. Also the code tends to get quite hard to read so it's not something I would use in team development:)

Again, coding in perl is fun. When you have tried the basic stuff it almost becomes a sport to write as little code as possible. And as you can see, perl is good at doing a lot of stuff in few lines of code.

No comments: