views:

2355

answers:

21

Hi,

I have used Perl for many years now, mostly for doing all kinds of file parsing and system scripting jobs. Several newer scripting languages (python, ruby) are now available, that all in part tend to address scripting etc. in a better way than Perl apparently did.

If I would have to choose learning a new scripting language, which one should that be and why?

+13  A: 

When I gave up on Perl, I switched to Python because of an article by Eric S. Raymond, and since Ruby wasn't nearly so mainstream as it is today. I think either are good choices, with Python having a greater array of libraries and Ruby being fully classful.

I should also add that Python has a RAD environment for web development that's similar to Ruby on Rails. It's called TurboGears and has a similar plugin architectue, so you can choose your ORM engine and templating format.

In other words, don't make your choice because of RoR ... make your choice based on the language, your compatibility with its syntax/structure and its suitability to the work you're doing. Also note that I'm trying to avoid sounding like a "Pythonista" (a Python language zealot), but may sound like one only because of my limited exposure to Ruby and if you look at my profile, you'll see I make my living with Java. If I were choosing a fourth-generation language now, would I choose Ruby ... I might. Please let us know what you decide.

Steve Moyer
What do you mean by "fully classful"? If you mean the ability to subclass basic types, Python has that too: http://pastebin.com/m47d49cf4
skymt
You should also check out Django as a web framework. http://www.djangoproject.com/
sethbc
Yes ... Dango is popular too, and for a Python based Application Server, there's Zope and the Plone, content aware CMS is built to sit on top of Zope.
Steve Moyer
There are plethora of web frameworks for Python http://wiki.python.org/moin/WebFrameworks
J.F. Sebastian
+27  A: 

Before I started learning Ruby, here's how I split up my usage for the languages I know:

  • PHP: Web applications, and only web applications. The good thing about PHP is that it has tons of built-in functionality, which makes it suitable for tiny to small applications. Also, most web applications are essentially data formatters, they read/write to/from a database, and that's about it.

  • Python: GUI applications, which tend to be more complicated. Python forces you to write clean code, which is annoying for quick hacks, but great if you're writing GUI code. Available libraries and toolkit integration are great (e.g. wxPython).

  • Perl: Everything that I would otherwise do in C, except for very low-level stuff, and even then, I can use Inline::C. Perl is great for quick text processing, which is a much broader application than it sounds. Everything from network daemons to mail filters can be written in Perl. And with CPAN, you'll barely have to write anything new.

I'd suggest learning Ruby over Python (or Ruby before Python) because it has concepts that can be useful for you as a programmer regardless of the language, and it's not whitespace-sensitive, so you won't feel weird coming from Perl.

At the end of the day, I believe there's no such thing as a better or worse scripting language. The best scripting language is the one you know well and gets the job done.

cubex
Ruby *is* whitespace sensitive: http://lucumr.pocoo.org/cogitations/2008/07/01/whitespace-sensitivity/
Armin Ronacher
Thanks for pointing this out. But the examples point out semantic whitespace sensitivity, as opposed to Python's syntactic.
cubex
"Python forces you to write clean code"? More so that Perl or Ruby? I don't agree.
JesperE
The whitespace thing felt weird to me for about five minutes, then it felt normal, now everything else feels weird!
John McCollum
I was a bit OCD about whitespace even back when I started out programming, so it was actually nice to be doing it for a reason for once!
Gary Chambers
+1  A: 

If it's for writing applications, I think Python or Ruby are a good choice. I still like the good old Tcl/tk even if I see it cited less and less nowadays.

If it's for embedding into a bigger application, I think nothing beats Lua. It's small, fast and very well supported.

Remo.D
+5  A: 

Python and Ruby aren't exactly new. Python was created in 1991 and Ruby in 1993. And just to round things out, the first paper on Tcl was given in 1990.

I think the choice of which language doesn't really matter. They are all fine languages and you'll take away something unique from each. Personally I recommend Tcl even though it wasn't on your short list, in part because it comes with fabulous bindings for Tk. Tk is the most common GUI toolkit in use among all scripting languages, and you can be up and writing GUI programs in a remarkably short amount of time. Learn Tk with Tcl and you can later transfer what you've learned to Python or Ruby or Perl.

Python is also a fine choice for its greater reliance on OO (though you can certainly do OO in Tcl, too). One definitely advantage Python has over Tcl is that it comes with a huge amount of built-in functionality. The standard library makes it easy to do a lot of stuff right out of the box. You can get a batteries-included version of Tcl from ActiveState, though I think Python still wins in that regard.

Roby, particularly if you're interested in jumping on the rails bandwagon, is also a good choice. I'm not as well versed in it so I'll just say it's not a bad choice to learn.

There are plenty of other dynamic languages to choose from but those are the big three outside of Perl, IMO. They all are interesting, unusual, and equally powerful in their own ways. You can't go wrong no matter which one you choose. Choosing any of them will definitely help you to become a better programmer.

