I'm not so interested in syntactical questions (eg
"this is how we construct a for loop in python and this is how we do it
java") I'm more interested in OO design patterns that Java supports (I
know that it supports interfaces for one thing) that are not readily
available in python, and other important differences. Is it possible
to define new classes, functions, methods in Java? Are there even unbound
functions in Java? From the little I remember of that half Java
chapter I read years ago you have to define classes for everything
even for a print statement? These are the kind of questions I have.
alex
--
Alex Polite
http://plusseven.com/gpg
Here it is:
Run away. Run fast. Keep running.
Warren
>
> I've been working a few years with python. I'm rather confident with
> basic OO design principles. Now some people that I consult for might
> be moving to Java. So I need to get up to speed with java. Are there
> any good documents out there for people with a python background
> coming to Java.
1) Give them Jython to revert to, and hope they'll only use Java for
performance critical things.
2) Thinking in Java by Bruce Eckel will answer all your questions
extensively. It's not an introduction, but it allows you to
work by looking up the answers to your questions, and it's free.
See www.mindview.net/Books .
> I'm not so interested in syntactical questions (eg
> "this is how we construct a for loop in python and this is how we do it
> java") I'm more interested in OO design patterns that Java supports (I
> know that it supports interfaces for one thing) that are not readily
> available in python, and other important differences. Is it possible
> to define new classes, functions, methods in Java? Are there even unbound
Yes, no, yes.
> functions in Java? From the little I remember of that half Java
No, but you can have methods bound to a class instead of to an object.
> chapter I read years ago you have to define classes for everything
> even for a print statement? These are the kind of questions I have.
You can use System.println() in java.
Have fun,
Ype
--
email at xs4all.nl
--
Rhymes
rhy...@NOSPAMmyself.com
I'll second Bruce Eckel's books (I've read the Java and C++ books),
they're my favorite.
>
> You can use System.println() in java.
System.out.println()
or has something changed in 1.4?
--
grayrest
http://grayrest.com/moz
> or has something changed in 1.4?
is still System.out.println()
--
Rhymes
rhy...@NOSPAMmyself.com
Think you'd better look for design patterns that Python supports and
that won't never be available in Java !-)
Laotseu
One thing you will find is that a lot of patterns that Python supports
trivially are quite cumbersome in Java.
For example, the "Visitor" design pattern is trivial in Python - in fact, it
is fundamental to the language:
for item in iterable:
item.visit() # or appropriate method
OR
[ item.visit() for item in iterable ]
OR
map(lambda item: item.visit(), iterable)
In java, each of these correspond to something like:
Iterator iter = iterable.iterator();
while (iter.hasNext())
{
ObjectSubclass item = (ObjectSubclass) iter.next();
item.visit();
}
Technically, the latter two correspond to:
Iterator iter = iterable.iterator();
List results = new ArrayList()
while (iter.hasNext())
{
ObjectSubclass item = (ObjectSubclass) iter.next();
results.append(item.visit());
}
There are plenty of other cases like this.
Tim Delaney
Jython is definitely slower than CPython and only recommended if
you're married to the Java platform and APIs. Python is already
cross-platform on its own and hence is a worthwhile alternative to
Java in many situations. For performance critical stuff, writing
your C extensions is the way to go. One would need to make the
Java/Jython tradeoff only if there's some functionality present in
the Java APIs you don't get with the Python library and are not
willing to code it in C for each platforms you wish to run on.
The Java APIs are vast indeed, but the libraries available for
CPython's are nothing to sneeze at either.