I've been using Perl for over ten years now. It has been around since the 1980s and has won a place in the trusted scripting languages category for thousands of Web Developers, Programmers, and System Administrators. You'll find Perl comes pre-installed with most every Unix and GNU/Linux distribution. Perl does do so many things that distinguish it from any other Dynamic Scripting Language written that it has earned the distinction of being 'the duct tape of the Internet'. When you become more acquainted with the language and its capabilities, that description becomes quite appropriate.To the credit of Larry Wall, the Author of Perl, Perl has become so popular that a culture has formed around its legendary 'open source' roots which resulted in creation of a repository known as the Comprehensive Perl Archive Network, or CPAN for short.
CPAN has existed since 1995, and has, to date, over 6848 authors and 14283 high-quality modules that are freely downloadable (and directly usable in Catalyst) and licensed under the terms of the GNU General Public License (GPL) .
Perl is a
If you have used another language such as 'C' or Pascal, you can get up to speed on the basics quickly. There are many Perl learning resources, including on-line tutorials, downloadable eBooks, and books. My recommendation, if you buy books, is to start with some of the outstanding O'Reilly Publishers book selections. Here are a few recommended titles:Learning Perl is excellent for beginners and provides a good basic foundation of concepts. The others give a more in-depth look at all of the rich and varied features of Perl.
If you make the time investment (a few hours), you will be pleased to discover just how easy Perl is to learn. Some of the syntax may seem terse or arcane at first, e.g., regular expressions, but the above-listed books are well-written and do a good job of explaining everything you need to know.
This is all to preface the topic of this article Catalyst: Perl's answer to Ruby on Rails and AJAX. Anyone doing full-time web development understands that the process is often repetitive and can easily grow into hundreds of coordinating web html, cascading style sheets, xml, javascript, template files. Potentially, maintenance of these files can progressively become difficult if not problematic as scale and design complexity grow. Making a design change can require making a change across several or more files. Missing a change in one file can result in bringing down the web application.
Model-View-Controller (MVC), attempts to manage these complexities and partitions away in a modular fashion the data and business rules (Model) from the user graphical interface (View) and actions taken by the user (Controller). Web applications employing MVC, or Frameworks, are implemented using web template systems. The list of Frameworks in use has grown over time and some have become more popular than others, one being Ruby on Rails.
There's been a lot of press recently focused on Ruby on Rails as it has been used to develop the popular website Twitter. Rumors about its inability to scale well have taken on a life of their own spurred by frequent reports of Twitter outages. I am inclined to believe that those rumors are not justified. It is probably more likely that there is a 'learning curve' in setting up distributed web server clusters that is unique for any implementation. It's just that Rails has been put to the test on a large scale deployment most recently and is a relatively new untested Framework.So, does Ruby on Rails being so popular imply it is better than say PHP with Joomla or Java with Spring or Perl with Catalyst? Not really. The successful implementation of any MVC depends on multiple factors, including the skill set and experience level of each individual tasked to contribute to the development of the web application--the programmer, web designer, database administrator, system administrator, system engineer, network engineer, all provide their own areas of expertise.
The following comparisons between Perl/Catalyst and Ruby/RoR are taken from WikiVS Catalyst vs Ruby on Rails:
====================================================================
Ruby Language Comparison
Some features which differ notably from languages such as C or Perl:
- Names which begin with a capital letter are treated as constants, so local variables should begin with a lowercase letter.
- The sigils
$and@do not indicate variable data type as in Perl, but rather function as scope resolution operators.- To denote floating point numbers, one must follow with a zero digit (
99.0) or an explicit conversion (99.to_f). It is insufficient to append a dot (99.), because numbers are susceptible to method syntax.- Boolean evaluation of non-boolean data is strict: 0,
""and[]are all evaluated to true. In C, the expression0 ? 1 : 0evaluates to 0 (i.e. false). In Ruby, however, it yields 1, as all numbers evaluate to true; onlynilandfalseevaluate to false. A corollaryregular-expressionnilon failure (e.g., mismatch). This convention is also used in Smalltalk, where only the special objectstrueandfalsecan be used in a boolean expression. to this rule is that Ruby methods by convention -- for example, searches -- return numbers, strings, lists, or other non-false values on success, but- Versions prior to 1.9 lack a character data type (compare to C, which provides type
charfor characters). This may cause surprises when slicing strings:"abc"[0]ASCII code of the first character in the string); to obtain"a"use"abc"[0,1](a substring of length 1) or"abc"[0].chr. yields 97 (an integer, representing the- The notation
statement until expression, unlike other languages' equivalent statements (e.g.do { statement } while (not(expression));in C/C++/...), actually never runs the statement if the expression is already true. This is becausestatement until expressionis actually syntactic sugar overuntil expression; statement; end, the equivalent of which in C/C++ iswhile (not(expression)) statement;just likestatement if expressionis an equivalent toif expression; statement; end. However, the notationbegin statement end until expressionin Ruby will in fact run the expression once even in if the expression is already true.- Because constants are references to objects, changing what a constant refers to generates a warning, but modifying the object itself does not. For example,
Greeting << " world!" if Greeting == "Hello"does not generate an error or warning. This is similar to final variables in Java, but Ruby does also have the functionality to "freeze" an object, unlike Java.Some features which differ notably from other languages:
Ruby (< 2.0) lacks full support for Unicode, though it has partial support for UTF-8.
- The usual operators for conditional expressions,
andandor, do not follow the normal rules of precedence:anddoes not bind tighter thanor. Ruby also has expression operators||and&&which work as expected.Popularity
Ruby on Rails sites directory Sites powered by Catalyst
Documentation
The Catalyst documentation is currently undergoing reorganization at http://catalystframework.org/, which is going to be powered by the Catalst-based wiki solution mojomojo. However, the most up-to-date Catalyst's documentation still resides on CPAN. At the moment, there is one book on Catalyst, which received mixed reviews [1].
RoR's documentation is organized in one place (http://www.rubyonrails.org/docs) and there are numerous books on Rails[2].
Performance
All of us working on Twitter are big Ruby fans, but I think it's worth being frank that this isn't one of those relativistic language issues. Ruby is slow.
General capability
Perl is said to make easy things easy and difficult things possible.
RoR makes easy things very easy and complex things very difficult:
Rails has a very strange learning curve. To get up a very simple website with a simple DB store, the language is great; you can get things up and running in no time, even if you're a newbie (...)
However, once you get past all the stuff Rails was designed to help you do, making it do interesting new things requires a TON of learning. All the "magic" it does, while great if you're doing things it was designed for, becomes a TOTAL headache when you're doing stuff it wasn't designed for, because all of a sudden you have to "understand the magic" in order to figure out why things aren't doing what you'd expect, and the reference documentation sucks -- several times, I've had to simply go dive into the library source code to try to figure out just what's going on, and even then, the "magic" makes it nearly impossible to easily figure out.
Application development speed
Rails is famous for its very rapid development of simple applications (Creating a weblog in 15 minutes).
Catalyst currently lacks a good set of screencast demonstrating its features. Two such resources are http://dev.catalyst.perl.org/wiki/Movies and Catalyst with FormBuilder screencast.
Features
Database
Catalyst supports a huge number of physical and virtual database backends, and different ORMs. RoR's favored ORM is ActiveRecord.
Perl/Catalyst has DBI, DBIx::Class, and Tangram which supports a large number of database backends (100+). Catalyst allows each model to be from different databases (even database sources). Some useful virtual databases exist (Amazon, Google, Excel documents, CSV files, etc.). DBIx::Class is the most popular ORM and supports features such as multi-column primary keys and character-based primary keys.
Rails supports the primary 6 database backends, although MySQL seems to be the best supported. Test and development "environments" can easily and automatically use different databases, however. Developers are not forced to use Rails' database layer, and some choose to use other Ruby based solutions. ActiveRecord is the most popular ORM for Rails. It has some design limitations in that it does not natively support multi-column primary keys.
The lack of support for multi-column primary keys is important, because many-to-many relationships require a junction table, whose primary key is made up of 2 columns referencing the two tables it links. Junction tables are required in most aspects of web application design: tagging items (an item may have many tags, and a given tag may belong to many items), representing user access roles etc.
Unicode / Internationalization
Since Ruby doesn't have any specific facilities for managing Unicode strings[5], Rails' support for Unicode is not yet mature.
Perl supports Unicode natively and so does Catalyst. [6]
Debugging
Catalyst can be debugged remotely with ActiveState Komodo IDE, or locally with the built-in perl debugger[7]. Every Catalyst application is generated along with a test script. Catalyst has built-in logging and can be integrated with Log4Perl[8].
Testing
Catalyst allows for easy decoupling of the model from the web application, which permits separate testing of the database backend without going through the web application. RoR fills the controllers up with logic.
====================================================================
Visit the Catalyst project homepage to learn more about this exciting Framework for Perl.Also, if you have a serious interest in Catalyst development, please consider purchasing Jonathan Rockway's new Catalyst book, published by Packt Publishing, now available for purchase. Get it now!

Leave a comment