Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Think Python: Java Comparison

 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Allen good luck with the book.

I read the free part of the book on Amazon and was intrigued how you started writing a college book on Java and it turned into Python, I am assuming non-polymorphically

But this does lead me onto several question about Python which I know absolutely nothing about.

Is Python based on Java or a subset of it?

Does the easier learning mean Python is inferior to Java in its capabilities.

Is knowing Java detrimental to learning Python as I saw you teach Python to new students.

Thank Kevin.
 
Allen Downey
Author
Greenhorn
Posts: 25
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin,

Lots of interesting questions. Python is not based on Java in any way (that I know of). According to the Wikipedia pages, Python was released before Java was designed, so it might be the other way around.

The semantics of the two languages are very similar, so it is easy to go from one to the other, but I think the similarities are due to convergent evolution, not common ancestry.

Since Python is easy to learn, you might suspect that there are limitations that come with simplicity, but I don't think that's true. Python scales up nicely to large projects and comes with industrial-grade libraries. The only limitation I can think of is that, because it is dynamically-typed, you get less error-detection at compile time. So some errors that would be caught at compile-time in Java would instead not be caught until run-time in Python.

And you asked if knowing Java makes it harder to learn Python. Definitely not. I see students make that transition all the time, and it is pretty much seamless.

Allen
 
Joe Ess
Bartender
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin Florish wrote:
Is Python based on Java or a subset of it?


No, but there is Jython, which is an implementation of Python that runs on a JVM. This allows you to do cool things like script a Java program using Python.

Kevin Florish wrote:Does the easier learning mean Python is inferior to Java in its capabilities.


I'm hard pressed to think of functionality in the Standard Edition of Java that isn't in the Python API.

Kevin Florish wrote:Is knowing Java detrimental to learning Python


I don't think so. Python is different, but the same principles of object-oriented programming can apply to Python.
 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answers guys.

Python certainly looks like something I might take a gander at.

Cheers Kevin.
 
Stephen Paulsen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:
No, but there is Jython, which is an implementation of Python that runs on a JVM. This allows you to do cool things like script a Java program using Python.


Another nice thing about Jython is that you can not only script a Java program, you can write a program that is a combination of Python and Java - maybe to re-use classes, or write your UI pieces in Java/Swing while rapidly coding the connections in Python.

I've also used Jython to load up some Java classes to unit test them or experiment interactively with them. Being able to interactively call methods without having to write a test "main" or re-run a test program is pretty cool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic