Discussion Locked

perl development question (general)

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi all,

I've just taken over a (very new) small website and I'd like to add perl to my programming skills.

Since I've never worked cross-platform before (I'm more of a hardware person), I'd like to know if I can develop source on a Wintel machine to run on a hosted Linux server?

What packages would you folks suggest I use to work with? I was looking at ActiveState's ActivePerl. Comments, suggestions???

13 replies

by jaqui

recommend using perl.org's version. it is the version on most linux boxes and will reduce compatability problems.

as long as you don't use os and arch specific coding, ( systems calls most likely ) then coding perl on an ms box and running on a linux bax should be no problem.

you could also use a live cd version of linux to test against a linux system.

most perlscripts in web use are cgi, or are used for accessing system tools for log rotation / handling.
php or asp ( if mod asp is installed ) are more likely to be of more use for website work.

by khunter

Perl.org has the source and recommends ActiveState as one of the sites for the binary. Until I get my own Linux machine running at home (w/SUSE 10) this will have to do as my compiler. I will, however, create one of the live boot CD's to do some interim testing.

Thanks for your help.
Keith

by apotheon

Why do you think PHP or ASP would be of more use than Perl? All three involve server-side scripting: none of them rely on the client. Based on that, I'd choose the language most likely to suit my needs. Since PHP is nothing but an anemic syntax and a huge bucket of functions, and ASP is, to put it briefly, crap, I'm confused as to why you think either would better suit web development than Perl.

Perl/CGI is great for web development, and with mod_perl for Apache you can do inline code with Perl just as you can with PHP.

by polinastya-techrepublic

I just recently started programming in perl. As an alternative to bash, it was great. And given that it is multi-platform, it should suit your needs. And given that it's pre-installed on almost every Unix installation nowadays, it's an obvious choice.

BUT... I would look into the less obvious choices of Python and Groovy. If you're going to learn a new language, Python is more intuitive than perl (IMO).

And given that I'm a Java programmer with significant familiarity with a lot of Java APIs, I favor Groovy. For example, I can connect Groovy to any of my databases via JDBC in a completely cross-platform way.

Both Python and Groovy have many of the popular features of perl, but they are object-oriented.

by khunter

though I don't have any experience there, either. I believe the host server will use Python. I'll look into it.
Thanks,
Keith

by apotheon

You can do object oriented programming with Perl, too. The fact that Perl is flexible enough that it's just as easy to write in a procedural style as it is to write Perl in an object oriented style doesn't in any way mean you can't write object oriented Perl.

Personally, I prefer Perl over Python. In fact, I really rather despise Python.

On the other hand, if you want really intuitive, easy, fun programming with a "pure" object oriented, language, I'd recommend Ruby, and for web development the Rails framework (which uses the Ruby language) is the best web application framework I've ever encountered.

by the admiral

You can, but why?

PERL is slowly becoming a defacto Dinosaur, and other languages such as PHP are becoming a defacto standard.

PERL is very tricky at a administrator level to set up and work properly, and without care, can break really easy.

by polinastya-techrepublic

I assumed we were talking about a Linux environment here. Perl is usually installed on most Unix/Linux installations that I've worked on recently, so I don't see the administrative hassle. If there were such a hassle, I would never bother with it.

I have been working with groovy and it was ridiculously easy to install (assuming you have a java runtime already installed) -- you just unzip the groovy installation zip-file wherever you want to install it and set an environment variable GROOVY_HOME. Done.

PHP is great for webapps. But our PHP programmer has switched over to Ruby on Rails and I don't think he'll ever go back. Even so, PHP is a valuable language to know. Very well-suited to the task of web development. Still, being a java programmer, it gives me the creeps. There are mistakes you can make in PHP that you just can't make in java (because of its strict typing) and the ability of the caller of a method to decide whether or not a method has write access to the arguments passed to it... well that's just wrong in my book. ;-)

But I can't argue against the speed with which good PHP programmers set up web apps.

by apotheon

