Thursday, January 29, 2015

Shock and Terror - Perl IS a readable language


As a fresh developer, one of the first things you'll hear about Perl is one of the following:
  1. Perl is unreadable
  2. Perl is the only language that looks the same before and after is encrypted with sha256
  3. Larry Wall fell asleep with his head on his keyboard and when he woke up he called the result Perl
You won't hear that Perl is the language that was behind almost every Web page until 2000s, practically powering the whole www, or that you can use Perl to build anything and elegantly implement all of your business requirements, or that Perl is the only real programming language that is delivered with every Linux distribution. No, I'm sure that if you started programming in the last 5 years, the very first thing you heard about Perl is one of the above bullshit jokes. And, if you happen to challenge their affirmation, they'll pull out some snippets that won a Perl golf code competition to "prove" it to you, proudly enforcing their statement with: "that is a perfectly valid  piece of Perl code". The truth is that no, the output of a golf code competition is not a valid piece of code. Not for the business critical applications that we generally use Perl for. Believing someone who never opened a Perl manual and says that Perl is unreadable, is like believing a 3 years old when she tells you that English is unreadable. Come on, you gotta be smarter than that.Show me a programming language that you can understand without reading some parts of its documentation and I'll give you the winning numbers at the lottery.I'm sure you can read and understand any programming language after you put enough effort and exercise into learning it - yes, even brainfuck

Programming Languages are Like Spoken Ones

There are around 1 billion people who understand Chinese and 200 million people who understand Arabic after all. And there are literally billions of people on earth who can't understand a single letter from the Latin alphabet. Do you believe that those billions of people who can't read English are wrong? or the ones who only speak Chinese, Japanese, Arabic, Russian, or Hebrew are using a less than best language because you can't understand them?  Now, do you really think that Perl is unreadable? Compared to what? To a language you used for years before trying to do something with Perl? Who sets the programming language readability standards? You see my friend, There Is More Than One Way To Do It and if someone tells you something else, send them to this post.
Just because some respected developer in an unrelated technology can't figure out what each sigil means in Perl, it doesn't mean that the language is unreadable. It means that the developer is a superficial cunt individual, who can't figure the difference between a joke and reality.

Programming Languages are Like Civilizations

We can consider Perl to be like the modern world, where everybody is allowed to do anything they want as long as they don't disturb or harm other people (this is unfortunately untrue at a world scale, but I live in Europe and here this is pretty much the case). Perl evolved nicely from a time similar to Egyptians where we used rudimentary tools and were able to  build great things - the internet, just like the Egyptians built the pyramids, to the present day, where we have DBIx::Class, and Mojolicious, and Catalyst, and Dancer, and Plack and we build beautiful skyscrapers with hundreds of floors.
We can see that other languages are still in the dark middle ages, where they burn witches when they say that not everybody likes to have their indentation enforced on their code the Earth is not flat, or even that it revolves around the Sun instead of the reversal.

The future is now

Right now I'm in Brussels, waiting for +FOSDEM 2015 to begin (thanks Evozon for sponsoring my presence here). If you're also around, do your best to attend Larry Wall's keynote speaking on Sunday, because I've heard he has really important news to share regarding Perl6. You might actually not have that much time to try Perl6 (which I hope will be named Camelia) before it is declared production ready and becomes mainstream.
If he made it that big with the original Perl, imagine what kind of a language will come out after his more than 25 years of experience, out of which, 14 were spent on designing a new language.

I can't wait to see the power of Perl6 explained by +Curtis Poe (who's one of my favorite presenters) on Saturday - have a sneak peak at his slides hereIf you liked this article, don't forget to share it on your favorite social network.

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?