Do I really need to learn Java?

Alex Martelli aleaxit at yahoo.com
Mon May 14 10:50:06 EDT 2001


"Hanna Joo" <hanna at chagford.com> wrote in message
news:989842871.798475 at nntp01.uskonet.com...
    ...
> Can somebody explain what the advantages/disadvantages of using Java (or
> C++) compared to python? And whether I will have to use Java in certain
> situations?

C++ allows you, potentially, to build software components that
are *WAY* faster than ones you can write in pure Python.  The
price to pay for that is HORRIBLE complexity.  You may ge the
same speed in C (without the ++), with less complexity _BUT_
probably far less productivity as well (in C, you'll be working
at a much lower level than you typically will in C++ -- compare
writing Python extensions with the bare Python C API's vs writing
them with the "Boost Python Library" for a typical example).

Java has different "deployment" characteristics than "Classic"
Python, but I can't think of anything you can do in Java that
you cannot also do with Jython, the Python version that targets
the JVM.  If you go the Jython route, you'll need some level of
"nodding acquaintance" with Java to be able to read the docs
and examples for existing Java libraries you want to use -- that
doc & examples are no doubt going to be expressed in Java terms
(just like, say, the docs & examples for COM objects you may
want to use from Classic Python on Windows are likely to be in
Visual Basic terms, so you need a nodding acquantaince with VB
just to be able to read those docs -- you may never need to write
a single line of code in VB, but...).


For purposes of "mind-broadening", without (probably) aspects
of practical use, and also to satisfy a desire for cleanness
and elegance, I recommend Haskell.  It will show you how a
strictly-typed language SHOULD be (far different from the
typing issues in C++ or Java...!!!), and introduce you to
pure functional programming, "lazy evaluation", &c.  It even
has some surface semantic similarities with Python, in that
it makes significant use of whitespace (with the "off-side
rule", a bit more complex than what Python does but not by
all that much:-).  And you'll find old Python friends in
new guises, such as list comprehensions (which Python got
from Haskell), albeit with different syntax -- in Haskell:
    [ x | x<-y, x>23 ]
is like, in Python:
    [ x for x in y if x > 23 ]

Probably the hardest single step will be realizing that what
Haskell (AND just about any other programming language:-)
calls "a list" is NOT what Python calls "a list" -- lists in
Haskell (and Lisp, and C++, &tc) are such that access is
only fast at the head (getting the N-th item has a cost that
is proportional to N), while Python's "lists" are more similar
to what other programming languages call "vectors" or else
"arrays" (getting the N-th item has constant cost, does not
depend on N).


Alex






More information about the Python-list mailing list