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

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?
  • Comment on Re^2: From PHP to Perl - Should I, and how?

Replies are listed 'Best First'.
Re^3: From PHP to Perl - Should I, and how?
by gwadej (Chaplain) on Mar 09, 2009 at 17:41 UTC

    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?

        There are probably many people here at the Monastery more qualified to argue the PHP vs. Perl thing. But, I guess I can give some advice on the rest.

        Given your situation, I would probably complete the current project in PHP. Next, I would try to do the same exercise in Perl on a separate site. Expect the second attempt to be harder in some ways (you are learning a language at the same time) and easier in others (you aren't trying to design a solution to a new problem).

        Depending on the kind of game you are writing, CPAN may be able to supply some tools that you can use. (I used Games::Maze to solve part of a problem for me a few years ago.)

        One downside of this approach is that your Perl program may be more PHPish than it should be. But you can correct your accent later as you gain more experience.

        G. Wade