in dynamic languages, Perl, programming

perl is dead, long live…perl?

When I started writing this article it was going to be about the choice of language people use when they create a quick dirty script for say a one off task. For this type of thing I tend to find myself using Perl and since I thought Perl was maybe a little old in the tooth, I wondered what the “cool kids” were using these days. However, this got me thinking more about the benefits of such scripts both to the programmer and their employer.

Often I find myself needing to process/generate a file in some way. To do this kind of task I feel that Java, C#, C++ etc are just waaaay too heavyweight for the task – my default reaction is that you need an interpreted language. For me this is Perl. I know PHP pretty well but it just never enters my head to use it for a command-line task, Python I kind of know but not very well, and Ruby again I just don’t know well enough, but would probably only consider this an option for a web app like PHP – no reason why I only see Ruby and PHP as web app not command-line options. So what do people use for this kind of stuff? I’m interested.

Anyway, this line of thought led me to the following observation: writing small scripts to do simple file manipulation/generation and system tasks makes you a better programmer. Even if the task you are trying to complete seems small and probably a one off, I say “write a script”. Why?

First, this may give you the opportunity to stray away from the heavyweights like Java that I mentioned above, and learn something new (the more you know the better programmer you are. Right?). Your boss may not like the idea, but the thing you are doing is work related so you can tell him it will save time, which I promise you in the long run it will. Even if you find you run the script only once you will find the learning process will have stood you in good stead.

Second, it’s an ideal way to break the monotony of your everyday work cycle. You may have been working on a particular project for months and, as happens, you are beginning to hate the thought of even looking at the code never mind write more of it. So, if you think of a script that will help you in some way in your day to day work, and will benefit both you and the company, then write it. Not only does it break the monotony but when you finish it there is also a sense of achievement that you feel by actually completing something. This sense of purpose is then reflected back into the main project; I mean you want that sense of achievement again. Right? So everyone wins.

Third, well surely the above two are more than enough reason to do it. If not tell me some more πŸ™‚ . You can always turn the little script writing into a competition within your work, i.e. who can come up with the best/most useful script! Don’t worry about finding these types of scripts to write – I generally think of a couple everyday. Just look around you and you will be amazed at what you will find.

Over and out.

Write a Comment

Comment

 

  1. I think the cool Java developers are meant to be using groovy. I can’t comment on it as I’ve never used it but I may spend some of my afternoon having a look at it πŸ™‚

  2. So I know nothing about Groovy. Is it complied or interpreted? I need it to be interpreted for it to meet my criteria for usage πŸ™‚

  3. Groovy’s pretty neat. It’s interpreted, or you can compile it to .class files.

    JRuby is another one to consider, if you want to stay with the jvm. Ruby syntax, java runtime.

    Personally, I use (j)ruby for quickie scripts these days. I’m an old perl-head and still “think” in perl a lot (perl 4 and 5, anyway; that v6 stuff is just beyond the pale, but I’ll look in another 5 years when it’s finally released).

  4. Mmmm Groovy might just be worth a look then.

    That said I have a funny feeling that I will just convert everything in my head into Perl – for example, when I have to do a regular expression in say Java, I normally first create it either literally or metaphorically in Perl then import it into Java. Though it does beg the question if I can achieve all my small script needs in Perl then why change – I suppose though it’s the old programmers adage, “something new is something interesting”?

  5. I think your general line of thought is correct. Now the question is only which language do people choose.

    I am a heavy Ruby user myself and I give the python users a general thumbs up for several reason, but I talked to a perl developer who did not care about perl 6(!) and instead said he was only interested in perl 5. Which surprised me, because I thought people dont really care about perl < 6 these days.

    It kinda opened my eyes, because this means that EVERY language that has gained a big follower base will continue to keep a language alive and actually evolve it. Now personally I have no illusion how much perl 5 can evolve (for me I have given up on perl 6 years ago, and on php 3-4 years ago already) but it seems that different people continue to have different opinions.

    Programming languages are immortal. At least as long as old farts continue to use them πŸ™‚

  6. Groovy is simply excellent for scripts and applications.

    It is always compiled (as Groovy itself runs on the JVM).

    You can however use it transparently as “groovy myscript.groovy” and the process will be automatic.
    It includes an interactive shell out of the box.

  7. Thanks for the input folks. It has certainly got me thinking. As I said I’m always keen to learn something new, and contrary to a certain comments on reddit, the reason I posted this was that I’m looking to find an alternative to Perl.

    At the moment in my job I’m doing a fair amount of Java so Groovy, it appears, may be a good option to go for.

    I notice that Ruby does seem to be getting a thumbs up as well and a few years back I made a big point of learning Ruby but have since forgotten most of it – to be honest I think I forgot it deliberately as I experienced some really bad hosting problems with a website that was developed and this damaged the allure of Ruby for me, despite it not being the fault of Ruby. I don’t know, maybe I should dust off my Ruby cap…

  8. > Ruby again I just don’t know well enough, but would probably only consider this an option for a web app like PHP.

    The fact that ruby became popular because it serves as the basis for Rails should not be taken to mean that it’s original purpose wasn’t to be used in all the places that Perl is used. In fact, while I love Perl, if I have to interact with other command line apps and read their output it’s generally much easier to do so with Ruby. So, for quicky command line scripts I’ll generally use Ruby. But for more complex scripting lang apps, I’ll still use Perl because I like it better and because it’s better known at my co.

  9. For such tasks, I generally write a Unix shell script (preferrably bash), but that’s probably only because I don’t know any better.

Webmentions

  • sticking with what you know | Equivalence December 23, 2008

    […] First, we cover the forced abandonment. This is when you are pushed kicking and screaming into pastures new, whether you like it or not, i.e. the new job. Here, not only is the new language curve ball thrown (viciously), but you also get whole new set of business rules into the bargain. So what do you do? You program the new language like the old one, only translating the syntax in your head. This is not the best way to learn a language though. Why? Well consider those C programmers trying to program imperatively in Java, Java programmers in JavaScript, C++ programmers in Ruby, and so on. When there is a change in paradigm this mapping strategy just doesn’t work – a similar situation exists with languages that contain a more powerful expression set. It also encourages the behaviour where people learning enough to get the job done, without understanding what is really happening, or that there may have been a better way using “unmappable” language’s features. A better approach would be to write something small, and new, that allows you to explore the language’s features. I’m sure most people can think of something they could write. Furthermore, if you can make it useful to other people, or even your new employer, then everyone’s a winner! This is something I touched on before. […]

  • Equivalence » Blog Archive » bad software engineering - made easy December 23, 2008

    […] perl is dead, long live…perl? […]