Clear questions and runnable code
get the best and fastest answer
Perl is an incredible language.
I feel so very fortunate that I learned Perl back in the early/mid 90's when it was the language for the Web. Back in the early Internet days, I hired a consultant to help me learn a few basic routines in Perl and something he said stuck with me and has been true to this day:
"You can do anything with Perl".
Initially, I had a fairly steep learning curve and wrote crap Perl but it worked. Over the years, I got better and better and started to work on form.
Now, I use Perl daily and have solved so many business problems with Perl. Perl has provided me with the ability to create so many mission critical programs for the company I work for with the sole cost of my personal salary. And, this stuff just works well. Compare this to all of the money that my company spends on the Microsoft-oriented Web developers and the tools they need in my company and I am know my boss appreciates my budget compared to theirs - not to mention the quality of my work.In my opinion, the big issues with Perl that I had in the beginning derive from the following areas.
Easy to use out of the box
Sure, Perl is easy no doubt.
But, having come from a Windows background with a novice level of programming, the initial thing that struck me as missing with Perl compared to any other languages being used was the visual programming aspect. By visual programming, I am talking about a GUI builder where you built the user interface and populate the code in events to create an interactive program. The idea of a console program does not initially compute and certainly does not work for the users I am programming for.
The coolest thing as a beginner was to be able to put together a stupid little Windows program in something like Delphi or VB that could connect to a database and show data through a data grid. I mean - this was easy. Ooh, I needed to add a little message box with a button - easy. Menus, a toolbar with cut, copy and paste. - many of the visual components of a working program.
In my experience, the user interface is actually quite a large portion of a program. It is often the most tedious to get right and, to the user, it is the program.
Working in a visual environment shaped my expectations and skewed my perceptions of what I thought programming was about. Building GUI programs in Perl is not a strong suite and cannot capture the imagination of those who are coming from this type of visual, instant environment.
The main goal of a beginner or novice is to see visible results and build from there. Having a GUI builder definitely gave tangibility. The problem was that the GUI environment gave the illusion of learning to code when in fact - this was really only interface building.
In contrast, I really started to learn how to program when I started learning Perl. Now - I can generate modules and "working" code more effectively but I generally do not build Windows GUI programs since I have the bias for wanting to do it in a visual environment.
I know that there are some tools out there that do this such as Glade but these are not initially seen by beginners and as such do not provide any instant gratification.
On a similar note, this is why PHP is so popular - because it is somewhat visual in nature and shows quick tangible results for novice programmers to show to end users.
Why I use Perl instead of X
Another reason why I like Perl is because of the loose typing. I know some people will disagree here but that's why you can look forward to Perl 6 and we can both win :-)
In general, I am not really interested in "programming" but rather solving problems. I really enjoy being able to stuff anything into a scalar variable. Hey, I need a list of scalars or I need to lookup scalars by name. These are human-oriented functions that are built-in. Lists of lists, hashes of hashes or a combination of those. Add references to the mix and I am set for a lot of complex problem solving.
When I was coding in Delphi, I had to worry about every variable type. If I used a number - what kind (integer or float) and if I wanted to show it on the screen I had to cast it into a string - how tedious! What if I didn't use the right type and I reached the numeric limit - poof! Where is the ObjectForThisSpecificPurpose object and what does it derive from? Where is that object tree again?
With Perl - I am focused on the problems and not having to worry about variable types, casting and the tedious details of working with the machine.
Finally, the Perl community is really the best thing about Perl. Without the community and the generous nature of the people involved - Perl as a language would stagnate. I appreciate that I am "Standing on the Shoulders of Giants". CPAN has allowed me to leverage my knowledge significantly. Need to unzip a file - Archive::Extract. Templating - Template Toolkit. Database connectivity - DBI. Amazing!
Too bad other people stuck in straight-jacket languages don't get the same experience. It's liberating. My personal next step is to integrate GUI programming.
Sorry for the long-winded post - but my feeling is that the lack of instant gratification in a visual sense (it being foreign to the developer) and the inability of beginners to appreciate that you can focus on problems not programming are the some of the main detractors of Perl's excitement.