[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Programming Languages, "to C or not to C, that is the Q."



Sam Watkins wrote:

I know perl very well, use it often, and don't recommend to learn it.
Or rather, I recommend not to learn it.  Perl is powerful and popular,
and has many libraries, but it's syntax is awful beyond your wildest
nightmares.  Perl is insane.  Learn python or ruby instead.
Or assembly language, or intercal, or brainf*ck - anything but perl!
Personally I really love Perl, but I confess to not knowing Python. Part of the reason for my delight in Perl is that I spend a lot of my time manipulating text files, and some of my time doing system administration, which are considered its strengths. Its syntax is diverse and intentionally designed to provide terse options for "common" situations, especially those involving text manipulation. This is both good and bad, as it makes it harder for beginning and intermediate Perl programmers to read other people's code. Perl was challenging for me to learn, but partly that was due to the fact that I was only familiar with C, partly that I had never been exposed to dynamic languages, and partly that I wasn't an expert in regular expressions (and Perl programmers seem to like to use those as much as possible ;-) I agree that Perl is crazy, but beautiful, as is its mad genius creator, Larry Wall.

A big factor in choosing a language is maintainability by somebody else, and the likelihood that there are other programmers out there who will be able to collaborate. Perl has good points and bad points here.

I don't know what people think about bogus indexes, but here is one view of the popularity contest between languages:

http://www.tiobe.com/tpci.htm

Here is another bogus popularity index: ranking by number of projects at SourceForge:

C++     14591   18.5 %
C       14158   17.9 %
Java    13852   17.5 %
PHP     10227   13.0 %
Perl    5613    7.1 %
Python  3694    4.7 %
C#      2124    2.7 %
JavaScript      2106    2.7 %
Visual Basic    2022    2.6 %
Delphi/Kylix    1681    2.1 %
Unix Shell      1604    2.0 %
Assembly        1479    1.9 %
PL/SQL  1070    1.4 %
Tcl     842     1.1 %
...

I created that listing with a little Perl program, feeding it the text I copied from the projects-by-language page at SourceForge: http://sourceforge.net/softwaremap/trove_list.php?form_cat=160

This is a pretty typical use of Perl. Note that the regular expression given, while legal, might not normally be written as it is, but more scarily as "/^\s+([^(]+)\s+\((\d+)/". Non-Perl coders will unfortunately be mystified by several perlish shortcuts, namely the magical DATA filehandle, which reads from the source code starting at the __DATA__ line, the magical <FILEHANDLE> operator, the important but invisible $_ variable, and the magical $a and $b variables in the custom sort function. All these bits of magic are considered Features, and personally, once I got over hating them, I love them. The printf ugliness is inherited from C. The regular expression ugliness and capturing convention is inherited from a variety of UNIX tools; I use regexps all the time: in my editor, in perl, in my pager (less), and even in my database (PostgreSQL). Learn 'em and love 'em.

# How popular is Perl among the open source community?  Will we ever know?
use strict;
use warnings;

my %langs;
my $total;

while (<DATA>) {
# The following regexp would ordinarily be written: /^\s+([^(]+)\s+\((\d+)/
 if (/^   # match the beginning of the line
   \s+    # match one or more whitespace characters
([^(]+) # match one or more characters that are not a left parenthesis and capture into $1
   \s+    # match one or more whitespace characters
   \(      # match a left parenthesis
   (\d+)    # match one or more digits and capture into $2
   /x) {
   $langs{$1} = $2;
   $total += $2;
 }
}

foreach my $lang (sort {$langs{$b} <=> $langs{$a}} keys %langs) {
 printf "%s\t%d\t%.1f %%\n",
        $lang, $langs{$lang}, 100*$langs{$lang}/$total;
}

exit 0;

__DATA__
# I pasted stuff from http://sourceforge.net/softwaremap/trove_list.php?form_cat=160 here:
     ActionScript (8 projects)
     Ada (89 projects)
     APL (13 projects)
     AppleScript (7 projects)
     ASP (520 projects)
# ... and so forth ...



Reply to: