python vs ecmascript

Werner Schiendl ws-news at gmx.at
Fri Nov 16 19:07:37 CET 2001


Hi,

my last contact with JavaScript is quite a bit in the past and limited to
client-side web scripting.
So maybe I'm not completely up to date what JavaScript and its features is
concerned.

Anyway

"Peoter Veili" <peoter_veliki at hotmail.com> wrote in message
news:mailman.1005928823.20662.python-list at python.org...
> Anyone familiar with ECMAscript (JavaScript)?  How does it compare to
> Python? .....

Isn't Javascript pretty limited what the creating of objects in the language
itself concerns?

In Python you can create classes as to your desire, and starting with Python
2.2 you can even derive your classes from builtin types.

The powerful builtin types like Dictionary, List and Tuple are also worth
mentioning. Especially because they are intrinsic concepts of the language
and not awfully glued on like this happened with VB's Collection class for
example. Are there any similar concepts in JavaScript?

Another argument for Python is it's amazing community.

Some of Python's concepts may be strange at first view, but once you're
accustomed to Python's way of doing things, this will no longer annoy you.

Python does not coerce each and everything to a string for you. But on the
other hand, you can freely define, how your objects should behave when they
are converted to strings. AND you can define how operators like + and -
should work with your objects.

There are a lot of nice features in Python, which all to mention would be 1)
difficult because it's to easy to miss one and 2) would make this post into
a book.
I think you try to find out how to do things with Python rather than
translating concepts from other languages literally.

If you miss some feature, you will usually be able to find a Pythonic way to
do it (e. g. in this news-group).
But if you cannot live w/o curly braces as block delimiters, then Python
would be not your tool.

...
> also a bit annoyed at some things like having to wrap objects in a str()
> before
> printing, I don't see why this can't be automatic.  This thing about only
> having
> two scopes, local and global,  I don't see the logic.  Is this by design,
or
> is it
> simply a current limitation?  The book I have says it may change in the
> future.
...

1) You can define your own functions and methods to accept everything and
treat it properly if you like. So this is not really a limitation in a
technical sense. You can also use backticks ` instead of str() if this is
more convinent for you.

2) Python 2.1 introduced nested scopes as an optional feature, Python 2.2
will make it the standard behaviour. Search the Python docs for 'nested
scopes' to find out more.

hava fun (with Python)
Werner



  I studied ECMAscript last year, people have an aversion to it
> from doing web client programming, but it is a high-powered OO scripting
> language in its own right.  Clearly the one downside of ECMAscript vs
Python
> is that Python has been around longer and has a large set of existing
> libraries.
> Besides that is there any major advantage that Python has?  I am new to
> Python
> but already I am seeing some limitations that don't exist in ECMAscript.
I
> am
> also a bit annoyed at some things like having to wrap objects in a str()
> before
> printing, I don't see why this can't be automatic.  This thing about only
> having
> two scopes, local and global,  I don't see the logic.  Is this by design,
or
> is it
> simply a current limitation?  The book I have says it may change in the
> future.
>
>
>





More information about the Python-list mailing list