Sunday, January 18, 2015

Perl Already Won

This post is a response to the Yet Another Perl Rant article which appeared on hackernews.

Without being a special kind of paranoid or conspiracy theory adept, I can't help myself noticing that from time to time an article appears which tries to convince us that Perl is dead and there are no reasons to learn it.

TL;DR

Perl already won once - in the nineties it was the technology that powered the whole web. It got a market share that none of the 'cool' languages will ever be able achieve - be that Python, or Ruby, or Go, or Node, or whatever. Be that backed by Google, Facebook, Twitter, Craigslist or Booking.com. PHP is coming close, but it won't achieve it, exactly because of the cool new programming languages, because of the much larger internet market and of the diversity of software developers. 

I believe the main reason haters gonna hate Perl forever is because their language of choice will never achieve its dominant adoption.

Transition to Perl

I started programming in Perl in 2010, after 4 years of professional software development (in progress) and after I did some projects in PHP, Ruby and Python.

I have to admit, as a programmer it wasn't really easy to start with Perl:

  1. Having those list, scalar, string, or void contexts is pretty confusing when you're first exposed to them. 
  2. The types of variables are totally different from anything that I've seen that far - scalar, array and hash type. 
  3. It was also hard to get along with the TIMTOWDI (There Is More Than One Way To do It) principle which is everywhere - should the $customer->orders method return undef when no orders are present, or should it simply return, or should it return an empty array or maybe an empty array ref - this is just one question that I found myself asking over and over again.
I had all of the above issues clarified after I read Damian's Conway Perl Best Practices and Intermediate Perl.

I came for the money and stayed for the robustness

I decided to switch from Progress because there was only one company in Cluj-Napoca that was using it. While you would normally expect, as an extremely specialized technologist, to earn a bigger salary because of the scarcity of experts in a certain field, the opposite was true - I earned a smaller than average salary, exactly because I could do nothing about it (ie I didn't had where to go). Although I wanted to switch to Java, the first opportunity I had was Perl. Given that we had at that time about 5 companies that were doing Perl development in Cluj, and that the salary this company offered, as a junior Perl developer (I wasn't able to even code the 'hello world' without googling it), was bigger than the one I got as a senior Progress developer with a commitment of salary negotiation after one month with the company, signaled me that there had to be something good with the language that I've only heard about it looks the same before and after it is encrypted. 

