Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java introduction for pythonistas

1 view
Skip to first unread message

Alex Polite

unread,
Jan 27, 2003, 6:25:25 AM1/27/03
to

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.

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

WP

unread,
Jan 27, 2003, 10:08:42 AM1/27/03
to
Alex Polite wrote:
> 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.
>

Here it is:
Run away. Run fast. Keep running.

Warren

Ype Kingma

unread,
Jan 27, 2003, 11:34:30 AM1/27/03
to
Alex Polite wrote:

>
> 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

unread,
Jan 27, 2003, 2:34:20 PM1/27/03
to

Do you know Jython? It allows you to code with your so-loved
Python style and use all the features of both languages: Python and Java.
Take a look!

www.jython.org

--
Rhymes
rhy...@NOSPAMmyself.com


grayrest

unread,
Jan 27, 2003, 9:26:19 PM1/27/03
to
Ype Kingma wrote:
> 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'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

Rhymes

unread,
Jan 27, 2003, 10:31:24 PM1/27/03
to
On Mon, 27 Jan 2003 21:26:19 -0500, grayrest wrote:

> or has something changed in 1.4?

is still System.out.println()

--
Rhymes
rhy...@NOSPAMmyself.com


laotseu

unread,
Jan 28, 2003, 10:21:04 PM1/28/03
to
Alex Polite wrote:
> 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.
>
> 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,

Think you'd better look for design patterns that Python supports and
that won't never be available in Java !-)

Laotseu

Delaney, Timothy

unread,
Jan 28, 2003, 7:05:03 PM1/28/03
to
> From: Alex Polite [mailto:m...@plusseven.com]

>
> 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

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

Jon Perez

unread,
Jan 28, 2003, 11:43:39 PM1/28/03
to
"Ype Kingma" <yki...@accessforall.nl> wrote in message news:3e3565f3$0$145$e4fe...@dreader7.news.xs4all.nl...

> Alex Polite wrote:
>
> >
> > 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.

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.


0 new messages