code is data

Ravi Teja webraviteja at gmail.com
Sat Jun 17 15:55:11 EDT 2006


Anton Vredegoor wrote:
> With the inclusion of ElementTree (an XML-parser) in Python25 and recent
> developments concerning JSON (a very Pythonesque but somewhat limited
> XML notation scheme, let's call it statically typed XML) Python seems to
> have reached a stage where it now seems to be possible to completely
> swallow lesser languages code, modify it, and spit out new source code
> targeting the original language the code was written in, or even make a
> translation to other languages.
>
> The idea is that we now have a fast parser (ElementTree) with a
> reasonable 'API' and a data type (XML or JSON) that can be used as an
> intermediate form to store parsing trees. Especially statically typed
> little languages seem to be very swallow-able. Maybe I will be able to
> reimplement GFABasic (my first love computer language, although not my
> first relationship) someday, just for fun.
>
> Then there are things like cTypes (calling functions from native DLL's)
> and PyPy (implementing Python in Python).
>
> All this taken together, to me it starts looking like we're now entering
> a territory that traditionally was exclusively in the Lisp domain.
>
> Yes, Python had eval and exec for a long time already, and metatypes and
> generators are having some strange unexplored possibilities too, but the
> day will come soon (and at last when PyPy is reaching execution speeds
> close to cPython) where Python will be able to swallow smaller
> languages, and finally it will be able to swallow its own tail, like
> Lisp but then more powerful (because of the widely used standard data
> types and the code exchange between languages that that makes possible).
>
> Your thoughts please.

I don't share your optimism at all. Most of the things you mentioned
have existed for long. Just because some of them are now included in
the standard library isn't going to change things drastically.
Installing them earlier was never hard at all.

People like to call everything with the lightest semblence, a DSL. That
gives the feel that the language is more powerful. Ruby people do it
all the time. Python cannot be called a DSL language until, creating
them is a natural language feature (like Lisp). And that does not seem
to be happening anytime soon. Boo for example allows you to write new
constructs with it's AST library. It still cannot be called a DSL
"language".

People have however written various language interpreters (Scheme,
Forth and yes, even Basic) in Python, just for kicks. Still does not
make it a DSL language anymore than it makes C a DSL language.

At present, the closest thing to writing a DSL in Python is Logix
http://livelogix.net/logix/
Too bad though, the project is defunct and there has never been enough
interest in it.

Personally, I would like to see macros in Python (actually Logix
succeeding is good enough). But I am no language designer and the
community has no interest in it. When I absolutely need macros, I will
go elsewhere.




More information about the Python-list mailing list