[BNE-PM] What do you use Perl for?

Derek Thomson derek at wedgetail.com
Tue Aug 20 00:55:12 CDT 2002


Tony Obermeit wrote:
> Derek, I appreciate your comments and questions.  Please take my 
> comments as my perspective, I don't want to start a flame war....

You don't! What kind of attitude is that? ;)

>>> Previously I used perl for all three of these areas, now I use java 
>>> for application development, ant for build scripts and perl for 
>>> ad-hoc scripts.
>>
>>
>> Okay, my question is: what technical reason is there for using Java 
>> for web applicatoins instead of Perl?
> 
> 
> When using perl as a language for developing an application that will be 
> deployed to many sites, with a variety of configurations, I found perl 
> to be challenging.  Some of the issues I had were:
> 
> (1) I didn't want to ship my source code.  With java I am able to ship 
> only compiled .class files.  This gives me a significantly higher level 
> of confidence that a bug hasn't occurred because someone hacked the 
> source code.

I would reply, compilation != encryption, and I'm happy for anyone to 
have my source. Yes this causes "friction" with management, so I do see 
your point ...

As for modifying ... if they modify it they get what they deserve? Just 
run a digest over the source directories, if it comes up different, tell 
them to put it back. Or, just make the source files read-only!

> 
> (2) When I installed my perl scripts, I had to edit each script to 
> replace the path to the perl interpreter if the perl interpreter was 
> installed in a different directory to mine, 

There are ways (I'm told) of arranging things so that you can ship a 
"complete" application. You can even go as far as shipping Perl with the 
application, which is what a lot of Java developers do (in effect) when 
they demand Java 1.3.x by VendorY (usually Sun).

> particularly worse when 
> trying to keep the application working on unix and Windows NT/2k.  This 
> caused me concern in regard to the installation of my application.

Desupport Windows? :) Actually I've almost zero Windows experience, but 
our Perl test framework seems to run all right.

> 
> (3)  I had challenges getting dbi/dbd::oracle working in a linux 
> environment, with java, jdbc just seemed to work in any environment.

I had just the opposite experience. That one just comes down to what 
you're used to, I guess.

> 
> (4) Ease of installation of a finished application, with perl I had 
> numerous scripts (.pl, .pm) to install.  

Apparently, you can package all this up in nice ways. I've not tried it 
but that's what I'm told.

> Java was much easier, I could 
> ship a single .jar file that included the entire compiled code of the 
> application, including the web server, the jdbc drivers and my 
> application, that made it easy to install the application, copy a single 
> .jar file to a directory and run with a single command java -jar 
> jarfilename.jar.  There can be issues if the version of java on the 
> target system is older than what you expect but the same applies to perl.

Yes, but I often find that running a Java program or installing a Java 
library is a lot of painful fiddlework with PATHS and JAVAPATH. With 
Perl I just go:

$ cpan
 > install Parse::RecDescent
 > quit
$

... and I'm done.

> 
> Once I got in to java, I also found that much more design material was 
> available in regards to object oriented development than was available 
> in perl.  Topics such as design patterns are well covered in a variety 
> of java books and white pages.  Many examples of Model/View/Controller 
> (MVC) patterns are around in java, that didn't even seem to get 
> discussed much in the perl world. 

I totally agree. Which is odd, as Perl's OO system is much more powerful 
than Java's, although it's strange at first. Get Damian Conway's OO Perl 
book - not only does it make Perl OO understandable, but it explores 
interesting OO topics that are impossible or hard to do in static 
languages like Java or C++.

A quick example - XML::Parser can not only parse XML, but create classes 
for each kind of element encountered on the fly. This kind of 
meta-programming can't happen in Java, and it's something that's hard to 
live without once you start using it!

>  A topic associated with this is 
> development methodologies, the Agile Methodologies including Extreme 
> Programming are well supported in the java world with junit.  I'd be 
> interested to hear from others who have used perl and Extreme 
> Programming and what conclusions they have drawn from the experience.

There is a testing framework built into Java. But I'll leave XP for 
another flame war :)