"[i]But our PHP programmer has switched over to Ruby on Rails and I don't think he'll ever go back.[/i]"
Smart guy.

"[i]Very well-suited to the task of web development.[/i]"
It would be more accurate to say that it's very well suited to the task of very low-end web development on unimportant low-traffic websites if rapid development is more important than good code, and it's not very damned scalable at all. Still, there are times when I use it. In fact, I'm in the process of creating a PHP-based web development framework, but I wouldn't recommend it for anything approaching the level of even a small e-commerce site. It's mostly just good for site designs that require nothing more complex than a template-based dynamic server-side component to the site architecture.

"[i]the ability of the caller of a method to decide whether or not a method has write access to the arguments passed to it[/i]"
That's only possible because PHP doesn't actually have methods. Its so-called object oriented extensions are just clunky workarounds that allow programmers to pretend it's object oriented. It allows programming in an "object oriented style" without actually being an object oriented language at all. If you want true object oriented programming for the web, use Perl or Ruby: Perl if you want something that is flexible enough to allow true object oriented programming, and Ruby if you want something that is inherently object oriented and makes basically anything else for the web look like COBOL by comparison.

"[i]But I can't argue against the speed with which good PHP programmers set up web apps.[/i]"
Exactly. That's the one benefit of PHP. The only benefit. If you're willing to live with the (rather severe) limitations of the language, you can crank out low-end web applications like crazy. A file upload script, for instance, consists of an HTML form and about six lines of PHP (I know this because I produced just such a thing for a friend of mine). Of course, the same could be done with three lines of Perl, but would probably take longer to write properly. Then again, a case could be made for anything written in PHP being written "improperly" by definition.

For rapid web development, nothing beats Rails, anyway. Not even PHP. I'd probably give up PHP entirely if I didn't still have to write and maintain code to run on webhosts that don't support Rails.

by apotheon

What is this crap? Why is it that every time someone mentions Perl the "more popular is better" crowd all comes out of the woodwork to say you should learn something else instead?

Nothing else has the regex capability of Perl. No other scripting language has the impressive breadth of prewritten code that Perl has (check out CPAN some time). Nothing is as flexible as Perl.

I wouldn't use Perl for everything, but I wouldn't discount it as a "dinosaur", either. It's every bit as capable as Python, and then some, and as for PHP:

PHP is an anemic syntax with a gigantic bucket of functions. It's not capable of anything approaching real object oriented programming. It's slow. It doesn't lend itself to MVC orthogonality. It tends to force a certain amount of repetition of data (which is a bad thing, for those of you that aren't familiar with the DRY principle). It works a bit like a language written by kids, and that's because it is a language written by kids.

I use PHP, but only for low-importance, low-functionality, low-traffic websites when I'm feeling lazy. PHP is for lazy code. That's it.

"PERL is very tricky at a administrator level to set up and work properly, and without care, can break really easy."
Two things:
1. BS. I have no idea where you got that idea. What a load of crap.
2. It's Perl, if you're talking about the language, and perl, if you're talking about the interpreter. It's never PERL unless you don't know what you're talking about.

by apotheon

Don't listen to any schmucks that try to tell you otherwise. Perl's great. It's not a "dinosaur", and it's not "obsolete". PHP will likely be obsolete before Perl ever is. Even Javascript has a more powerful and flexible syntax than PHP.

Ruby on Rails is probably going to prove to be more useful for web development in the low- to middle-range than anything Perl based, but for really high-end stuff (high traffic, high load), Perl still has Rails beat. Of course, if you have a webhost that'll run Ruby, you can do the same high-end web development with Ruby that you can with Perl, but Rails doesn't scale quite well enough to be usable at that level. Anything short of it, though, and Rails kicks serious butt.

For a good web development framework somewhat like Rails, but for use with Perl, look into Catalyst. It's pretty good as well. Like Rails, it kicks the crap out of Zope (in my humble opinion) and Struts.

