Smalltalk and Python
Russell E. Owen
owen at astroNOJNK.washington.edu.invalid
Tue Dec 12 13:26:55 EST 2000
In article <3A2FFB8B.2030408 at zoologic.com>, Panu Viljamaa
<panu at zoologic.com> wrote:
>For the needs of a project, I'm looking into the language Python.
>
>It seems to have many attributes similar to Smalltalk in general such
>as dynamic typing, OO with the keyword 'self' and bytecodes. I used to
>think it was some kind of improved Perl. But by skimming a book I
>discovered the following quite impressive list of features:
>
>1. Dynamically typed, object oriented
>2. Simple syntax. Concise but readable code. Blocks (not
>block-closures) require no braces around them since they are indicated
>by indentation. Local variables need not be declared.
>3. Cross platform (with GUI), yet well integrated to Windows (COM,
>D-COM, DDLs, C++, TCP-IP, ODBC)
>4. 'Single dialect' . There's no Python-V, Python-VW, Python-MT,
>Python-X. There is just one Python with a single lineage of released
>versions..
>5. Web-enabled, http (server included), ftp, news, pop3 etc.
>6. Modules and namespaces. Default arguments.
>7. Innovative gimmicks such as indexing the last element of array with
>-1, the next to last by -2 etc.
>8. Reflective capabilities
>9. 'Business orientation', compared to say 'Squeak' (which I dare say
>feels a academic )
>10. FREE with a growing community of contributors
>
>So I was wondering if any of you Smalltalkers had tried Python and could
>compare the experience to working with Smalltalk .
I have used both and like both very much.
I think of Python as a very advanced scripting language. Much cleaner
and more regular than Perl, not as powerful as Smalltalk. It is a great
language and should appeal to many Smalltalkers for smaller tasks.
- It has an impressive collection of features, and they are well
implemented. Classes, exception handling, name spaces, collections,
reflexive programming and networking are all built in and all cleanly
implemented.
- It is free and runs on unix, Mac, PC
- It is well documented -- lots of good books out there.
- It tends to favor simplicity. Generally this is a good thing, though
occasionally it is overdone. But if you find Perl or C++ too cluttered
(as I do) then you definitely should give it a look.
- Nice function/method calling capabilities (positional parameters,
named parameters, defaults).
- Development is overseen by one person, Giudo VanRossum, whose goal is
to keep it a simple and usable language. (I very much wish Squeak had
this kind of driving force behind it; it's a wonderful language by a
brilliant team, but making a clean, usable language does not seem to be
their main focus.)
- It has "normal" procedural flow control structures, which is one of
the few things I miss in Smalltalk. That is my personal opinion, not an
attempt to anger anybody.
On the other hand, it is not as powerful, clean and regular as
smalltalk. Limitations include:
- The language is somewhat cluttered and irregular because it has
procedures, functions and methods. Hence arbitrary decisions had to be
made in some areas as to how to implement things, which can lead to some
hunting through the manuals.
- It has lambda functions, but getting late binding behavior is too
difficult (though doable).
- Only two scopes for variables: global (to a text file) or local (to a
function/method).
- There are no class methods, though they can be faked reasonably well
with modules.
- Basic built in types (e.g. integers, floats and lists) are not
classes, in the sense that they do not have class methods.
- No boolean class; uses C's icky everything-is-a-logical idea.
- I personally find not having to declare variables a negative (too
dangerous), though it's reasonable for simple scripting languages
- garbage collection is reference counted, though now enhanced in Python
2.0 so it can handle most cases of circular references
- Collection classes are good, but no match for Smalltalk. (But then
what language comes close to ST in this area?). It does have
dictionaries and lists, both of which are great. But that's about it. It
also has "tuple", a minor and annoying (to me) variant of a list that is
immutable (more or less) and so can be used as a key in dictionaries.
- Mediocre GUI support (a mediocre interface to Tk and a different
interface to wxWindows that isn't available on my platform--Mac)
- Mediocre IDE. I hope this will be improved over time, along with the
GUI support.
- Rather ugly implementation of "package" (multi-file modules). This is
one of the few areas where I find the implementation to be ugly and
hastily done; generally it's a very clean language.
- Like most languages, it uses text files to contain sets of code. I
really miss Smalltalk's more integrated approach.
It has a few minor annoyances, such as:
- One must explicity include the "self" parameter in method parameter
lists. This is pointless (from a user's perspective, I'm sure there are
implementation reasons) and much too easy to forget.
- Required colons at the beginning of sub-blocks are much too easy to
forget. But easily fixed.
Having said that, the language rather stands out because it doesn't have
more of these.
It also has some interesting oddities, such as:
- you can add a method or field to a class or instance of a class at any
time; interesting but dangerous
- Code indentation is significant. This tends to annoy folks at first,
but almost everybody comes to find it reasonable or good after a short
time. It shocked me at first, but I like it just fine.
It's an absolutely stunning language for free, and although not as fast
as Perl, still quite reasonable for basic work. Every Smalltalker who
needs a smaller-scale language for small projects should look at it, but
don't expect it to be a substitute for Smalltalk.
-- Russell
Having said that Python is not really a great substitute for Smalltalk,
I will admit that I am working on a reasonable scale GUI project in
Python because even though I adore ST I have doubts about ST's long-term
viability (cincom seems to be back to ParcPlace's old tricks on insane
pricing) and it'd be an incredibly hard sell to my management. I may be
setting up for failure, due to Python's mediocre GUI, but I'm having a
go at it.
More information about the Python-list
mailing list