Python vs. Io

Daniel Ehrenberg LittleDanEhren at yahoo.com
Fri Jan 30 20:10:16 EST 2004


> Hey, if I wanted to to, I could add functions and all that that would
> make Python look like Lisp, or IO, or whatever.
> 
> But, why? If I wanted to write Lisp or Io, I'd use those.
> 
> Your example I'd write in Python as
> 
> for key, value in dict(x=1, y=2, z=3):
>     print '%s: %s\n" % (key, value)
> 
> I didn't have to write 43 lines of support code, and it's also two
> lines. I don't think "this isn't builtin" is a selling point -- you
> need a critical mass of builtins to make a language useful.

I know. Maybe in the future, it can be builtin, but it just shows how
flexible Io is. Io has its own version of a for loop (in addition to
being able to iterate directly over a dictionary or list) which in
some cases makes more sense than Python's. It's like this:

for(x, 1, 10, #goes through x with values 1-10
    write(x, "\n")
)

IMHO, this makes more sense than iterating over a list created just
for a specific loop. On my computer, Io's loops are faster than
Python's (probably because they are lazy).

>> [stuff about size of communities and bindings to stuff]
> 
> Yep. That's a *big* difference, I'd say.

But the community will grow larger in time. The Io community is bigger
than the Python community two years after Python was released
(although that's probably because it wasn't publicly released for two
years).
> 
> Can you elaborate a bit on why Python is inflexible? I find Python to
> be extremely flexible.

There's still a difference between types and classes in Python. Try
this in Python:

>>> x = object()
>>> x.number = 5

It raises an error. But the same thing in Io works (which is x :=
Object clone; x number := 5). To do it in Python, you have to do

>>> class goodObject(object): pass
>>> x = goodObject()
>>> x.number = 5

Also, Python has statements (as opposed to just expressions) even for
the simplest things like writing things to the command line. In Io,
flow control is in functions, which can be overwritten if you want to
change them. The Python philosophy is that if you allow this and other
flexible things to happen, you will have inconsistent code. If someone
asks on the Tutor mailing list how to change that, everybody responds
"Why would you want to do that?". While that's a valid viewpoint, it's
not the most flexible.
> 
> Python is 14 years old, and it's still working on global domination;
> Io's got some catching up to do :-)

I don't think world domination is a practical goal for either
language.

Daniel Ehrenberg



More information about the Python-list mailing list