> 
>> I haven't ever done any web applications, so I really don't know, but 
>> my experience with Java is that it's large, slow, not very portable 
>> really, and the database integration support just doesn't measure up 
>> to Perl's DBI module, and it takes a *lot* more code to get anywhere.
> 
> 
> Web applications are much different in java than non-web applications.  
> With non-web applications in java the java GUI is not pretty, your 
> comments below about java guis that are slow and large are quite 
> applicable). 

And ugly, and *incredibly* hard to make simple stuff behave correctly 
and consistently. Perl/TK, OTOH, is amazingly easy for GUI work.

> With web applications, java generates the html and the 
> performance isn't really an issue.  One issue in perl's favour is that 
> the breadth of available libraries is much better and richer than java 
> in certain areas such as generation of png charts, etc.  The newer 
> versions of java (many since 1999) are much better performance wise.  

I keep hearing that, but it never seems to translate into reality ... 
just look at how long javac takes compared to jikes!

> The number of api's being released with each version of java are 
> staggering.

Yes.

> 
> Having used DBI and JDBC extensively, I can't see where java's database 
> integration doesn't measure up to perl's dbi.  

At the time JDBC driver support was abysmal.

> They are both quite 
> similar to use.  I haven't looked at how to do database connection 
> pooling in dbi but it is quite easy now in java with jdbc2.  It can take 
> more code in java to get some things done in perl but the object 
> orientation in java is better than it was in perl.

No, I'd say the object orientation in Java is not better in Perl. Try 
the Class::Contract module, which gives you class invariants, abd true 
pre and post conditions (and the pre conditions can refer to the 
previous state of the object!). You can't do that in Java!

(Java still doesn't have multiple inheritence - and don't tell me I 
don't need it!)

> 
> I have found it easier to make java applications portable across 
> unix/Windows than perl.

I haven't, but that's just been our respective experiences. People do 
make porting harder by using Perl to call Unix utilities, but I just 
slap them until they don't do it any more :)

> 
>> That was in 1999, maybe things have changed (but I still have to run 
>> Java GUIs that are too slow and suck up 46M!!). Is there any real 
>> advantage over, say Apache + mod_perl + Perl?
> 
> 
> Overall, I would say the servlet api provides better capabilities than 
> Apache + mod_perl but I believe a dedicated perl developer can build 
> just as fast (if not faster) applications using perl with mod_perl.  One 
> limitation with that is being tied to Apache.  With the advent of a 
> number of pure java web servers, BEA, Orion, for example, being tied to 
> apache can be a limitation.
> 

Do any of these Java web servers show up on http://netcraft.com? I think 
Apache's the clear winner, and by implication much more trustworthy than 
any of these other things. It comes down to the "only N engineers" 
argument that applies to all proprietary development. And what if the 
company vanishes, forces you to "upgrade", or silently desupports the 
product chasing the latest over hyped bandwagon (Web services, anyone)?

> I would also say that part of my choice in using java over perl in 
> application development had to do with career goals.  Java has become 
> much more the language of choice in the enterprise size of organisations 
> compared to perl.  

You mean, like Amazon or IMDB? :)

> Organisations like IBM, Oracle, BEA, Borland and Sun 
> have made significant investment in java.  

But if you can do exactly the same thing in 1/10th the time, and not 
have to pay for an "Enterprise" server (whatever that is this week :) 
then I think you're better off.

> For some, the fact that java 
> is not open source is an issue, my answer to that, choose perl if that 
> bothers you.

I guess I've done enough Java GUIs and server-side work to tick that 
box. I didn't really like it, I'd pick C++ over it any day, as my work 
reflected Sun's engineering quality, not mine. I also missed the 
consistent typing and collection type-safety - and not grappling with 
the GUI bugs.

> 
> Perl is a really great language, it has many strengths, the same applies 
> to java, I continue to use both languages and encourage others to do the 
> same.  The learning curve for me was significantly larger with java 
> compared to perl, yet I have several friends who took up perl on the 
> basis of my ravings about it and both of them struggled with learning 
> perl.  That was hard for me to understand because I found perl extremely 
> easy to learn.
> 

Everyone should start by reading "Learning Perl" by Schwarz and Phoenix. 
"It is the only way" ...

Regards,
Derek.




More information about the Brisbane-pm mailing list