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

Python and Java

8 views
Skip to first unread message

Gregory Trubetskoy

unread,
Jun 28, 1996, 3:00:00 AM6/28/96
to
I noticed there are some things that Python (www.python.org) and Java
have some things in common ( a lot of things ). Both compile to
cross-platform byte-code, both are object oriented. The import
statements look kinda similar, similar exception handling, static
initalizers etc.

Both have some things that neat but unique to each language, e.g. Python
is interpreted.

Does Python stand a possibility of competing with Java, is this in any
way the intention? On the other hand does anyone think that it'd be nice
if Java had an interpreter like Python does? How did they come about
being similar?

Any elaboration on any of the above points as well as anything else
reltaing to Java and Python would be highly appreciated.

--
---------------------------------------------------
Gregory Trubetskoy
gri...@mira.com
http://www.mira.com/home/grisha
---------------------------------------------------

Fredrik Lundh

unread,
Jun 29, 1996, 3:00:00 AM6/29/96
to

> Any elaboration on any of the above points as well as anything else
> reltaing to Java and Python would be highly appreciated.

Some good sources for such information are:

http://www.python.org/python/Comparisons.html
http://www.perl.com/perl/versus/index.html

> How did they come about being similar?

They were both designed by dutch programmers named "X van Y" :-)

Regards /F

Aaron Watters

unread,
Jun 30, 1996, 3:00:00 AM6/30/96
to

. wrote:

> another poster (attribution lost) wrote:
> Does Python stand a possibility of competing with Java, is this in any
> way the intention?

I think you got it backwards. Python mostly pre-dates java (and so do tcl and perl
and scheme and others), and I think java was inspired by its predecessors,
as was javascript.

Python and java can be regarded as competitors in the sense that many
things people are trying to do with java could be done (more easily imho)
with Python.

Python's most concrete advantage over java is that it can
be connected with other software and embedded in other applications extremely
easily. The former is very hard with java and the latter is explicitly
forbidden unless you join the ``java club'' and cough up $150k last time
I checked, for starters. There are a lot of other advantages to Python (meta
programming, first class everything...), but these are harder to quantify.

Java's most concrete advantage over Python is that
its basic interpreter is faster and supposedly will compile to native code
eventually, and that it runs under Navigator and MS Explorer.

> The Grail browser provides Python-based applets, and a Python-plugin
> for Netscape might appear (Perl and Tcl plugins already exist).

There is a Navigator plug-in for Python, which would need some work
in a professional release, but since I don't believe in plug-ins in this
domain I don't think it's all that interesting (except possibly for
in-house intranet type apps). It's quite an accomplishment nonetheless.
I wrote a NSAPI server-side plug-in, btw (in 2 days).

> However, with JIT and its support for static typing, Java can achieve
> C-like performance today, which is important since Java is being used
> increasingly for tasks in the browser like image processing,
> compression, encryption, and kinematics (for VRML). With Java, you
> can download and execute that code safely without native code
> extensions. To get anywhere close to that performance with Python,
> quite a bit of work still would have to be done on the Python language
> and compilers (it is probably possible, but hard).

I disagree. You just have to get your head out of the bits. Jim Hugunin
has an excellent matrix extension, which might well provide a great VRML
type functionality, since most 3d animation can be formulated in terms of
matrices -- and since the matrix extension is written in C it might even surpass
a java-only implementation in performance, for all I know. Look to the Alice
prototype at UVA for 3d applications of Python...

I regard the static typing thing as bizarre. For 99% of the things that
java is being used for now it just makes everything harder with almost no
benefit. Static typing is important in huge monolithic applications and
there are precious few examples of these in java... and I think the industry
as a whole is moving more towards smaller general purpose modules...

I see Python as a near perfect ``steering/glue'' language for integrating
multiple components and for implementing high level logic for
complex applications... I see java essentially as a stand-alone interpreter
designed to largely replace rather than supplement the rest of the software
world -- and this irritates me, frankly. -- Aaron Watters
===
``I've never met a more agreeable man... Everybody trusts him and nobody fears him.''
-- H.G.Wells, on Stalin.
(hmmm...)

Gregory Trubetskoy

