[Tutor] Comparative code questions: Python vs. Rebol

Magnus Lycka magnus@thinkware.se
Wed Jan 15 05:38:01 2003


At 14:05 2003-01-14 -0900, Tim Johnson wrote:
>     I'm writing a column where I am comparing certain simple
>coding tasks in different programming languages. This time,
>I doing 'rebol' and 'python'.

Interesting. Will this be available to the public?

>Now here is a more complex example:
>Dynamically compose a series of functions such that
># python
>   print H3("This an html header of level 3")
>   >>> "<H3>This is an html header of level 3</H3>"

I don't know anything about Rebol, but in Python it's not
typical to dynamically compose functions, even if you can,
as others have shown. I think most python programmers,
maybe beginners in particular, prefer to see in their
code what functions they have, rather than to infer that
through another level of abstraction.

There are a number of python libraries that do what you
try to achieve here.

 >>> from HyperText.HTML import *
 >>> print H3('Thank you Andy Dustman!')

<H3>Thank you Andy Dustman!</H3>

 >>>

See http://dustman.net/andy/python/HyperText/

With this you will get a lot of other features as well.

I realize that this is not what you are after, that the
example is just there to demonstrate a language feature, but
available libraries is maybe a stronger point in Python than
its highly dynamic features.

Of course, it might be useful sometimes to show how an
idiom commonly used in one language can be used in another
language as well, but typically, if you look at Python
with a Rebol perspective, I assume Rebol will win.

Hopefully Rebol is the best Rebol. Similarly, if you
look at Rebol from a Python perspective, Rebol won't have
a chance. You can exchange Rebol and Python for any other
programming languages you like.

Make sure that you don't miss the best features of Python.
You will certainly find much more programming resources on
the net for python for instance. I did a little test with
google. Looking for either Rebol or Python together with
some other buzz words I got this many hits.

Buzz word       Python  Rebol
xml-rpc         55 000  2 500
oracle         250 000  2 700
web services   470 000  4 500
html         1 640 000 20 100

If popularity with Google was the only factor, Java or
Perl would obviously be even better, but the abundance of
third party libraries is certainly a useful feature of
Python. Maybe even more important is the standard library.
In fact, while most non-significant Perl program which isn't
completely reinventing the wheel will use third party module,
the python standard library is broad and good enough to aid
most programs with all they need.

How do you write a web server or xml-rpc server in Rebol? In
python a web server can be written in four lines of code or
something like that, by using the features in the standard
library. An xml-rpc server will be a little more...

Also, the possibility to work interactively with python, its
strong dynamic and introspective features are important.

Having worked a bit with Visual Basic for Excel 97 yesterday,
I must say that error handling, error messages and the system
with trace backs in python is a really strong point. I saw a
number of messages about unknown errors, and also several cases
where I had made obvious programming mistakes, that were just
silently ignored by Excel--I pushed my button and nothing
happened! In my almost seven years with Python, I haven't seen
as much strange behaviour as I did in an afternoon when I wrote
180 lines of Visual Basic code.

For more opinions about Python, have a look at:
http://www.thinkware.se/cgi-bin/thinki.cgi/PythonQuotes


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se