Amazing SCALE weekend

February 14, 2007

Last weekend (Feb. 10-11) I spent volunteering at the Los Angeles Perl Mongers booth at SCALE. A lot of people showed up at the LA Perl Mongers booth and were very impressed! Our plan to slowly convert every programmer to the Perl language seemed to be working ;-) The whole event was just mind-blowing. So many uber-interesting booths and presentations!! I attended a talk by Jay Pipes on Maximum velocity MySQL. The talk was packed with extremely valuable information on advanced query optimization and tuning MySQL for optimum speed and performance. I didn’t know that the person sitting right next to me was one of the co-founders of MySQL David Axmark. How cool is that!! :-)

I also attended a talk by Frank Wiles on Introduction to mod_perl2.


Volunteering at SCALE

February 6, 2007

I will be volunteering for SCALE on Feb. 10th and 11th at the Los Angeles Airport Westin. If you happen to attend, come and say Hi. You can find me at the Los Angeles Perl Mongers booth. I’ll be there from 10 a.m. till 6 p.m. While you’re there, you can check out a neat demo prepared by Juan Natera demonstrating the speed and performance of Perl compared to other languages and technologies.


Perl advocacy

January 30, 2007

Programming republic of Perl

How often do you mention “Perl” to a group of programmers/software engineers and get that strange look on their face? I recently had that experience. I was meeting a few fellow programmers (who happen to be core Java developers) and casually mentioned that I was attending a Los Angeles Perl Mongers meeting later that evening. To my utter surprise, all of them seemed to be either disgusted or weirded out as if I had mentioned something completely absurd. Um..Did you just say Perl? They were of the strong opinion that Perl was an outdated, hard to use, hard to maintain, old school 1990’s scripting language and why would you even want to think about it in this day and age of Java, PHP, ASP and oh of course, the hottie Ruby?!? One of them even said with a funny look on their face, “You really like Perl? Do you write one of those long, crazy, obfuscated one-liners that are a nightmare to look at?” I was in shock. After all, these were highly seasoned engineers with years of solid experience working at top companies building cutting-edge stuff. They weren’t some recent grads holding the newest edition of the next AJAX or Ruby book. And they had such disgust and ignorance for such a beautiful language! Well maybe, this experience was a bit extreme, but rarely have I gotten enthusiastic responses. Unfortunately, this attitude is reflected by many (if not most) within the current technology market and it’s hurting Perl badly in many ways.

So, Why Perl?

The usual pluses:

  • Cost: Software costs for deploying the entire LAMP (Linux, Apache, MySQL and Perl) stack – $0. For everything else in life, there’s MasterCard.
  • Community: Perl community is filled with some of the smartest and the most interesting individuals.
  • CPAN: The largest repository of re-usable Perl code. Enough said! (PEAR doesn’t even come close, although there are quite a few good modules available on there.)
  • Open source: The entire Perl source code and its modules is available to be browsed or tweaked
  • Availability: Perl is installed by default on almost all *nix platforms.

The solid pluses:

  • Performance and Efficiency: mod_perl is by far the best thing since sliced bread. Also check out perlbal – a Perl based reverse proxy load balancer and a webserver and memcached – a caching solution – by Danga Interactive.
  • Templating systems: There are a wide variety of powerful templating systems available. Take your pick from HTML::Mason, HTML::Embperl, HTML::Template, Text::Template, Template::Toolkit, Apache::AxKit and many many more.
  • MVC Platforms: Just like RubyOnRails, Perl offers various MVC frameworks such as Catalyst, Maypole and Jifty.

These are a few of the advantages that just pop-up in my mind. The list is quite far from being exhaustive.

Some basic Myths:

  1. Perl is hard to learn and code: Just like any other language, Perl has it’s learning curve. It might appear in the beginning that since there are so many ways of doing the same thing, it’s all too hard to learn. Trust me, its not! It’s all about mental inertia. Once you start coding and reviewing a lot of Perl code, this will all seem natural. (Now, the whole Java world can be bewildering!)
  2. Perl code is hard to maintain: This is not completely true. Badly written code written in any language can be hard to maintain. I’ve had to deal with terribly written, completely undocumented, spaghetti PHP code. And good luck counting those indentations in Python. There are established Perl best practices and conventions that, if followed, can help immensely in writing elegant, understandable code. You break the rules, you pay! Simple as that. Doesn’t matter what language you code in. Don’t forget to check out the Perl::Critic module on CPAN. It offers an extensible framework for enforcing coding standards and best practices.
  3. Perl is slow: This one can’t be any farther than the truth. Have you heard of mod_perl? When it comes to squeezing out the last drop of performance from your Apache server, there is nothing like mod_perl (other than the C language, of course). My colleague Juan Natera has developed a nifty little demo to be presented at the upcoming SCALE highlighting the speed of Perl apps vs. other languagues. You can see the post here.

A little googling around will reveal that there are a lot of sites/articles on Perl advocacy out there. One particularly good link is here.

Here are my two cents:

  • Get Perl 6 released (soon) and hype it up! Believe it or not, but Perl really needs to glam up this new release if it expects widespread attention. Most of the cutting-edge apps are written in Perl or use mod_perl, but how many times do you see “Powered by Perl” or “mod_perl inside” mentioned? You see the Python and Ruby communities do this quite often. 37 Signals, for example, has been evangelizing Ruby extensively. You see Python being mentioned a few times if you’ve ever subscribed to a mailing list using Mailman.
  • The local Perl mongers are doing a great job of bringing the Perl community together. I love my Los Angeles Perl Mongers meetings. One thing I’d love to see more Junior to mid-level members being invited to present a topic. Of course, we all love to see Perl Gurus come and give us a talk – that’s always the biggest treat. But encouraging budding Perl developers to come and share their experiences or to research a particular Perl or related technology that they’ve just taken up and present it to fellow Perl Mongers. This does a few things: surely it pushes the “presenter” to get a better grasp of the topic being presented, which would involve extensive research, implementation and lots-n-lots of learning. Not everyone knows everything. Even if some people have used, say advanced OO Perl programming or Webservices in Perl, there are quite a few who’d love to learn more about it. There will always be an interesting audience available. I would strongly urge the local Perl Mongers to invite talks and presentations from the entire spectrum of Perl talent.
  • More companies should hire and train programmers in Perl. There are companies out there that do that and hats off to them. They’re doing a great job of it. But most of the companies out there are looking for senior to mid-level Perl software engineers with quite a bit of experience. This doesn’t help those who want to grow and mature as Perl developers. Other technologies, such as PHP, Java or Ruby, have encouraged junior developers immensely. But then again, many of them don’t even come close to the quality of Perl Engineers :-)
  • Hackathons!! The Chicago Hackathon was a major success and we definitely need to have more of those.
  • Encourage academia to include Perl in their courses. Most of the programming classes use or recommend using either C/C++ or Java for their projects.

Please feel free to comment and give your feedback. What are your suggestions as to how we can further the Perl advocacy? I’d definitely love to hear. Long live the Programming Republic of Perl ;-)


Handling “Undefined subroutine called” errors in mod_perl

January 18, 2007

So I wrote a sample mod_perl handler. It’s a simple hello worldish module. After registering the module in the httpd.conf file and restarting Apache, when I tried to access my module via the specified URL, I got the dreaded 500: Internal Server Error. The Apache error_log indicated “Undefined subroutine &Apache::Hello::handler called”. My file name was Hello.pm and it was placed under the Apache folder under my ~/lib/perl directory at the server root. My program was compiling correctly. Here’s the original code:


#!/usr/bin/perl
use strict;
use Apache::Constants qw(:common);

sub handler{

my $r = shift;

$r->content_type(’text/html’);

$r->send_http_header;

my $host = $r->get_remote_host;

$r->print(<<END);

<HTML>

<HEAD>

<TITLE>Test mod_perl Handler</TITLE>

</HEAD>

<BODY>

<b>Go mod_perl!!</b>

</BODY>

</HTML>
END

return OK;

}

1;

As you can see the code is very simple. After some googling around, I found out that the real reason for the error was namespace collision. When two scripts or handlers call a function defined in a library without a package definition, or when the same subroutine name is used in two different scrips or handlers being called, there is no clear idea as to which script’s ‘handler’ function to call. So, I added a package definition as shown and it fixed the error.


#!/usr/bin/perl
package Apache::Hello;
use strict;
use Apache::Constants qw(:common);

sub handler{

my $r = shift;

$r->content_type(’text/html’);

$r->send_http_header;

my $host = $r->get_remote_host;

$r->print(<<END);

<HTML>

<HEAD>

<TITLE>Test mod_perl Handler</TITLE>

</HEAD>

<BODY>

<b>Go mod_perl!!</b>

</BODY>

</HTML>
END

return OK;

}

1;

A good link that talks about troubleshooting runtime mod_perl errors is provided here at Stas Bekman’s mod_perl guide.


USC’s Dwayne Jarrett leaving for NFL

January 11, 2007

USC’s star wide-receiver Dwayne Jarrett announced today that he’ll be leaving early for NFL draft. Although, everyone at SC would’ve loved for him to return for his senior year and win a national championship. But oh well, good for him. The guy had a phenomenal season.

Along with Jarrett, another star receiver Steve Smith will also be leaving as he’s graduating. But the coming season looks very promising for the mighty Trojans with much of the defensive and offensive squad returning, of course not to mention the red hot John David Booty. I’d be highly surprised if SC isn’t listed as #1 coming into the next season. Sure Florida beat the heck out of Ohio State, but USC pummelled Michigan and LSU spanked Notre Dame. Frankly, Florida’s schedule was tougher than Ohio’s so I kind of expected Florida to beat Ohio, just not in this fashion. LSU’s quarterback JaMarcus Russell will also be leaving for the NFL. He had a solid game against the Irish.

Among other USC Football news, coach Pete Carroll made it very clear that he has no plans on leaving the head coaching job at SC for the Miami Dolphins coaching job. The Dolphins owner met with Pete Carroll in Costa Rica where Carroll had been vacationing. Apparently, Carroll was impressed with the way the Dolphins owner runs the organization. The head coach has the final say in running the team. But Pete Carroll has his eyes set on another USC National Championship. Thank God! We need you Coach Carroll. LA needs you. The USC Trojans are the NFL team for the City of Los Angeles. Rumors of LA getting an NFL team no longer bear any credibility. We’ve heard that a lot. While some team owner steps up and negotiates with the city and brings a team to the City of Angels, the mighty Trojans will remain our city’s team! Sorry UCLA, but you guys aren’t anywhere near as good as SC. Sure, you caught the Trojans off-guard and beat them this season, but watch out for another long streak of SC over UCLA. Even the USC basketball team has been doing great lately. Way to go Trojans!! Fight on.


Apple’s new iPhone

January 11, 2007

As if you didn’t already know, Apple’s Steve Jobs unveiled the cool new iPhone at MacWorld in San Francisco yesterday. And today Cisco sues Apple over the use of the iPhone name. Cisco registered the iPhone name in 2000 for it’s internet phone and Apple was in intense negotations for rights to use that name. Apple was supposed to get back to Cisco right away with signed agreement, which it didn’t and obviously Cisco filed a suit today. Apple’s shares fell nearly 1 percent in after hours trading. Steve Jobs, ya better get those docs signed if you want iPhone to be publicly available by July as advertised.

Regardless, iPhone is one heck of a device. It’s truly revolutionary. The iPhone features a wide-screen iPod, a cell phone, a wireless communications device, a web browser, a 2 megapixel camera – all in one. The intuitive multi-touch screen is fascinating. The touch screen even de-activates when you bring the phone closer to your face as you’re talking over the phone, so that you don’t accidentally face-dial. Impressive. But I’d wait for it to mature and the coming versions of iPhone would be even better. Think of new carriers offering their services through iPhone, 3G broadband capability, a camera phone with much more than it’s current 2 megapixel capability, larger storage capacity and much much more! I’m excited already.

Apple also announced it’s taking orders for Apple TV which lets you watch movies dowloaded on your PC on a high definition flat screen. How cool is that!! Apple rarely ceases to amaze me.

With a slew of gadgets, Apple’s reshaping it’s image as merely a computer company. Apple Computer Inc. is now known as Apple Inc. Which shows that it’s now a consumer electronics company.


Emacs vs. vi aka. The Battle of the Editors

January 8, 2007

To vi, or not to vi: that is the question:
Whether ’tis nobler in the fingers to suffer
The h’s and l’s of outrageous fortune,
Or to start using Emacs

I’m a long time vi user and still prefer it over any other editor. Although, lately I have been paying some serious attention to emacs. One thing that I don’t like about vi, is that if you have the most basic version installed, then it doesn’t come with syntax highlighting. Sure you can upgrade and get vim, but what if you can’t? And what if the only other alternative would be to use emacs which comes with built-in syntax highlighting for most languages? For most people, using their favorite editor is a matter of life and death (well, almost). Programmers are known to defend their choice of editors with religious fervor. Talk to them about the possibility of using some other editor and they cringe.

The choice of editor depends on many factors. If you’re primarily developing on Windows platform (and maybe ftp’ing or syncing your files with a remote server), then Eclipse is the best. It’s free and it comes with a whole lotta plug-ins for pretty much every language and technology. For Linux platform, it’s either vi or emacs. Although, both editors come with their own strengths and weaknesses, it’s best to know both. You should be at the very least able to open, modify, save, close without saving and undo (very important!) in both editors.


Top Companies to work for

January 8, 2007

CNN Money released a list of 100 Best Companies to work for and Google was ranked #1. Some facts that kind of surprised me: Microsoft ranked #50, Yahoo #44 (I would think Yahoo should be ranked a lot higher – probably in the top 10), No Amazon, No ebay. I know I’m just talking about tech companies, but that’s because it’s the only sector I’m familiar with. Maybe they should come up with a list of 100 Best Tech Companies to work for. Regardless, it’s a very good article.


Apprentice LA

January 7, 2007

The first episode of Apprentice Los Angeles aired today. It’s been quite a while since I saw Apprentice. I believe I saw the first season and a little bit of the second one, that’s about it. There are a few reasons I might watch Apprentice this season:

  • It’s in Los Angeles and has a fresh look
  • The loosing team ends up being in a tent – this might add a funny element as the season progresses and the tent wears out. But that’s how life is.
  • Ivanka Trump

In the first episode, the teams were challenged with running a car wash. The Sunset Car Wash that one the teams were working at is less than a block away from my house and it’s where I usually get my car washed. Hmm… come to think of it, I might have seen one of those guys who got fired still working there!

Frankly, some of the contestants looked like complete dumb asses. But overall the teams look quite competitive. Ivanka was very impressive. She quite a competitive business woman. This should be a good season.


Age is just a number…

January 4, 2007

I got an email today from my boss letting me know that my insurance just went up slightly. I got a little confused since I hadn’t been to the doc’s recently and I inquired about the cause of this increase. Apparently, my insurance went up because I just turned 30! I almost fell of my chair. According to the insurance broker, when I signed up last year, I was in the 0-29 years age range and my rate was for that range. Since I now belong to the 30-34 years age range, my rate was slightly higher. What!!! I mean cmon now, cut me some slack here. I’m trying to get used to being in my 30’s now and this certainly doesn’t help. I feel like I’m a 20-something (Mr. Insurance guy if you’re reading this, get me back on my previous rate, can ya?).

If I said the word “like” 20 times in a sentence, would that help me?? How about if I wore Abercrombie & Fitch? OK, how about Hollister then?…

They say that age is just a number… tell that to the insurance guy!!! grr…