Dynamic Languages: Perl, Ruby, Python
Perl, Ruby, Python — so many languages, so little time. Which should you learn or learn next? All are interpreted, not compiled, and all three are dynamic languages. With the exception of Perl (which is a true programming language, according to some) all are scripting languages that are easy to learn and use — far simpler, in the end, than C or C++.
Most important, perhaps, is the fact that all three are in demand, and they’re unlikely to fall out of favor in the near future.
Perl is the granddaddy here, the oldest, best-known and most widely used of the three. It was first released in 1987 by the now-famous Larry Wall, and it quickly caught on for its string processing power, among other features. Because it’s old and popular, Perl is well-documented. Indeed, the best-known book on Perl (“Programming Perl,” also called “The Camel Book” for the camel on its cover) was released in 1991. It’s still in use today.
And although you can find enough information on Ruby and Python to fill a warehouse twice over, Perl is still the most fully explained — in the last two decades, even its arcane nooks and crannies have been exposed to someone’s flashlight.
Perl is also the more powerful, and more complex, than Ruby or Python. Hence, it’s harder to learn and less readable. Because of its age, Perl projects can suffer from cruft, a problem if you’re the new kid on the block who’s been asked to wade into a project and alter someone else’s code.
Ruby: Diamond in the Rough?
Enter Ruby, released by Japan’s Yukihiro Matsumoto (“Matz” for short) in 1993. It’s much simpler to learn than Perl, even though it draws on Perl’s syntax in no small measure. (In fact, many Perl hackers learn Ruby because it’s similar.)
Similar, but not the same — Ruby is fairly easy to read, even if you’re not reading your own code. And the language follows the principle of least surprise (POLS), that is, it tends to work as you’d expect, with few curveballs.
Programmers also like Ruby for two more reasons. First, it’s strictly object-oriented. Yes, Perl and Python have objects, but Ruby adheres most closely to the object paradigm. Or, as a common refrain goes, “With Ruby, everything’s an object.”
The second reason Ruby is popular is Ruby on Rails, a Web application framework that makes building even complex Web systems fairly easy. Ruby on Rails sponsor 37Signals even bills it as “Web development that doesn’t hurt.”
Python: No Venom Here
If you like Ruby for its simplicity, you might fall in love with Python. It’s the simplest, most programmer-friendly of the three, and most programmers consider it the most readable too. That can be a big benefit if you’re working in teams and have to deal with other people’s code.
But with readability comes a price: Python can be verbose, and it runs more slowly than Ruby or Perl. Yet, it tends to run fast enough for the job at hand, and if you’re truly looking for speed, why use an interpreted language in the first place? Better to turn to Ferraris such as C or C++.
Where Ruby has Rails, Python has Django, a Web application framework designed to take the sting out of complex online applications. It’s nowhere near as popular as Rails, but some Python programmers swear by it.
If you’re still torn among Perl, Ruby, and Python, try this: Learn just enough of each language to produce a simple script or two. It’s not hard, and you’ll get a taste (if not the full flavor) of how each language works. After all, sometimes a taste is all it takes.
David Garrett is an IT consultant and former IT director who writes about the nexus of business and technology. He can be reached at editor (at) certmag (dot) com.