While I worked as a Progress developer, I was doing the whatever part time project I wanted to work on using technologies like PHP, Ruby and Python, mostly because of the high costs of running a Progress app (at that time they were charging even for the runtime VM, I don't know if that still applies). I don't have any public project since that time. When I switched to Perl I decided to use it for everything I do - I wanted to see if that's possible, without losing any productivity and in order to become more proficient in the language.
As a result, I currently have 2 extra projects that I work on and have real users www.eatfab.com (a food ordering application) and www.prforge.com (a crowd speaking platform).

The right tool for the right job

Since 2010 when I started to develop in Perl, I found out that Perl has everything that I needed, some more and they're all rock solid pieces of software:

  1. Want a RoR like framework? go with Catalyst
  2. Want a Sinatra like framework? choose between Dancer2 and Mojolicious
  3. Want an uber ORM? - go with DBIx::Class (dbic)

That's why Perl became my golden hammer

Young but wise

I think that the average age of a Perl developer is about 35 years (I have no official data for this, my hunch is based on the people I saw at numerous YAPCs I had the opportunity to be present at). Assuming this is true and assuming a dev enters into production at 23 years old, it results that the average Perl developer has 12 years of software development experience.
What kind of code would you prefer in your business critical, money making software products? one written by people with an average of 12 years experience in the language of choice, or one written in a language that appeared on the radar in the last decade:
  1. Ruby on Rails, the framework that made Ruby popular was launched in late 2005
  2. NodeJS is not yet at version 1, having its first version launched in May 2009
Regarding youth, Perl's last stable version is 5.20.1, released in 14th of September 2014. The Dancer2 framework had its first release in 2013 and it had 37 more releases since then. Mojolicious reached version 1 in December 2010, now it's at version 5.72 - have a look at the frequency of releases.

In my imagination a language that is dying does not have frequent releases, nor it has modern frameworks and it doesn't inspire other languages also.

A short story

I currently work on a project written completely in Perl for a company that sells economic reports - lets call it X, because I don't have their permission to use their name. The project was started around 1998 and for about 8 years there were less than 3 developers who supported the whole online division of the company. The company that I currently work for (an outsourcing one) started to assist the X company with the project around 2008. If I remember correctly, between 2008 and 2012 there were no more than 5 developers assigned to the project from my company at any one time.

In late 2012, a new CIO was hired by the X company in order to help with modernizing their so called legacy codebase. It was indeed legacy - the whole website was done entirely with CGI.pm. The new CIO promised to rewrite the whole system in .NET in just one year, because you know, how much functionality can be implemented by an average number of 3-4 developers in a technology that is so old and rusty as CGI, while also maintaining the core, business critical and money generating, functionality?

So, in November 2013 they started to lay out the business logic that takes place in the online app in order to be able to start implementing it in early 2013 so it would be done by the end of 2013.

It was March 2013 when the CEO decided to stop the idea of rewriting the app in .NET because they weren't able in those 4 months to even define the scope of the project. The CIO was out.

My company made the commitment to rewrite the whole app using Modern Perl and to also respect the original schedule, compensating the time lost because of the unsuccessful .NET rewrite attempt. I remember my department manager saying after he came back from company X with the project "I might have made the most stupid commitment ever, but it might also be the best".

Long story short - by October 2013 we rewrote 90% of the old application using Catalyst and DBIx::Class on the backend and Bootstrap from Twitter on the front end. By the mid of 2014, the old application, the CGI one, was taken out of production.

There was no business interruption because of the rewrite.

Conclusion


Watch out for whoever says that Perl is an ancient technology, because they're either ignorant and completely clueless about what's really happening in the world of computer programming, or they have hidden agendas.

I know, this might be a biased post - I love Perl, but so are the posts that people wright when they say it is irrelevant. Let me ask you a few biased questions:

  1. Why do you love Perl?
  2. How did Perl helped you in your profession?
  3. How did Perl helped your company?
  4. How do you intend to use Perl in the next years?

5 comments:

  1. So in your opinion Perl would be better than ASP.Net ?

    ReplyDelete
  2. "I believe the main reason haters gonna hate Perl forever is because their language of choice will never achieve its dominant adoption."

    So your leading argument as to why people "hate" Perl is that they are jealous? *sigh*...

    As a Perl, PHP and C programmer since the late 90s, I can't relate to any part of that argument.

    ReplyDelete
  3. Perl is a programming language. ASP.Net is not, so this comparison is irrelevant.
    Perl 5 has its disadvantages, but other languages have their disadvantages also, and depending on each one's needs, some of their disadvantages may be bigger.
    C#/Java are too verbose so low productive, C is too low level so great for speed but low productive also, Python/Ruby are modern and good languages but they are slower and have a worse support for Unicode, plus that they both share some of the disadvantages of Perl (like multi threading support), PHP... we are talking about programming languages here :-)

    As it was said, the life is more complicated so we can't say that the envy is the single reason.

    If somebody used Perl many years ago, when it was a very successful language but a pretty bad language in modern terms, or if somebody tried to force Perl to make programs which were not very appropriate for a language like Perl, because just like any other language, Perl is not good for everything, then that person might have been needed to abandon Perl and make an effort of learning other languages. That person will surely hate if he or she sees that now Perl didn't die but it is actively updated and used. It is like when somebody made an effort of buying some shares on the stock exchange, then is forced to sell them and buy other stocks, and after a time that person sees that the stocks he holded in the past still have a good value. He would really hate those stocks if their value would increase after he sold them.

    Another reason is that the most verbose programmers are usually those who are young and have the necessary time and energy to express opinions, and there are good reasons why the young programmers use to prefer newly appeared programming languages as now is the case of languages like Go or node.js.
    A new appeared language is relatively new for both newbies and old programmers, so the newbies are not very much disadvantaged, or in a certain measure they are even advantaged, because it is easier to learn a new programming language at 25 than at 45, because there is more free time, a better motivation, good energy etc, so it is easier for beginners to compete with old programmers if a new language is used.

    Another reason some people like languages like Java or C# is that they were promoted at enterprise/government level, where paying extremely large teams of developers is not a problem, so they were also promoted by state in the public education system. The result is that the graduate students use to prefer the languages they know and really hate to hear that there are other languages which are more productive or which are better for some specific things.
    And they would surely hate to hear that such a language is Perl, which has a syntax which is pretty different than the syntax used by the languages they learnt in the school, so it would be probably a little harder to learn it.
    And surely there are many other reasons to hate a language. I also hate that C is much faster than Perl. I also hate that Java has a better support for threading, I also hate that C# has its own graphics library that can be used for creating desktop GUIs and can create very easy Windows executables, also hate that PHP apps are so easy to deploy by just copy/paste, while Perl is worse in these fields. :-))
    That's life, Perl is not as fast as C, but it is faster than other dynamic langs, it doesn't use a VM like Java/C#, but Perl 6 will use one, Perl's syntax may be confusing if the programs are written without respecting best practices, but it allows a great flexibility which it is very useful sometimes. It has the best regular expressions engine, it is great for parsing strings, it has a very good Unicode support and some people say that it is the best for this, it is very good for working with data structures especially when the data is not absolutely clean, so there are important fields in which Perl is better than all other programming languages.

    ReplyDelete
  4. You know how you can tell when a language is dead? When people start writing articles claiming it isn't.

    ReplyDelete
  5. Very nice post .. I'm 37 ... Perl was my 10th language ..

    ReplyDelete