in reply to From PHP to Perl - Should I, and how?

While several of the other monks have answered your explicit questions. There's one potentially bad idea lurking in your original post.

Is it worth it to drop everything, take time to learn Perl, port that code over, and continue writing in Perl?

Is there any reason why you would need to? If code is working in PHP and you don't have an explicit need to change it, why change?

When learning a new language, it is often better to start off writing small pieces of code or tools than porting some critical (or even just working) code to the new language. Instead of a rewrite,

Often learning a new language will force you to think about your primary language (and programming) differently. Once you get comfortable with the new language, you may see places where you could do a better job in the new language than in the old one. That is the time to consider building more production code in the new language.

Several times in my career, I've seen someone come to the conclusion that a system should be re-written in a new language to improve the system. I can't think of a single time I've seen that go as planned. Often the new system turns out worse, because the programmers don't know the new language as well as they did the old one. Sometimes this ends up souring them on the new language forever.

IMNSHO, you should definitely learn Perl. If possible, you should also make use of Perl where it fits with your other goals. You should probably not rewrite a significant chunk of functionality unless you have a really good reason.

G. Wade
  • Comment on Re: From PHP to Perl - Should I, and how?

Replies are listed 'Best First'.
Re^2: From PHP to Perl - Should I, and how?
by salazar (Scribe) on Mar 09, 2009 at 17:23 UTC
    Thanks. Right now, the bulk of what I have done is in the form of a script which maintains state, and some good ideas for what I want the site to be like.

    That's really why I was considering rewriting it, because if I'm going to be doing any web work with Perl, I'm going to want to have some scripts set up to authenticate the user nicely, load his information from the database, log his online presence, etc.

    Would you suggest, then, that I continue with the site I am building in PHP, and play with Perl on the side -- then, when the time comes, port it over if I see a significant reason?

      There are CPAN modules to do some of what you are talking about: CGI::Session, CGI::Session::Auth, CGI::Auth::Basic, Apache::Session (I haven't used any of these, so don't take this as a recommendation for a particular module.)

      If a couple of CPAN modules replace much of what you want to do, it might be worth changing. In general, though there should be some functionality that is unique to your site. That is what's risky to convert.

      It also depends, of course, on the site. If this is a personal project and no one but you is depending on it. Your risk is lower and you might want to experiment. If your job is riding on the site or lots of people are depending on it, I would take the lower-risk approach I mentioned.

      Like any other part of programming, these kinds of decisions are not black and white. They involve trade offs. If I had to decide between PHP and Perl for a new site, I'd pick Perl because I know it better. If I had to take an existing site in PHP and either fix it or re-write it in Perl, I'd bite my tongue and work in PHP (probably learning more PHP in the process), because that is the lower risk path.

      The main point of my previous post was that you don't have to rewrite everything to get some of the benefits of using another language. More exposure to different types of programming and different languages usually improves your programming in all languages and projects you work on.

      I have actually gained a lot of benefit from Perl in jobs where we were required to work in other languages. I have used Perl for testing, data generation, code generators, and a host of little tools to make my development go faster.

      G. Wade
        Ok. I understand that at some point these judgments will have to be my own, but I figured I'd ask you for some advice right now ;).

        Cause I'm a little kid (heh at heart at least), a lot of what I do is focused around games. My friend has asked me to make a game for his site, which I'm thinking would take 8 hours of PHP coding, with a PHP login / logout system already in place. I'm guessing this is something I should use PHP for, right? Especially because I don't know really any Perl?

        On the other hand, I'm hoping to get a big game site going, with lots of cool features and all that fun stuff. I have nothing done except for a web design and some PHP for handling the things I've described above. At this point, would it be worth switching to Perl? Which begs the question, where does PHP hit that wall which makes Perl so much better, and how likely am I to hit it?
Re^2: From PHP to Perl - Should I, and how?
by locked_user sundialsvc4 (Abbot) on Mar 10, 2009 at 16:39 UTC

    Heh... the experience of learning a new language also transforms your future work in the languages that you already know! It's how you grow in this business... and there's no replacing it.

    And the “gurus” who are out there producing “PHP itself” ... do they know? You bet they do! That's the beauty of (and the endless allure of...) this business as a career:   you always feel that you are lucky to be getting paid for doing this. And yet, the digital computer is always your master; never truly your slave.

    You now recognize the need to add another powerful tool to your personal tool-belt. Does that, therefore, provide an adequate (business|financial|technical|career) justification to scrap what you have already done? Ditto the expertise you have already acquired? N-O-!!

    Never forget the “FISI principle”:   F**k It, Ship It!   :-D

    At the end of the (business...) day, “what is done is done, and by the way, it's paying the freight.” What you do in the future is an entirely separate decision.