unread,
Jun 30, 1996, 3:00:00 AM6/30/96
to

Aaron Watters wrote:

> I think you got it backwards. Python mostly pre-dates java (and so do tcl and perl
> and scheme and others), and I think java was inspired by its predecessors,
> as was javascript.

I dont' have the time to research this right now, but I was under the impression that
Python is a little newer than Java. Python has been around in the public domain
longer, but I don't know if it's been in the works as long as Java. (Same goes for
perl and Tcl, though I'm not sure why you even mention them, especially tcl) Could
someone clarify this by giving some more or less exact dates?

I also find it hard to believe that the development of Python somehow influenced Java
or the other way around. They both were most probably "inspired" (or were to be an
improvement to) C++, Smalltalk, Object Pascal (?) and Modula. Where does the
bytecode idea come from?

Anyway, I love them both. I've been using Python ever since I heard Guido present it
at a Washington DC Linux user group meeting a while ago. I have less experience with
Java but I like it so far too.

Andy Robinson

unread,
Jun 30, 1996, 3:00:00 AM6/30/96
to

In article: <31D6B5...@mira.com> Gregory Trubetskoy <gri...@mira.com> writes:
> I also find it hard to believe that the development of Python somehow influenced Java
> or the other way around.

Quote from "The Java Handbook", Patrick Naughton (one of the authors of
the language):

>"Bill Joy ... was often comparing Oak to more complicated and
> elegant languages like Python and Beta. He would often go on
>at length about how geat Oak would be if he oculd only add closures
>and continuations and parameterized types. While we all agree these
>are very cool language features, we were all kind of hoping to finish
>this language in our lifetimes...".

Oak became Java.

Although bits of it were in development from 1991 onwards, the above
comment (prior to fixing what was in and out of Java) refrred to spring
1994.
--
Andy Robinson an...@hps1.demon.co.uk
High Performance Sports Tel 0181-211-7000

My opinions in this forum ARE those of High Performance Sports,
because I'm the only one here who can switch on a PC...


Niels Möller

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

Gregory Trubetskoy <gri...@mira.com> writes:

> I also find it hard to believe that the development of Python

> somehow influenced Java or the other way around. They both were most
> probably "inspired" (or were to be an improvement to) C++,
> Smalltalk, Object Pascal (?) and Modula. Where does the bytecode
> idea come from?

Using bytecode is an almost ancient idea. It has been used in several
lisp-implementations (including GNU emacs), in at least one commercial
Pascal compiler, and for dozens of interpreted languages including
python, java, perl, µlpc, you name it (not all of them use
machine-independent bytecodes, though)

/Niels

Larry W. Virden

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

According to Gregory Trubetskoy <gri...@mira.com>:


:Aaron Watters wrote:
:
:> I think you got it backwards. Python mostly pre-dates java (and so do tcl and perl
:> and scheme and others), and I think java was inspired by its predecessors,

:I dont' have the time to research this right now, but I was under the impression that

:Python is a little newer than Java. Python has been around in the public domain
:longer, but I don't know if it's been in the works as long as Java. (Same goes for
:perl and Tcl, though I'm not sure why you even mention them, especially tcl) Could
:someone clarify this by giving some more or less exact dates?

These are my recollections

Tcl - designed in fall of 1987, implemented by spring of 1988, according
to Dr. Ousterhout's paper from December of 1988.
Perl - first version posted to comp.sources.unix in 1987.
Python - released in beta in 1994

--
:s Larry W. Virden INET: lvi...@cas.org
:s <URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
:s Unless explicitly stated to the contrary, nothing in this posting should
:s be construed as representing my employer's opinions.

Farshad Nayeri

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

> How did they come [Java and Python are] so similar?

Designs of Python and Jave were influenced by features in Modula-3
(and its predecessor, Modula-2+).

As far as I know, Modula-3 was the first language that made a
big point of combining exceptions, threads and garbage collection,
among other things. Modula-3 language and an implementation
incorporating these features has been available since 1989!

--
Farshad Nayeri
Critical Mass, Inc.
http://www.cmass.com/

Guido van Rossum

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

> Python - released in beta in 1994

Actually, it was first posted to usenet news in February 1991.

--Guido van Rossum (home page: http://www.python.org/~guido/)

Larry W. Virden

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

Okay doaky - I had gotten my date out of the change log from python
1.3. But it had listed 1.0 and I did`t think about there being an
undocumented 0.x release. Sorry.

Steven D. Majewski

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

On Mon, 1 Jul 1996, Larry W. Virden wrote:

>
> Okay doaky - I had gotten my date out of the change log from python
> 1.3. But it had listed 1.0 and I did`t think about there being an
> undocumented 0.x release. Sorry.
>

Guido's version numbers have been rather on the conservative side.
I ran into Python around v0.6 or so ( +/- 0.1 ) and it was already
quite well documented and pretty mature - the tutorial, ref. man
and library reference were already in existence, although a bit
shorter. It had been in use at CWI before it was released on the
net. Guido's first published paper on it was circa 1991 --
<http://www.python.org/~guido/Publications.html>

One reason it was already quite mature was that Guido had already
had some experience on a previous language project at CWI: ABC.
I would guess that Guido was not the lead on that project, because
Python does not show the typical "second system" bloat -- rather, he
seemed to have pared away some of the unessential features of ABC.

Python was in quite widespread use well before v1.0 and there was
a lot of discussion on the mailing list about various features and
misfeatures. As we got closer to 1.0, the versions numbers nearly
got asymptotic: 0.97, 0.98, 0.99 came out with quite a few changes.
The "golden" 1.0 was being saved for when a number of changes under
discussion would be 'frozen' and new mods would have a greater burden
of backwards compatability.

By 1994, it was in wide enough use that NIST sponsored the first
Python workshop ( I remember it well -- I printed up a bunch of
"Guido van Rossum's Python World Tour" T-shirts which I sold out of
the trunk of my car in NIST's parking lot. "world tour" was a
USA-centric joke -- Guido was making the rounds of several conferences
in the states, including the Usenix "very high level language" meeting,
where, I recall he said that he, Ousterhout, Larry Wall, et. al. --
all of the language *DEVELOPERS*, got along quite well and were all
interested in what ideas they could "steal" from each other -- it was
the language *FANS* who were all hoping for some sort of battle!


However -- I don't think there was any evidence that Python was an
influence on Java ( and I don't think anyone has claimed that. )
Java appears, at least on the surface, to be an attempt to redo C++
from scratch without the C compatability requirements, with perhaps
a bit of influence from Modula-3 ( which was a major influence on Python.)
A lot of similar ideas were in the air at the time -- look at Dylan
for example.


---| Steven D. Majewski (804-982-0831) <sd...@Virginia.EDU> |---
---| Computer Systems Engineer University of Virginia |---
---| Department of Molecular Physiology and Biological Physics |---
---| Box 449 Health Science Center Charlottesville,VA 22908 |---
[ "The grass is always greener, except at t=0" - Stan Kelly-Bootle ]


Daniel Larsson

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

And Simula was the first language that made a big point of
combining coroutines, inheritance and garbage collection, and
has been around since the sixties!

Coroutines are still rare in newer languages. I'm sure there
are more, but I know only of Modula-2 and BETA.
--
Daniel Larsson, ABB Industrial Systems AB

Steven D. Majewski

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

On Mon, 1 Jul 1996, Daniel Larsson wrote:

> Coroutines are still rare in newer languages. I'm sure there
> are more, but I know only of Modula-2 and BETA.

Icon makes a lot of use of coroutines - expecially a shorthand
subset which are ( according to Knuth, I believe ) actually
called semi-coroutines, and which Icon calls generators.

Generators are expressions which produce a (possibly infinite)
series of values, and they are implemented in Icon as semi-couroutines
that can be resumed to produce the next value in the series.
As I noted in a previous thread, the for-loop implementation
of Python was changed to make it easier to simulate this bahaviour
in Python. Breaking on End-of-Sequence, rather than explicitly
testing against the length makes it easier to use sequences with
an unknown or unevaluated length.
Icon, however, not only has a special syntax for initializing and
resuming coroutines, but it represents boolean tests rather differently
than most other languages. Python and some other languages allow
several data types to be equivalent to FALSE in a boolean context.
Python will consider None ( a special "nil" value ), 0, 0.0, (zero),
[] (the empty list), () (the empty tuple) as equivalent to false --
You can test ( x == None ) or ( x = [] ) if you require a specific
'false' value. In Icon, expressions either yield a value, or FAIL -
there is a special value for FAILURE, and this and the coroutine
expressions make it simple to express backtracking and pattern
matching expressions.
[ Icon is the successor to the string/pattern matching language
SNOBOL, which has it's own curious style of control flow. ]

Scott Schwartz

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to Daniel Larsson

Daniel Larsson <dlar...@sw.seisy.abb.se> writes:
| Coroutines are still rare in newer languages. I'm sure there
| are more, but I know only of Modula-2 and BETA.

Alef, used for systems programming in Plan 9.


Farshad Nayeri

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

> > > How did they come [Java and Python are] so similar?
> >
> > Designs of Python and Jave were influenced by features in Modula-3
> >
> > Modula-3 was the first language that made a
> > big point of combining exceptions, threads and garbage collection,
> >
> And Simula was the first language that made a big point of
> combining coroutines, inheritance and garbage collection, and

Right. Modula-3 designers clearly give credit to the Simula
design--see the Modula-3 specification--so their relationship
is well-known. I was trying to highlight the relationship of
Java and Python with Modula-3 which is not as well-known.

James C. Phillips

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

Daniel Larsson wrote:
> Coroutines are still rare in newer languages. I'm sure there
> are more, but I know only of Modula-2 and BETA.

For us non-computer-science-types, what is a coroutine?
I've never heard this term before.

-Jim

Aaron Watters

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to

I've never really used them, but as I recall they are like
subroutines, except that more than one coroutine can be
active at once and one coroutine can explicitly give control
to another or something... I personally don't understand why
you need programming language features to emulate this kind of
behaviour, but I'm probably ill informed and wrong.

Maybe some expert can tell me: is there anything you can do
with coroutines that can't be emulated directly with instances
of classes in Python or M3? Please educate... -- Aaron Watters
===
What the heck does that do?
Dunno. try commenting it out and see if it matters...
--overheard years ago in a Symbolics lab.

Daniel Larsson

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to

Aaron Watters wrote:
>
> James C. Phillips wrote:
> >
> > Daniel Larsson wrote:
> > > Coroutines are still rare in newer languages. I'm sure there
> > > are more, but I know only of Modula-2 and BETA.
> >
> > For us non-computer-science-types, what is a coroutine?
> > I've never heard this term before.
> >
> > -Jim
>
> I've never really used them, but as I recall they are like
> subroutines, except that more than one coroutine can be
> active at once and one coroutine can explicitly give control
> to another or something... I personally don't understand why
> you need programming language features to emulate this kind of
> behaviour, but I'm probably ill informed and wrong.
>
> Maybe some expert can tell me: is there anything you can do
> with coroutines that can't be emulated directly with instances
> of classes in Python or M3? Please educate... -- Aaron Watters

I would hardly describe myself as an expert in coroutines, but
anyway...

Suppose you have a binary tree class:

class Node:
def __init__(self, elem, left=None, right=None):
self.elem = elem
self.left, self.right = left, right


class BinTree:
def __init__(self):
self.root = None

def scan(self, node):
if node:
self.scan(node.left)
suspend node.elem # Suspend coroutine and return value
self.scan(node.right)

coroutine traverse(self):
self.scan(self.root)
return None # Terminate coroutine

A coroutine has its own stack. When a coroutine is called, the
caller's stack is saved, and the execution is moved to the callee's
stack. When a coroutine suspends, stacks are reversed again.

In the above case, each call to traverse will do one inorder step
in the tree and return the value at that node. Here's how to use
it to print the contents of a binary trees:

tree = BinTree()
... # init tree
while 1:
elem = tree.traverse()
if elem == None: break
print elem

This could certainly be implemented in Python without coroutines,
and I don't even know if this is even a good example of the
benefits of coroutines. Anyway, some problems where you would like
to use threads, might be easier to solve with coroutines, since
you don't have any synchronization problems (you have explicit
control of when switching between threads).

Hope I didn't confuse too many people out there...

Joel Neely

unread,
Jul 4, 1996, 3:00:00 AM7/4/96
to

Aaron Watters wrote:
>
> I've never really used them, but as I recall they are like
> subroutines, except that more than one coroutine can be
> active at once and one coroutine can explicitly give control
> to another or something...

I suspect coroutines passed out of fashion when concurrency was
recognized as a fundamental conceptual structure, on a par with
decisions and loops. Most of the canonical examples I can recall
would now be solved with pipes and multiple tasks/threads.

For instance:

Consider the problem of reading a text file of arbitrary line
length and re-wrapping the *words* into a fixed output line
length. An easy approach is via two cooperating processes --
a word-maker which reads lines and scans each line into its
component words, and a word-packer which appends words into
an output line until full, then writes it.

MAIN:
resume MAKER;
resume PACKER;

MAKER:
suspend;
foreach line in inputfile
for each word parsed from line
SharedWord = word;
resume PACKER;
SharedWord = "< eof >";
resume PACKER;

PACKER:
lineout = "";
resume MAKER;
while SharedWord != "< eof >"
if length(lineout) + length(SharedWord) + 1 < limit
lineout = lineout + " " + SharedWord;
else
write lineout to outputfile;
lineout = SharedWord;
resume MAKER;

Clearly a very 1960s-control-flow-mentality sort of concept, but at
least a primitive first step toward concurrency.

-jn-

Adrian Aylward

unread,
Jul 4, 1996, 3:00:00 AM7/4/96
to

Joel Neely wrote:
> I suspect coroutines passed out of fashion when concurrency was
> recognized as a fundamental conceptual structure, on a par with
> decisions and loops. Most of the canonical examples I can recall
> would now be solved with pipes and multiple tasks/threads.

Coroutines are essentially threads that cannot preempt one another
and only yield control by explict action. As such, they may be
cheaper to implement, and easier to use as they do not require
such careful attention to synchronisation.

They are useful for programming problems such as simulation or
filters.

David Ascher

unread,
Jul 4, 1996, 3:00:00 AM7/4/96
to

> Coroutines are essentially threads that cannot preempt one another
> and only yield control by explict action. As such, they may be
> cheaper to implement, and easier to use as they do not require
> such careful attention to synchronisation.
>
> They are useful for programming problems such as simulation or
> filters.

As someone who didn't know about them, I'm glad for this discussion.

Now, anyone want to add them to Python?

--da

Daniel Larsson

unread,
Jul 4, 1996, 3:00:00 AM7/4/96
to David Ascher

From Guido's paper on Python 1.4 And Beyond (presented at the
conference last month):

"Python 2.0
...
* The virtual machine will be rewritten to eliminate the C stack
(in most cases anyway). This will make it possible to implement
migratory Python programs, as well as portable coroutines."

Bernhard Fastenrath

unread,
Jul 6, 1996, 3:00:00 AM7/6/96
to

. (t...@best.com) wrote:
: In article <31D4A1...@mira.com> Gregory Trubetskoy <gri...@mira.com> writes:

<...>
: Does Python stand a possibility of competing with Java, is this in any
: way the intention?

<...>
: I think the proper choice isn't Java vs. Python, where each language
: has unique advantages and disadvantages, but Javascript vs. Python,
: and there, Python is uniformly better IMO.

I'd say it's rather Tcl/Tk vs. Python. Sun plans to use Java for low level
programming (lower than many people seem to realize, e.g. most of JavaOS).

IMHO Python would be a nice replacement for Tcl, not for Java in this page:
"The Relationship Between Tcl/Tk and Java"
http://www.sunlabs.com/research/tcl/java.html

--

_|_|_|_|_|_|_|_|_|_|_|_|_|_|_///_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_| Bernhard Fastenrath /// http://titan.cs.bonn.edu/~fasten/ : _|
_| fas...@cs.bonn.edu \\\/// Java Workbench 1.0 beta _|
_| fas...@shw.com \XX/ AmigaOS ext2 filesystem 0.5b, 0.3 _|
_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|

Hi, I'm not a signature virus. Why don't you just copy me into your signature?

0 new messages