I have a number of scripts written in Perl for code-generation and other build tasks. Over time, however, I have been put off by my inability to read quickly Perl code that I have written six months before.
Perl is the most popular and also the fastest scripting language, but the syntax is horrendous. It is concise for simple procedural scripts, but it gets in the way for object-orientation and large scale programming tasks.
I am currently evaluating both Ruby and Python as replacements, and it is not clear to me which is better for my needs. In either case, both seem to provide more maintainability and readability than Perl. They provide explicit and clean support for class, modules, function parameters, exception handling and iterators. Also, variables only contain references not values, which greatly simplifies these two languages compared to Perl. In Perl, there was a different construction operator for an array (), an array reference [], a hash reference {}. In addition, Perl had a C-like dereference operators $$var, @$var, $var->{}, $var->[]; conversion from a value or reference to its reference required a preceding backslash just like C's ampersand. Working with advanced data structures became painful.
I have looked through a number of posts such as this one.
Python has been around for ten years and appears to be used in broader range of applications than Perl. I recently noticed a book on Game Programming with Python at Barnes and Nobles.
Ruby seems to be the most object-oriented and most expressive language, but, being new, it has less documentation, less third-party support and fewer available libraries. Ruby actually borrows more from Perl than Python does, so adopting Ruby may provide for an easier transition.
I'll most likely chose Python.
Sorry, but Perl reads like geek code. The point of modern languages is to be human-readable and maintainable. This is my impression of Perl which I use all the time, much to my chagrin, as opposed to well-written C++:
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED/J d-- s:++>: a-- C++(++++) ULU++ P+ L++ E---- W+(-) N+++ o+ K+++ w---
O- M+ V-- PS++>$ PE++>$ Y++ PGP++ t- 5+++ X++ R+++>$ tv+ b+ DI+++ D+++
G+++++ e++ h r-- y++**
------END GEEK CODE BLOCK------
Posted by: Xofis | May 20, 2004 at 02:50 PM
You're right, Ruby borrows more from Perl, and might be an easier transition for you, but Python has the best readability and the largest number of 3rd party libraries and interfaces.
I currently use and like Python, but sometimes when trying to design frameworks for others to use, I wish it had some of the power and flexibility that Ruby has, instead of having to mess around with metaclasses. But that doesn't sound like the kind of stuff you will be using it for.
Posted by: | May 20, 2004 at 03:40 PM
What about scripting facilities of .NET? Do they (JScript.net or vb.net) not provide enough functionality? What about dynamic code (dynamic assemblies)? Is it not good enough for you needs?
Posted by: Ornus | May 20, 2004 at 04:44 PM
well python has been around for more than ten years, and ruby just hit ten recently :)
I'd say: take a little script, translate it to both and check what feels the best, like michael tsai did. And check for trackbacks :)
Posted by: gab | May 21, 2004 at 04:43 AM
forgot to say: "code generation in action", a nice book from manning makes large use of ruby, it may be of interest to you.
Posted by: gab | May 21, 2004 at 04:55 AM
I have been lurking on both languages for a while. I like Ruby's syntax better, but think Python has better Windows support.
Posted by: Thomas Eyde | May 23, 2004 at 01:28 AM
You might want to check out Groovy here:
http://www.codehaus.org
Let us know what you think....
Regards,
Oswald
Posted by: | May 28, 2004 at 04:42 PM
Groovy looks interesting, but it seems to tied with Java. My interests are with the .NET platform. Also, I don't require or necessarily favor that the syntax match closely with C# or Java.
C# and Java are too verbose for a scripting language. Both Ruby and Perl already adopt the expression syntax of the C-based languages; that alone is enough similarity for me. It would be nice to have direct access to .NET, but I think there will be eventual ports to that platform. For now, I can still use the COM support available in all 3 languages and .NET interoperability to my .NET libraries.
Posted by: Wesner Moise | May 28, 2004 at 06:00 PM