If you want to develop Perl for a unix/Linux platform, you should test it on a unix/Linux platform. Perl is one of the most cross-platform capable languages in existence, and as long as you're doing web development with it you should be okay, but it's still best to test on the platform on which you'll be deploying your code. As such, you may not even have any particular need to install an interpreter on your Windows machine, if you have easy access to the deployment platform: you can just write your Perl code using whatever text editor you like best for programming. I, for instance, tend to use vim on Linux systems, and SciTE on Windows systems (both are open source and free, both as in speech and as in beer).

If you just want a Perl interpreter on your computer for playing around and learning the language, and don't have terribly handy access to a unix/Linux system, ActivePerl will work just fine. Just remember what I said about testing your code on the platform on which you'll be deploying it.

Question: What sort of webserver hosting are you using? Are you using a commercial webhost, doing virtual server hosting, running your own webserver, or something else entirely? That might have an effect on the sort of advice someone knowledgeable would give you. For instance, if you're stuck with a small-time webhost, you probably have Perl and PHP support, may or may not have Python support, and almost certainly have no support for Ruby, Scheme, or Java. May webhosts won't allow you to run compiled binaries from the cgi-bin, which can also be a problem, depending on what sort of web development you want to do.

by polinastya-techrepublic

I've only worked through perl tutorials enough to write two scripts, but I have yet to see anything in perl that resembles object-oriented features (i.e. classes, method overloading, inheritance). In fact, rudimentary perl is extremely limited, having only three data types (scalar variables, lists and hashes).

I didn't realize that Java was as unsupported as you say on typical web hosts, but I was aware that perl is ubiquitous (on Unix/Linux machines anyway). That's why I have forced myself to learn it.

For example, today I had to write a script to modify /etc/printer.conf in a very uniform way, changing text such as "socket://x.x.x.x" to "lpd://mylpdserver/myprinter". I suppose I could have written this script in bash, but with perl it was really easy (and I say that even though I had to google a lot of stuff). I would have preferred to have written it in groovy, but perl was already installed and I wanted it done by end of day, so I used perl.

As for regular expression support, I think all of these scripting languages (Ruby, groovy, Python & perl -- don't know about PHP) have similar regular expression support. Nobody would use them if they didn't match perl in that regard (no pun intended).

by apotheon

It takes some familiarity with the language to start seeing the OOP support. Most of the scripts you'll run across are strictly procedural (which actually makes sense for small scripts: there's no need to define classes and the like when writing a fifteen-line script to traverse directories and make modifications to file contents), and the tutorials out there all tend to focus on the procedural uses of the langauge.

Here's a quote from Chapter 7, "Object-Oriented Programming", of the book [u]Advanced Perl Programming[/u]:

"[i]Object orientation (OO) is the latest software methodology to occupy the airwaves, hyped to a point where the term "object-oriented design" seems to automatically imply a good design. In this chapter, we will study what the noise is all about and build objects using Perl. I will leave it to the plethora of OO literature to convince you that there is a respectable middle-ground and that the object revolution is indeed a good thing.

If you are already conversant with OO, you could simply read the "Objects" section in Appendix B, Syntax Summary. Among other things, it supplies a C++ example and translates it to equivalent Perl code.[/i]"

Re: regexen

Those other scripting languages all pretty much derive their regex capabilities from Perl. In using regexen in such other scripting languages, the only really obvious difference you'll notice at first is minor syntactical differences such as how a substitution regex is used ( $foo =~ s/match/replace/ in Perl, $foo = ereg_replace('match', 'replace', $foo) in PHP, et cetera). This tends to make regex substitutions a bit clunky to write in other languages, but they usually look prettier to those who grew up on syntax that doesn't include the Perl way of doing things. The real differences, though, come up when you start doing things that are a bit more complex, such as trying to work with special characters in your regexen. For simple stuff, the other languages tend to be pretty close to Perl in functionality, but when you start getting into really hairy code, the limitations of other languages start becoming a little more evident. I hear good things about Ruby's support for regexen, though, as compared with Perl's -- even at the high end of it. I haven't done much regex work in Ruby yet, though, so I can't confirm or deny the reports.

This discussion is closed to new replies.