perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Greenish <grea...@yahoo.com>
Subject Re: A question for the newbies
Date Thu, 16 Feb 2006 17:48:26 GMT
I've been writing in perl for just over a year.  I was
a developer in embedded controls, but had an idea for
a website and some free time so started learning perl.
 I had a strong C++ background so understood OO pretty
well.  I chose Perl because I had heard so much about
it.  My first site was pure scripting, all code & html
in one file.  It was such a mess but a great learning
experience.

After switching jobs, I had the opportunity to take a
"java for the web" class and learned the MVC way.  I
was eager to apply this to my web project, however it
took me quite a while to figure out how to write OO
with Perl.  In fact, I really struggled for several
weeks.  I looked around on the web for a while, tried
to study the modperl apache site's examples, but just
couldn't derive a good code example; I understood OO,
I knew that perl could do OO and I couldn't find
design patterns to go to the next step.  It wasn't
until I happened to run across "Learning Perl Objects,
References, and Modules", by Randal L. Schwartz that I
started to develop a web pattern for implementing MVC
with perl.  If it wasn't for that book, I probably
would have given up.  Even with that, it took me a
while to figure out how to write good constructors.  I
looked plenty, but I just couldn't seem to find the
right info on the web.

Taking a step back, after that java class, I
considered Java struts.  I like much of the language
syntax, such as the "." vs "->" notation.  However,
the prospect of setting up Tomcat on top of learning
Apache by myself seemed daunting.  In addition, Java
Struts seems overkill for most applications.  

5 months ago, I changed jobs again and now work in a
PHP only shop.  What I miss from Perl with PHP is how
broad the language is.  There seem to be no limits to
Perl. The syntax is easy and extensive. I can do unix
tasks and web task.  And there are so many reliable
modules available via  CPAN.  PHP has pear, but its
not nearly as extensive.  The other thing I miss about
perl when programming in PHP is the arrays.  In PHP,
there are associative arrays; I uses complex sets of
anonymous hashes and arrays all the time in perl, but
it's harder to do the same thing in PHP. And I find
dereferencing harder too.  And of course, perl regex
is 100x better than PHP's limit string matching and
grepping.

What I like about PHP over perl is the ease of
variable declaration.  I feel I have to use strict
with perl, I would like the ability to not have to put
"my" in front of every new variable.  Probably 1/4 of
my errors when debugging pages for the first time are
undeclared variables.  Seems  stupid and I try to be
thorough, but it still happens and it's a nuisance. 
My biggest complaint for perl for web apps, however,
is the templating.  I haven't found a template module
in perl that rivals Smarty templates in PHP.  What's
with this crazy loop structure in HTML Templates?  Why
can't I just iterate over an array without having to
put it in a crazy anonymous array thing.  I can access
any array element with ".".  Smarty plugin's are
great.  They help with creating select drop downs,
date drop downs.  I can capitalize, count, strip
template variables within smarty.  There seems to be
so much more I can do with Smarty than with
HTML::Template.  Maybe I just missed all that stuff in
the documentation but again, I didn't find it.  Also,
it's much easier to include a code snippet in php than
in perl.

Today, Perl is still my personal favorite language to
code for web/unix task.  However at work, I am
implementing MVC in PHP 4 much like I did with Perl
using the basic OO capabilities available in 4. 
Interface functions don't help in the web apps I do
(small - medium) so I don't see to much need for us to
move to 5.  But that's another topic.  

That's my experience so far with perl vs PHP vs Java
so far.

greanie

--- Boysenberry Payne <boysenberry@humaniteque.com>
wrote:

> I guess I'm still considered a mod_perl / perl
> newbie.  I started 
> learning perl 6 months
> ago in anticipation of translating a CMS (Content
> Management System) I 
> wrote in PHP.
> 
> I considered Python, and  C++ as alternatives.  C++
> was over kill and 
> would require
> way too much development just to get going (why
> reinvent the wheel if I 
> don't have to.)
> Python, seemed too similar to PHP for my tastes.  I
> don't like being 
> "forced" to use
> someone else's coding conventions unless I know
> there are valid reasons 
> for it.
> With what I read about Python's white space issues,
> I thought it might 
> be more
> tedious, rather than easier to maintain my 50+ files
> of code.
> 
> Once I started looking into perl I was blown away. 
> Not only has perl 
> been the "swiss
> army knife" of system administration for well over
> 10 years, but 
> mod_perl blows the
> socks off of php.
> 
> So for my particular project I couldn't find a
> better solution.
> 
> I think the hardest part about learning perl (coming
> from developing in
> php for 5 years) was the odd mix of syntax.  It's a
> mixture of a couple 
> of
> languages.  Because I was new to unix and shell
> syntax it was a bit of
> time before I started to feel comfortable. 
> Considering 70% of the 
> internet
> is run off of *nix flavored servers it's not a bad
> skill to have.
> 
> The benefits of having moved to perl from php are
> too many to count.
> Just the efficiency of perl's string manipulation
> cut my code down by
> up-to 50% in some cases.  Perls abilities to be used
> both procedurally
> as well Object Oriented makes it easy for me to use
> it which ever way
> is most useful for my task.
> 
> Moving from PHP to Perl has been the smartest move
> I've made.  Our
> code is more secure (we use a proxy system to keep
> it completely 
> separate
> from our client's file server.)  Our system is more
> stable and 
> responsive.
> And my code is 100% easier to maintain.
> 
> Although I could have used Python or even stuck with
> PHP and 
> accomplished
> most of what I'm doing, it would take more time, and
> wouldn't be nearly 
> as much
> fun.  In my situation (building a CMS without
> funding, etc.) I don't 
> think I would
> have made it this far without being inspired as I
> was by perl, mod_perl 
> and
> all that they can do.
> 
> Did I mention CPAN?
> 
> My hat is off to the Perl/mod_perl community for
> giving such an 
> opportunity.
> When in history has it been so bright?
> 
> Boysenberry
> 
> boysenberrys.com | habitatlife.com | selfgnosis.com
> 
> On Feb 16, 2006, at 7:41 AM, Clinton Gormley wrote:
> 
> > It seems to me that a lot of people new to
> mod_perl and to Perl have
> > joined this mailing list recently.
> >
> > And this is during a period when popular opinion
> (amongst those who 
> > know
> > no better) seems to regard Perl as antiquated.
> >
> > I'm delighted that new people are joining.
> >
> > My question is, what prompted you? What made you
> choose Perl above
> > Java/.Net/Python/Ruby etc etc
> >
> > Do you have experience of those languages? What
> appeals to you about
> > Perl? And how do you find your community
> experience/support compared to
> > the other languages you know?
> >
> > clint
> >
> >
> >
> >
> 
> 



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Mime
View raw message