Complementary language?

Mike Meyer mwm at mired.org
Sat Dec 25 23:07:34 EST 2004


HackingYodel <taoiststarter at -nospam-yahoo.com> writes:

> Hello all!  I'm learning to program at home.  I can't imagine a better
> language than Python for this.  The ideal situation, for me, would be
> to study two languages at the same time.  Probably sounds crazy, but
> it works out better for me.  Being a newbie, I find almost all
> languages fascinating.  C, D, Objective-C, Ocaml, C++, Lisp, how is a
> non-tech to choose?  Does any single language do a better job in
> Python's weaker areas? Would anyone care to suggest one to supplement
> Python.  That is, if you could only use Python and one other language,
> which would it be? Thank you for your time and help.

It depends on what your goals are. Python is an excellent language for
learning OO and procedural programming, and makes it possible to learn
functional programming as well.

Part of the Python philosphy is that there should be one obvious way
to do something. That's what makes it an attractive language to
me. Eiffel shares this philosphy, in that every feature of the
language was added to solve a specific problem that programmers
encounter. It does many other things the exact opposite of
Python. It's statically typed, with no loopholes allowed. For cases
where you're not sure that something is conformant with a variable
(meaning it's the same class as the variable or inherits from it in
some way), there's even a "work if you can" assignment operator. So
you see code that looks like:

       a ?= b
       if a /= Void then
          doSomethingWith(a)
       else
          doSomethingElseWith(b)
       end

As you can see, it keywords instead of :. It's pure OO, in that there
are no free-standing functions; every function is a method of a
class. Functions aren't first-class objects, so you can invoke
parameterless methods with just object.method. This allows subclasses
to change such a method to a variable without you having to change any
code anywhere else in the system. It has export rules to control what
features (shorthand for methods and instance/class variables) are
visible to what other classes. Exceptions are handled in a completely
different method as well, with a method having an optional "rescue"
clause that gets invoked when an exception is raised, should repair
things, and then retries the method.

The key feature is "Design by Contract". Each method can have a set of
boolean expressions that must be true when the method is invoked, or
an exception is raised. Likewise, each method has a set of boolean
expressions that must be true when the function exits, or an exception
is raised. Finally, there's a set of expressions that are always true
when an externally-invoked method exits. These are the contracts, and
they make debugging wonderful. You can disable all those checks for
production code.

There are tools to display the the method headers, header comment, and
contracts (short form). There is a tool to display all methods a class
has, including inherited methods (flat form), and of course there's a
tool that displays the shortflat form.

If you want to do GUI programming on Windows, Linux or FreeBSD 5.x,
EiffelStudio is probably your best bet. It comes with a standard GUI
library, an IDE built on that library, and a reasonably
standards-compliant compiler and library. It hasn't yet drifted into
the parts of the language that are undergoing experimental changes.

    <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list