What python can NOT do?

Tomasz Rola rtomek at ceti.com.pl
Sat Aug 29 05:37:34 CEST 2009


On Fri, 28 Aug 2009, qwe rty wrote:

> i know that an interpreted language like python can't be used to make
> an operating system or system drivers.
> 
> what else can NOT be done in python? what are the limitations of the
> language?

Oh, my. And now everybody points at you this Turing-completeness. The 
issue, in my opinion, is not that something cannot be done. The truth 
about Turing-completeness is, I would say, you can do whatever but 
sometimes you will not because it would be too ugly. My private list of 
things that when implemented in Python would be ugly to the point of 
calling it difficult:

1. AMB operator - my very favourite. In one sentence, either language 
allows one to do it easily or one would not want to do it (in an ugly 
way).

http://www.randomhacks.net/articles/2005/10/11/amb-operator

After quite some googling I was finally able to locate sample 
implementation, but I cannot say ATM how well it works and if it is 
practical enough to use it in any of my programs. If time permits, I will 
try it, hopefully.

http://www.c2.com/cgi/wiki?AmbInPython

2. Changing the language from the inside.

Everybody can change the interpreter, right? But how about doing some 
bigger, maybe even fundamental change to the language by means offered by 
the language itself?

Example:

If Python had no object system, or if I wanted to implement one in 
different way (say, I would like to experiment or I would not want to wait 
for a new release). In some languages that interest me now, it is possible 
and practical, more or less. So it can sometimes backfire - what OO system 
should I choose for my next Scheme program, etc. Because there are few of 
them :-), all (? - I believe) implemented as a code library. Just install 
it and off you go, now you have OO programming. Actually, I don't use OO 
all that much recently (maybe I feel disapointed a bit, or something).

Also, I have read (but not checked it myself) that for some time Common 
Lisp had it's now-official CLOS distributed and tested in a form of 
library. Say, have they adopted OO with single inheritance as a part of CL 
ANSI standard - I would still be able to have OO with multiple 
inheritance. I would just have to download and install CLOS. No change to 
interpreter or compiler. From their point of view, CLOS would be just 
another library.

http://en.wikipedia.org/wiki/Common_Lisp_Object_System

Judging by this code, introducing OO to the language is relatively easy:

http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-14.html

It is not possible to alter Python in a minor way, I think. Something 
simpler than OO, like a new keyword or structures:

http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-10.html
http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-11.html

Some readers could oppose the above by saying that Lisp's syntax is so 
primitive that it can be used to implement just any programming paradigm, 
so having it as a loadable code is not a big achievement. Well, it seems 
to me that Python has even simpler syntax or on par with Lisp family, 
so...

Some (perhaps other) readers could also say, that there is no need to 
extend Python. It already has sets and "yield" and... But some time ago it 
did not. As far as I can tell, it can be a bit too hard to go into 
"experimenting mode" with Python. Something like adding "yield" all but 
myself. It only takes few kilos of code for a working OO in another 
language, so how hard could such "yield" be? Well, in Python I probably 
wouldn't dare.

BTW I hope nobody's feeling have been hurt. This was meant to be 
informative, not offensive.

BTW2. As I said, these are _possible_ things (Turing complete language, 
and so on). But adding them would require some hard work and would produce 
ugly and/or fragile code, so I decided it could be easier to learn another 
language...

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.      **
** As the answer, master did "rm -rif" on the programmer's home    **
** directory. And then the C programmer became enlightened...      **
**                                                                 **
** Tomasz Rola          mailto:tomasz_rola at bigfoot.com             **



More information about the Python-list mailing list