convince me

Gareth McCaughan Gareth.McCaughan at pobox.com
Wed Aug 7 04:26:29 CEST 2002


Kyle Babich wrote:

> I started learning perl but more recently I found python.  Both look
> to have their advantages, so I'm having a hard time picking one to
> stick with and persue.  I have seen arguments that python has cleaner
> syntax, is gaining in popularity, with excellent documentation, and is
> better for group projects, which is all fairly obvious.  But (from a
> _neutral_ standpoint I am asking) what can python do that perl can't?

[and elsewhere Kyle's explained that he's 15 and just getting
into programming...]

Wrong question :-). Programming languages are not at war,
despite what some people seem to think. You should learn
several. Learn a good variety now, while you're young and
your brain hasn't turned into concrete, and you'll be more
adaptable for the future.

                         *

You should definitely learn Python. It's startlingly easy
to learn, and it has some important ideas in it (classes,
inheritance, dynamic typing, dictionaries, list comprehensions,
iterators, generators, garbage collection, ...) that are
good to have firmly lodged in your head.

You should learn Perl, but don't learn it now. Wait three
years, until Perl 6 has either arrived and started to get
established or turned out not to be happening after all.
(My money's on the former.) It's going to be very different
from Perl 5.

You should learn at least one close-to-the-machine language;
C is the obvious choice, and a good one for many reasons.
(It runs *everywhere*, lots of things are written in it,
it's good to have on your CV, it'll stand you in good stead
for learning Java or, if you must, C++, it's quite decently
designed.)

Don't learn Java now unless your only consideration is
maximizing your salary in the next few years. It shouldn't
be. The Java *language* contains very few ideas you won't
meet elsewhere. What's hard about learning Java is getting
a clear picture of all the libraries into your head. That's
something that will be easier when you have more experience,
so wait a bit. And, besides, it's always possible that C#
will have taken over the world. So this is another one to
look at in three years' time.

Don't learn C++ now. It has many powerful things in it,
but many of them are warped into ugly shapes by having to
be mostly compatible with C, and by the principle that
"what you don't use, you shouldn't pay for"[1]. You should
learn as many of the ideas as you can from languages where
they take better forms -- classes and objects from Python
or Java or something, generative programming from Common Lisp,
close-to-the-metal stuff from plain ol' C, and so on --
and pick up C++ later if you really need to.

*Do* learn some more unconventional languages, languages
with ideas in that you won't encounter by learning a hundred
variations on C.

Learn Haskell to understand about functional programming,
lazy evaluation, type inference, and pattern-matching
function definitions.

Learn Common Lisp to understand how treating code as data
can enable you to transform your programming language into
what you need, to get a completely different view of object-
-oriented programming from the one you'll get from Python
or Java or C++, and to appreciate that good performance
*can* be had from a dynamically typed language.

Learn Prolog to discover how programming feels when you
have a little theorem prover as part of the language.

Learn an assembly language to understand what is *really*
happening when the computer runs your programs. Take a
look at the code your compilers generate, if you're
writing in something that compiles to native code. The
results may be enlightening. Or baffling.

Consider learning Forth, Fortran, OCaml, Oz, Smalltalk,
and every other language you encounter. Even Cobol,
JavaScript and Visual Basic. (But by law you aren't
allowed to see those until you're 18 unless you have
parental supervision.)

                         *

Why should you go to all this trouble? Because it will
make you a much, much better programmer than if you
just learn a few languages and try to specialize in
them. It will also make you better at learning languages
really well, having more points of reference. And if
you learn lots of languages, you'll find yourself
comparing them, thinking about why they are the way
they are. In other words, you'll be paying attention
to issues of design as well as of coding. Don't listen
to people who say you can do either of those well
without the other.

                         *

[1] Unfortunately, if you widen this principle beyond
    the narrow focus of runtime efficiency at all, C++
    violates it really badly. C++ programmers around the
    world are paying every day for micro-efficiency and
    C-compatibility that they don't need.

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
.sig under construc



More information about the Python-list mailing list