473,698 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python vs. Io

Io (www.iolanguage.com) is a new programming language that's purely
object-oriented (but with prototypes), has a powerful concurrency
mechanism via actors, and uses an extremely flexible syntax because
all code is a modifiable message tree. Like Python, it is dynamically
typed, has a very clean syntax, produces short code, and is
excruciatingly slow (on the same level as eachother). Io has a unique
syntax combining Lisp's idea of functions for flow control with
traditional function syntax and smalltalk-like syntax to get slots of
objects. Io has no keywords and everything, even multiple lines of
code, can be used as an expression. Even as a beginner to Io, I was
able to write something in just 43 lines to let you do something like
this (and more) in Io:

each((key, value) in map(x=1, y=2, z=3),
write(key, ": ", value, "\n")
)

Neither the each function nor the map function were built in (Io has
other mechanisms for that kind of thing, but they are less efficient).
Can anyone show me how to so much as alias "for" to "each" in Python
or allow block syntax at all without hacking the C source code?

Io doesn't use __methods_with_ this_annoying_s yntax__ because nothing
is supposed to be for internal use only and there are only about three
functions that would cause a problem if overridden.

For embedding, Io doesn't have to use Py_ALL_CAPS, instead it just
uses IoCamelCase, which looks much better. Interfaces to C are much
more object oriented.

Many users of Io (myself included) have switched over from Python for
these reasons.

I guess there are still the obvious advantages of Python over Io,
including
*large community
*more bindings to stuff
*strict coding conventions
*inflexible so everything is the same
*no need to close blocks
But unless there are other problems, the first two go away soon
(considering that Io was first created just two years ago). The last
three are somewhat trivial and may even be to Io's advantage.

Daniel Ehrenberg
Jul 18 '05 #1
20 2446

"Daniel Ehrenberg" <Li************ @yahoo.com> wrote in message
news:71******** *************** **@posting.goog le.com...
Can anyone show me how to so much as alias "for" to "each" in Python
Without getting into the language wars, I think what you're looking
for is called the Visitor Pattern (Design Patterns: GOF). It's actually
trivial to implement as long as you're not looking for built-in support.

Something like this works quite well in any object where you want
to implement a visitor over a collection:

class aCollection:
def visit(self, instance):
for x in self._collectio n:
instance.visito r(x)
return instance.result ()

The final call is a little more than the bare visitor pattern, but it
allows the visitor instance to pass back a result so you can use
it in expressions.

A visitor then looks like this:

class fubar:
def __init__(self):
self.whatever = 0
def visitor(self, value):
self.whatever += value
def result(self):
return self.whatever

and you use it like this:

ohWow = aCollection.vis it(fubar())

Unlike a block in, for example, Ruby, a visitor instance
can be pre-initialized, it can have multiple methods and
it can persist after being passed against the collection.

Of course, you can use more complex data structures as well,
see the compiler stuff for examples of the visitor pattern used
over the Python Abstract Syntax Tree.

The visitor pattern is also very useful for file system
navigation; I use it consistently.

John Roth

Daniel Ehrenberg

Jul 18 '05 #2
John Roth wrote:
"Daniel Ehrenberg" <Li************ @yahoo.com> wrote in message
news:71******** *************** **@posting.goog le.com...

Can anyone show me how to so much as alias "for" to "each" in Python

Without getting into the language wars, I think what you're looking
for is called the Visitor Pattern (Design Patterns: GOF). It's actually
trivial to implement as long as you're not looking for built-in support.


I think Daniel's example is a little bit more complicated than that. It
resembles more closly the lisp-ish macros that were discussed to death a
while ago.

Note that in his code:
each((key, value) in map(x=1, y=2, z=3),
write(key, ": ", value, "\n")
)

key and value are variable names that get used inside the function call.

Here is my pythonic(?) version, however it requries a lambda to bind the
variable names.

def map(**kw):
return kw.items()

def each(seq, func):
for v in seq:
apply(func, v)

from sys import stdout
write = stdout.write

each(map(x=1,y= 2,z=3),
lambda key, value: write("%s: %s\n"%(key, value)))

Brian

