[NBLUG/talk] Perl vs other scripting methods
matt at cfxnetworks.com
Tue May 9 16:28:54 PDT 2006
On Tuesday 09 May 2006 11:16, Todd Cary wrote:
> I am sorry about creating some confusion when I mentioned PHP. My
> intent was to indicate that I am comfortable with the syntax and as I
> recall, there is some similarity to Perl (as well as C). By no means do
> I intend using PHP for system level scripting. My main question is Perl
> versus the shell languages about which I know zip other than struggling
> to understand some of the scripts. Should one really go through the
> efforts and learn the language that is used by so many scripts in Linux
> or stick with Perl or as suggested, Python?
Of course [ba]sh is the core, and if you want to go through learning it then I
would say like most everyone here it is a fundamental skill in the *nix
world; but yeah, Perl is more powerful.
Honestly it depends on what you want to do ("write scrips?"). I think of it
this way, if you need to quickly get some coding done:
If you *know* Perl, then of course use it. But you said it's been 15 years,
and like any language, if you don't use it for that long, you'll forget it.
If you don't know Perl, shell, or Python and need to learn one to start
writing scripts, then my recommendation is Python.
I'm not fanboying Python here, I'm simply saying that if you must learn a
language and want to actually get something accomplished as soon as possible,
I can almost assure you that you will spend less time learning Python than
the other two to expedite your coding process.
Walter Hansen wrote:
> So tell me what Python is good at.
I would say simply that Python is an easy but powerful language. Python is
good at accomplishing real programs in minimal amounts of time, and has
bindings to almost all major GUI toolkits. Python was created to be one of
the most intuitive languages out there, making it more human-readable and
having less unnecessary syntax than other languages (semicolons and braces
that are at this point in technologically useless).
The main grievance I hear about Python is that "it forces a coding style on
you," namely the required* tabbing. Honestly, that is one of the worst
arguments I've heard, as it is one of the most free-form languages around.
First off, you *should* be tabbing your code. If you aren't, then that's a
problem in itself. Second, if you are so masochistic as to want to make your
code in one line, then you can use semicolons like; this; here; if you so
desire. (A Python script won an obfuscated code contest once.) Moreover, you
can space code how you want, and add parentheses, move things, use tabs, not
use tabs, whatever you please. I honestly couldn't point out a feature that C
has to bastardize your code that Python doesn't (not that there should be).
In a nutshell, the idea is elegance. Python is an elegant, human-readable
language that tries to remove all of the unnecessary crap that keeps you from
accomplishing your job: making the program. Programming shouldn't be about
writing the code; it should be about developing the concept.
matt at cfxnetworks.com
More information about the talk