Bryan Oakley
A: 

Python becomes more and more popular. Just look at Google Application Engine.

maxp
I think that may not be the most accurate measure of popularity. Especially since the creator of Python works for google.
J.J.
And since Perl is currently being ported to the Google App Engine as well, and Larry doesn't work for Google.
pjf
+13  A: 

I think it depends on whether Perl drives you crazy.

If you love all the nutty rules and weird special cases and implicit variables, then Ruby will probably make you happy. It's not as insane as Perl, but it generally follows the same "more than one way to do it" philosophy.

If you think Perl is insane and Larry Wall is the Jackson Pollack of software, then Python will probably suit you nicely.

benjismith
+1  A: 

Learning any scripting language is useful. But if you have a Java background, I'd suggest Groovy. Groovy runs on the JVM, being basically a layer on top of Java, so if you know Java you already know 90% of Groovy so there's almost no learning curve. And you'll have the entire Java library API, and all of your already-existing Java classes at your disposal to use. Plus the benefits of a dynamically-typed, powerful, modern programming language.

That said, if you do not have a Java background, then Groovy probably doesn't particularly stand out over any other scripting language.

seansand
+1  A: 

Python, I have found it useful for working with XML and it is the scripting language for Paint Shop Pro.

If you are a windows environment you should also learn PowerShell, because it is Microsoft's future direction for the command line. It's very powerful and it will only be getting better. It's pipeline contains objects and not plain text.

bruceatk
It looks like a python hater has come through this old question and marked Python suggestions down. I wish people would have to comment on why they mark something down.
bruceatk
+5  A: 

I'd suggest lua.

It has a clear stack-based C interface and some simple, yet interesting threading concepts.

Unlike in python, you can embed multiple instances of the interpreter within a single C program. Also, you don't have to explicitly count references all along the way. Good fun, easy to learn and use.

+27  A: 

Perl 6?

Seriously, though, I read your question as saying that your main reason for wanting to switch is because you believe that other languages "address scripting etc. in a better way than Perl apparently did." This suggests to me that you don't really know what problems "apparently" exist in Perl and you're just trying to follow the current fashion in programming languages.

If my impressions are correct, then I'd say you should just look at the trends and use that to decide which one you want to follow. They're all very capable and why choose a new language for technical reasons if your reason for distancing yourself from the old one is non-technical?

If I'm wrong, then you may want to ask a new question which specifies the areas that you see as deficient in Perl, because that's what will determine what will be your best option. And it may simply be to get to know Perl better - if you've just been using it for "file parsing and system scripting", then there are likely vast areas of the language that you're not familiar with.

Dave Sherohman
+20  A: 

Why do you want to learn another language?

If you're looking for a different job, find out what sorts of jobs are in the geographical area you want to work, if there's a cool local user group, and so on. Find out what sort of lifestyle you want and if you can have that with language you choose (i.e. do you want to telecommute, live in a certain area, work 9-to-5, work on big iron, and so on).

What sort of programming do you want to do? Web apps? Command-line tools? Slick GUIs that run on the local machine? Different languages will be better-suited to different tasks. That's mostly not related to the language itself but the cool tools other people have built around the language.

If you just want to learn another language, consider branching out to something completely foreign, such as Smalltalk or Erlang. Instead of learning Python or Ruby, try something in a different part of the programming language evolutionary tree. Also, try a language that's not in your current field of work just to sample what life is like elsewhere. You might not always have the sort of job that you do, so a little breadth in the CV isn't so bad.

Play with the new language for a week. See how hard it is to find help online (and not just here :) and to use the documentation. Find out what sort of libraries and tools it has already, and find out what the community is like and if you like those sorts of people. :)

And, if you choose something you end up not liking, just choose something else. It was a learning experience and now you know something about that new language even if you don't use it. If you keep going in your programming career, you're going to do this over and over again, so you're not making a life commitment to anything.

Good luck,

brian d foy
+1  A: 

I'd suggest you take on a small project and implement it in both languages. Something practical: hit an API, grab the data in XML, do something with it, store it in a DB etc...

some sort of project that will hit a few points you're likely to encounter but nothing that's huge and takes weeks.

It's like test driving a car. Give 'em both a whirl on a "road" you know (something you already use Perl for) and see which suits you better.

Also - I'm a fan of getting my feet wet with new-to-me languages. It can't hurt. Lots of problems out there are easier or harder to solve depending on the language.

arin sarkissian
+4  A: 

I found an article comparing python and ruby.

andreas buykx
Fantastic article.
postfuturist
+1  A: 

I did much the same thing. I grew annoyed at Perl's oddities with data handling, and "more than one way" concept.. though perl was certainly useful. I started looking into Ruby and Python, reading a lot of articles and finally started with Python. I eventually started playing with Ruby as well, out of curiosity. My impression is that perl was good at the time, but has long since been needing a replacement. Python and Ruby both feel like much more complete and professional tools. They both seem very well laid out, and capable of the most demanding tasks. I find that I would rather write in them than anything else (C, C++, Perl, sh scripts, matlab scripts, etc.). The only downside is that as interpreted languages they do take a penalty in performance compared to a compiled sort, but honestly.. in most cases that is not a problem.

Between the two, I'd say its not really cut and dry. Python seems more conservative in some ways, with a larger library selection, and close attention to the one best way to do things. Ruby seems trendy, but has some very good concepts behind it, and the idea that everything is an object is great. It is annoying that Ruby does have several methods to accomplish the same thing, which Perl has taught me to fear, but it doesn't seem quite so infected with it. Performance-wise.. Python still does win, at least in all the cases I've put it to the test.. how much depends on the type of operation. But again, if performance is a concern, you should be looking at C/C++ or something.

I know there are some slightly more obscure things I've thought of looking at (Lua, Ocaml, haskell), but Python/Ruby is becoming popular enough that corporations will coax IT into supporting. Python and Ruby are both available at my work. I would pick Ruby or Python first, and perhaps after you're comfortable with that move to something less mainstream.

In either case highly recommend a book.. "Programming Python" or "The Ruby Programming Language".

MattG
+13  A: 

I'd suggest, and you can have a go at me for sounding glib here, Perl.

Obviously I don't know exactly how far your knowledge of Perl runs, but if you (or anyone else) are still writing 'Perl 4' in Perl 5.8, or even 'traditional' Perl 5 OO, I would suggest that you owe it to yourself to acquaint yourself with, at the very least, Moose for OO, some of the recent changes in Perl 5.10, a bunch of the more recent 'new wave' of Perl CPAN modules, and the like.

Penfold
A: 

C++, along with STL and boost.

I've twice won bet, and writing a program in C++ faster than perl.

There is a need of a killer C++sh ( there have been a few attempts ).

Vardhan Varma
+10  A: 

One suggestion would be to re-learn Perl!

Have a try at new programming techniques rather than just new programming language (eg. OOP & Functional programming).

I'd recommend the following Perl books / sites....

  • Perl Best Practices by Damian Conway
  • Higher Order Perl by Mark Jason Dominus
  • Object Oriented Perl by Damian Conway
  • Moose

/I3az/

draegtun
Those books are excellent recommendations also the perl testing notebook is good. As well as looking at Moose. Also Catalyst (and maybe Jifty for more turnkey stuff) for web programing, and DBIx::Class for database stuff.
singingfish
+1  A: 

I'd second the suggestion of Lua. but mostly because that's what I'm currently learning. I used to think I was using Perl less, but thinking back on it, I'm learning less in Perl. My most interesting development in the last 5+ years has been in Perl (with a little C, ksh and PL/SQL thrown in), so it has become second nature at this point. I've dabbled in Haskell, Common Lisp, Python, and PostScript, each of which is different than my core languages. But they have been hard to get stuff done in for various reasons.

I was attracted to Lua because it's faster and cleaner than Perl, is designed to be embedded in C, and has some interesting meta-features that I'd like more exposure to. I've found it relatively easy to get things done in Lua so far.

Reading the other suggestions here, it's time I spent more time with some of the newer Perl modules on CPAN. And I hope to be pleasantly surprised by Perl 6 one of these days.

Jon Ericson
+3  A: 

I'd $n++ the recommendation to re-learn perl. Perl 5.10 is a solid language backed up by a large collection of libraries in CPAN. You can create UIs in Tk, wxWidgets, Qt, Curses and Gtk, amongst others, do event-driven programming, manipulate all sorts of databases, and much, much more. If you're used to the C-ish (and Perl, Java, JavaScript, amongst others) way of doing things (blocks between braces, semicolons at the end of statements) then Python's syntax will be jarring and unintuitive. Ruby reads like Perl, if Perl were designed for buzzword compliance and is really only popular because of the bags of undeserved hype surrounding RoR.

james2vegas
+1  A: 

I'm sort of amazed nobody has suggest you learn Javascript!

Scott Evernden
+2  A: 

What are your goals?

Are you looking for mind-expansion, employability or utility?

Utility

For simple utility, sharpen your Perl skills. You've got a solid base with Perl, build on it. Why start over, you'll get more done in less time if you expand your Perl skills.

Mind Expansion

For mind expansion learn Haskel, LISP, Lua, or anything else that is very different than what you are used to.

Employability

For employability, you'll have to look at various job boards and see who's hiring and for what languages. That will change with time.

Python, Perl and Ruby have all had their 5 minutes of fame. Jobs can be had hacking any of them. What's available in your area may vary.

If you really want to hit it big, figure out what fad language will be used for Web 3.0 in a few years time. Learn it now, so you will be one of the few with 3 years experience in HOTLANGUAGEOFTHEDAY. You'll be able to demand a huge salary while you go chop those venture capital dollars.

daotoad