Jul 18 '05 #3
At some point, Li************@ yahoo.com (Daniel Ehrenberg) wrote:
Io (www.iolanguage.com) is a new programming language that's purely
object-oriented (but with prototypes), has a powerful concurrency
mechanism via actors, and uses an extremely flexible syntax because
all code is a modifiable message tree. Like Python, it is dynamically
typed, has a very clean syntax, produces short code, and is
excruciatingly slow (on the same level as eachother). Io has a unique
syntax combining Lisp's idea of functions for flow control with
traditional function syntax and smalltalk-like syntax to get slots of
objects. Io has no keywords and everything, even multiple lines of
code, can be used as an expression. Even as a beginner to Io, I was
able to write something in just 43 lines to let you do something like
this (and more) in Io:

each((key, value) in map(x=1, y=2, z=3),
write(key, ": ", value, "\n")
)

Neither the each function nor the map function were built in (Io has
other mechanisms for that kind of thing, but they are less efficient).
Can anyone show me how to so much as alias "for" to "each" in Python
or allow block syntax at all without hacking the C source code?
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.
Io doesn't use __methods_with_ this_annoying_s yntax__ because nothing
is supposed to be for internal use only and there are only about three
functions that would cause a problem if overridden. For embedding, Io doesn't have to use Py_ALL_CAPS, instead it just
uses IoCamelCase, which looks much better. Interfaces to C are much
more object oriented.
Ok, these two points are window-dressing: minor spelling and
punctuation issues (which seems to be what most language wars are about).

Heck, use boost::python for C++ interfaces; those function names are
even shorter. Or use pyrex to generate wrappers, writing them in a
Pythonesque language.
Many users of Io (myself included) have switched over from Python for
these reasons.

I guess there are still the obvious advantages of Python over Io,
including
*large community
*more bindings to stuff
Yep. That's a *big* difference, I'd say.
*strict coding conventions
*inflexible so everything is the same
Can you elaborate a bit on why Python is inflexible? I find Python to
be extremely flexible.
*no need to close blocks
But unless there are other problems, the first two go away soon
(considering that Io was first created just two years ago). The last
three are somewhat trivial and may even be to Io's advantage.


Python is 14 years old, and it's still working on global domination;
Io's got some catching up to do :-)

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)phy sics(dot)mcmast er(dot)ca
Jul 18 '05 #4
On Thu, 29 Jan 2004 17:21:19 -0500, co**********@ph ysics.mcmaster. ca
(David M. Cooke) wrote:
At some point, Li************@ yahoo.com (Daniel Ehrenberg) wrote:
[snip-a-lot]
For embedding, Io doesn't have to use Py_ALL_CAPS, instead it just
uses IoCamelCase, which looks much better. Interfaces to C are much
more object oriented.
Ok, these two points are window-dressing: minor spelling and
punctuation issues (which seems to be what most language wars are about).

Heck, use boost::python for C++ interfaces; those function names are
even shorter. Or use pyrex to generate wrappers, writing them in a
Pythonesque language.
Many users of Io (myself included) have switched over from Python for
these reasons.

I guess there are still the obvious advantages of Python over Io,
including
*large community
*more bindings to stuff


Yep. That's a *big* difference, I'd say.


Using any language (other than a Lisp) which is sufficiently powerful
mostly comes down to personal preference regarding syntax. Library and
community support will of course grow for new languages if enough
people find it 'fits their minds' better than anything previously
available.
*strict coding conventions
*inflexible so everything is the same


Can you elaborate a bit on why Python is inflexible? I find Python to
be extremely flexible.


If inflexibility means not being able to arbitrarily change the
syntax, then I'm all for it, because it does help consistency and
readability, which I like very much in my programs, especially when
not working on them alone... Python seems to have found a good middle
ground between strictness and dynamism.
If I wanted a 'flexible' language, I'd use Lisp, or Forth.
--
Christopher
Jul 18 '05 #5
Daniel Ehrenberg wrote:
Neither the each function nor the map function were built in (Io has
other mechanisms for that kind of thing, but they are less efficient).
Can anyone show me how to so much as alias "for" to "each" in Python
or allow block syntax at all without hacking the C source code?
No, you cannot introduce new special forms (i.e., statement syntax) in
Python without modifying the Python interpreter itself.

There are two major camps in language design. One says that you should
be able to modify the language itself to your will, and the other says
that this gets rapidly confusing and you shouldn't. They're simply
different camps, and the two camps won't agree. Furthermore, the
ability to convert a language from the second camp to the first is not
without difficulty; such things usually have to be designed into the
language from the scratch, or you end up with a very complicated process
of creating hygienic macros.

This is a situation where Io is in the first camp and Python is in the
second. They simply don't have equivalent goals; Python emphasizes
transparency and readability more than customizability and flexibility,
whereas Io does the opposite.
Io doesn't use __methods_with_ this_annoying_s yntax__ because nothing
is supposed to be for internal use only and there are only about three
functions that would cause a problem if overridden.

For embedding, Io doesn't have to use Py_ALL_CAPS, instead it just
uses IoCamelCase, which looks much better. Interfaces to C are much
more object oriented.


These are really stylistic objections, as are the other objections you
list below. That's completely fine, of course; you should choose a
language that jives with your personal sense of language style. But
language designers need to make decisions, and those decisions are
necessarily going to eliminate some styles of programming, while
emphasizing others.

You're in a situation where it sounds like Io jives with your sense of
style more than Python. That's perfectly fine, and I know from my own
research that Io is a neat little language (though I haven't really used
it for anything substantial yet). But you can't expect other languages
to bend to your personal will and personal sense of style, particularly
when it means necessarily violating someone else's corresponding senses.

Io and Python have quite different fundamental approaches to language
design, and so it's not surprising that there are going to be
irreconcilable differences.

--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ The only completely consistent people are the dead.
-- Aldous Huxley
Jul 18 '05 #6
Daniel Ehrenberg wrote:
Io (www.iolanguage.com) is a new programming language that's purely
object-oriented (but with prototypes), has a powerful concurrency
mechanism via actors, and uses an extremely flexible syntax because
all code is a modifiable message tree.


I long to live in a world where Python is considered a crufty incumbent
legacy language that is forced on unwilling programmers by Pointy Haired
Bosses. First, it would mean that Python has vanquished languages that
programmers like less. Second, it would mean that the up-and-coming
languages are so unbelievably cool and elegant that they make Python
look like a lumbering dinosaur.

Thanks for reminding me that that that day was once unfathomably far in
the future and now seems almost around the corner!

But when I look closer at IO it seems to me that the day is not as near
as I hope. If you wish to hasten I urge you to:

* finish the IO tutorial
* distribute windows binaries of IO
* make IO compilers to C and Java available
* make bindings to popular windowing toolkits
* make bindings to Java, .NET, COM, SOAP, XML-RPC etc.
* use IO in a production context so that the rest of us can have faith
in its stability
* implement MySQL and Oracle bindings
* publish some books on IO
* point me to some documentation on how to launch and kill processes in IO

If this were all done tomorrow I might be tempted to jump over to IO but
I would be amazed if it were all done even two years from now.

Also, an observation: IO's syntactic simplicity looks to me to be both a
blessing and a curse.

Paul Prescod

Jul 18 '05 #7
As other posts have indicated, this is not the io-user-list. While
you probably have good, purely academic intentions with your post,
this is not the correct forum. Create an io-vs-python list somewhere
and I'm sure you'll get a few subscribers. :)

--

Jonathan Daugherty
http://www.cprogrammer.org

"It's a book about a Spanish guy called Manual, you should read it."
-- Dilbert

Jul 18 '05 #8
Daniel Ehrenberg wrote:
Perhaps it isn't more flexible. On the other hand, it does allow anyone
to read your code and know that there isn't any magical syntax that is
usable on one Python x.y installation, that isn't on another.


As mentioned by Sean Ross, I was talking about Python x.y compatibility
with other copies of version x.y. With the way you describe IO, it
encourages people to customize flow control and syntax. Such
customization does not necessarily increase readability, usability, or
write-once-run-anywhere with IO version u.v. It may also fragment the
language in the long run into different camps; those that like the slim
version, and those that like a version with every modification they can
find.

- Josiah
Jul 18 '05 #9
Paul Prescod wrote:

....snip...
First, if I had invented Python I would not have bothered to buck the
trend of using curly braces. Hardly anyone chooses Python because of
that feature and some are turned off by it.

....snip...
Not that this invalidates your point, as I still fall into the category of
'hardly anyone'; but, the indentation-identified block is precisely the
reason I first tried Python. Having used Occam for many years, I was very
pleased to find a language that recognized the superiority of that style.
--Andy
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.