473,769 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for resources for making the jump from Java to Python easier and more productive

I'm just starting out with python, after having a long history with
Java. I was wondering if there were any resources or tips from anyone
out there in Python-land that can help me make the transition as
successfully as possible? Perhaps you've made the transition yourself
or just have experience with folks who have made the transition.

I'm looking for the common types of mistakes that say a Java/C# or
even C++ developer may commonly make. More examples like those
highlighted here http://dirtsimple.org/2004/12/python-is-not-java.html
would be particularly useful. I've already made the static class
method mistake, and been thoroughly confused by packages and
imports/froms and extremely frustrated with attempting to call super
constructors etc. I'm getting the hang of passing around functions
(ala the command pattern), customising the operators and extending
inbuilt classes. All of these concepts I've done before so there
nothing really great and wonderful about using them in another
language. Some of the really powerful ideas of python (eg as suggested
in the link) about creating one function containing a template function
that can cater to all possible implementations sounds really cool and
alien to me at the same time. That's the sort of stuff I'm
interested in.

At this point in time I'd say my python code is more coding Java in
python than doing it in a pythonic way. Perhaps there some good/great
examples of Python scripts or projects that I could look at to get
inspired or learn pythonic implementation ideas? I just don't know of
any. Are there python specific equivalents to the common Patterns,
Anti-Patterns and Refactoring books that are so prevalent as
reccomended reading in C++ and Java? If so what?

Given the rising popularity of Python these days there has got to be a
few of you out there who've made the transition successfully and have
some pearls-of-wisdom to share that you'd wished you'd known about
earlier.

Thanks
Todd

Apr 22 '06 #1
17 1992
In article <11************ **********@u72g 2000cwu.googleg roups.com>,
"ToddLMorga n" <To*********@gm ail.com> wrote:
I'm looking for the common types of mistakes that say a Java/C# or
even C++ developer may commonly make.


Using subclassing when you don't have to. For instance, you might have a
Java method which takes an argument of type java.io.OutputS tream to
which it writes. You might translate this to a Python method to which
you are careful to only pass instances of subclasses of file objects.
But in fact there is no necessity for this: you are free to pass any
object which has appropriate members.

I suppose this is an instance of the more general rule: "using OO when
you don't have to".
Apr 22 '06 #2
In article <11************ **********@u72g 2000cwu.googleg roups.com>,
"ToddLMorga n" <To*********@gm ail.com> wrote:
Are there python specific equivalents to the common Patterns,
Anti-Patterns and Refactoring books that are so prevalent as
reccomended reading in C++ and Java?


I don't think they exist. Such books are targeted more towards
development in a corporate environment, where every proposal has to go
through multiple layers of management, and nothing is ever done by
individuals working alone, always by "teams" working on separate parts
of the project. And also where the end-users don't really get much say
in how things are supposed to work. It's only in such a high-overhead,
top-down, cover-your-ass environment that such books are looked on as
being at all useful. Possibly on the grounds that nobody ever got fired
for buying them.

I'd say languages like Python and Perl are the absolute antithesis of
this sort of development culture.
Apr 22 '06 #3
ToddLMorgan wrote:
I'm just starting out with python, after having a long history with
Java. I was wondering if there were any resources or tips from anyone
out there in Python-land that can help me make the transition as
successfully as possible? Perhaps you've made the transition yourself
or just have experience with folks who have made the transition.


Some time ago I had to learn a bit of Java in order to be able to write
some signed jython browser applets that I could use while working at a
highly restricted public library computer. So I guess I was coming from
the opposite direction :-) Anyway I wondered why (and how!) very small
jython scripts could replace large blocks of java code.

Maybe looking at it from a jython perspective will be educational for
you. I think it would be a lot of fun realizing how much java code can
actually be 'automatically' generated or filled in by jython traversing
its class system.

Also I'm hoping it would produce an opportunity for an advanced java
coder to write some cool signed java applet in jython that would have
the look and feel of idle.py for python but that would run from a
webbrowser.

I know it can be done because I did write some experimental but still
already very functional things like a jython console webbrowser applet,
a websucker.py running from within a browser, and I hacked some other
jython editor-console (eclipse is good for such things) to add some
functionality and do my own signing and library selection.

Don't ask for my code yet though, it's nowhere near presentable. Anyway,
since then I found a job that gives me access to less locked down
computers which is also fun.

Anton

Apr 22 '06 #4

http://dirtsimple.org/2004/12/python-is-not-java.html
http://dirtsimple.org/2004/12/java-i...on-either.html
http://dirtsimple.org/2004/12/python...-not-java.html

This link seems to be down at the moment.
http://naeblis.cx/rtomayko/2004/12/1...c-method-thing

The above articles were really helped me understand the python way of doining
things. In particular they mention language features that may be named the
same and do similar things, but would be used for totally different reasons in
the two languages.

I hope you find them as helpful as I did.

-Chris
On Sat, Apr 22, 2006 at 12:40:51AM -0700, ToddLMorgan wrote:
I'm just starting out with python, after having a long history with
Java. I was wondering if there were any resources or tips from anyone
out there in Python-land that can help me make the transition as
successfully as possible? Perhaps you've made the transition yourself
or just have experience with folks who have made the transition.

I'm looking for the common types of mistakes that say a Java/C# or
even C++ developer may commonly make. More examples like those
highlighted here http://dirtsimple.org/2004/12/python-is-not-java.html
would be particularly useful. I've already made the static class
method mistake, and been thoroughly confused by packages and
imports/froms and extremely frustrated with attempting to call super
constructors etc. I'm getting the hang of passing around functions
(ala the command pattern), customising the operators and extending
inbuilt classes. All of these concepts I've done before so there
nothing really great and wonderful about using them in another
language. Some of the really powerful ideas of python (eg as suggested
in the link) about creating one function containing a template function
that can cater to all possible implementations sounds really cool and
alien to me at the same time. That's the sort of stuff I'm
interested in.

At this point in time I'd say my python code is more coding Java in
python than doing it in a pythonic way. Perhaps there some good/great
examples of Python scripts or projects that I could look at to get
inspired or learn pythonic implementation ideas? I just don't know of
any. Are there python specific equivalents to the common Patterns,
Anti-Patterns and Refactoring books that are so prevalent as
reccomended reading in C++ and Java? If so what?

Given the rising popularity of Python these days there has got to be a
few of you out there who've made the transition successfully and have
some pearls-of-wisdom to share that you'd wished you'd known about
earlier.

Thanks
Todd

--
http://mail.python.org/mailman/listinfo/python-list

Apr 22 '06 #5
Ant
Take a look at the newgroup archives over the last week or two - there
seem to have been a glut of people coming from Java to Python and
asking the same sort of questions. There were some links to a bunch of
Python 'gotcha' pages which will be useful.

For my part, I came from Java to Python, and found that it was useful
to do a load of small scripts in the simplest way possible, or in as
many different ways possible. For example, trying a script involving
creating a new iterable object from a list using for loops, list
comprehensions, generators or functional built-ins (such as map()). The
clearest method usually seems to be considered the most pythonic.

A couple of sites to practice against are:
http://www.pythonchallenge.com/
http://mathschallenge.net/

They give a good set of problems which will work various aspects of
Python that aren't familiar to Java guys, and also break the mindset
that everything has to be done in classes.

I'm still making the transition of course ;-)

Apr 22 '06 #6
I've actually managed to find some other links by backtracking through
some of the links that you provided.

The most comprehensive so far is this one
http://www.razorvine.net/python/Pyth...avaProgrammers and a summary
version (on the same site)
http://www.razorvine.net/python/PythonComparedToJava

The site owner (Irmen de Jong) appears to be be compiling a decent
migration path from Java to Python on a Moin-Moin Wiki so perhaps he'll
be harvesting more useful information from here and other places in the
near future as the pages only appears a few days ago.

There was also a follow up to
http://naeblis.cx/rtomayko/2004/12/1...c-method-thing with
http://naeblis.cx/rtomayko/2005/01/2...setters-fuxors

Hopefully this will prove helpful to some other folks :- )

I'm still working my way up to the practice sites (python and math
challenge) ... I want to do a bit more reading first :- )

ciao & thanks
Todd

Apr 23 '06 #7
Lawrence D'Oliveiro wrote:
In article <11************ **********@u72g 2000cwu.googleg roups.com>,
"ToddLMorga n" <To*********@gm ail.com> wrote:

I'm looking for the common types of mistakes that say a Java/C# or
even C++ developer may commonly make.

Using subclassing when you don't have to. For instance, you might have a
Java method which takes an argument of type java.io.OutputS tream to
which it writes. You might translate this to a Python method to which
you are careful to only pass instances of subclasses of file objects.
But in fact there is no necessity for this: you are free to pass any
object which has appropriate members.

I suppose this is an instance of the more general rule: "using OO when
you don't have to".


Lawrence, I'm afraid you're confusing OO with "statically-typed
class-based". FWIW, dynamic typing is part of OO since Smalltalk.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Apr 24 '06 #8

Ant wrote:
Take a look at the newgroup archives over the last week or two - there
seem to have been a glut of people coming from Java to Python and
asking the same sort of questions. There were some links to a bunch of
Python 'gotcha' pages which will be useful.


Here's a few gotchas which i would like to drop into the python wiki,
but I couldn't find an appropriate place. Maybe the Intermediate
Conundrums page?
Anyway, if OP take the time to flip through these, it'll speed the
learning, I hope.

http://www.ferg.org/projects/python_gotchas.html
http://zephyrfalcon.org/labs/python_pitfalls.html
http://zephyrfalcon.org/labs/beginners_mistakes.html
http://www.python.org/doc/faq/
http://wiki.python.org/moin/Intermediate_Conundrums

http://diveintopython.org/appendix/abstracts.html
http://diveintopython.org/appendix/tips.html

http://blog.ianbicking.org/my-python-4k.html

http://www.onlamp.com/pub/a/python/2...rn_python.html
http://www.norvig.com/python-iaq.html
http://www.faqts.com/knowledge_base/index.phtml/fid/245

http://amk.ca/python/writing/warts
http://c2.com/cgi/wiki?PythonProblems

Apr 24 '06 #9
Lawrence D'Oliveiro <ld*@geek-central.gen.new _zealand> writes:
In article <11************ **********@u72g 2000cwu.googleg roups.com>,
"ToddLMorga n" <To*********@gm ail.com> wrote:
Are there python specific equivalents to the common Patterns,
Anti-Patterns and Refactoring books that are so prevalent as
reccomended reading in C++ and Java?


I don't think they exist. Such books are targeted more towards
development in a corporate environment, where every proposal has to go
through multiple layers of management, and nothing is ever done by
individuals working alone, always by "teams" working on separate parts
of the project. And also where the end-users don't really get much say
in how things are supposed to work. It's only in such a high-overhead,
top-down, cover-your-ass environment that such books are looked on as
being at all useful. Possibly on the grounds that nobody ever got fired
for buying them.

I'd say languages like Python and Perl are the absolute antithesis of
this sort of development culture.


On "antithesis " comment:

Python can be used for Agile Programming, with the end user there at
the monitor. But it can also be used for heavy duty development
regimens with data models, specifications, development teams working
multiple shifts or working worldwide, separate test-and-release teams,
etc.

On response to the OP:

The most important thing you bring to the table is knowledge of data
formats, algorithms, OO programming, and test-driven design. E.g.,
XML, HTML, LDAP, SQL, pipes, stacks, queues, threads, dictionaries,
lexers, parsers, regular expressions, matrix transformations , GUI
dialogs, etc. Many of us consider Python a secret weapon in learning
new paradigms and technologies

The most important things you need to leave behind:

1. Intuition about what is already available vs what you have to
write. Java tries to reinvent the whole compsci world. Python just
says "Nice C/C++/FORTRAN library; I think I'll use it via a binding."
If it is codable, it is probably scriptable in Python.

2. Temptation to reinvent entire stacks of libraries to replicate the
Java module import structure. This is a real problem in migrating
existing code. You have to take deep breath and ask "What is the
fundamental task, and how would a programmer do that in Python?"
Entire library trees melt away when you do this.

3. Fear you are missing something when you get done. Python takes
c. 1/3 as many LOC as Java for the same task. At first I kept saying:
"This wee bit of code couldn't posssibly do the whole job, could it?"
If you have a good regression test suite, you are done when it works.
If you need help getting on board unittests, see mkpythonproj:
http://www.seanet.com/~hgg9140/comp/index.html#L006
--
Harry George
PLM Engineering Architecture
Apr 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2492
by: BlackHawke | last post by:
Hello! My name is Nick Soutter, I am the owner of a small game company in San Diego, CA called Aepox Games (www.aepoxgames.net). Our first product, Andromeda Online (www.andromedaonline.net), goes
49
2873
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
114
9884
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
37
4335
by: asj | last post by:
awhile back, eBay decided to switch from a Microsoft/.NET/Windows architecture on the backend to a J2EE one, which might explain why their java backend will handle up to 1 BILLION page views a day! the funny thing was eBay was one of the major case studies for .NET at the beginning, when there was still some hype about it. interesting post about a few java case studies: http://weblogs.java.net/pub/wlg/268 "I love looking through case...
28
4331
by: liorm | last post by:
Hi everyone, I need to write a web app, that will support millions of user accounts, template-based user pages and files upload. The client is going to be written in Flash. I wondered if I coudl get your opinions - what do you think is the best language to use for the server? Python or Java? And I'm talking scalability, object oriented, development tools etc. Thansk for any idea! I'd love to hear it Happy New 2006,
12
2128
by: john_sips_tea | last post by:
I've got a fairly substantial webapp written in Java (plus Tomcat, Hibernate, Struts, JSP, MySQL) that is a bit of a bear to work with. I didn't write it. Much of it is only very sparsely documented (if at all). No design docs anywhere. It's a large webapp with many classes and fairly deep inheritance hierarchies. There seems to be JUnit test cases in place. The possibility of re-writing it has come up, and I must say that, although it...
8
2441
by: Aravind | last post by:
hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to develop an app which can run both in windows and linux. Pls help. Thanks in advance....
16
4014
by: Amir Michail | last post by:
Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes
29
2353
by: s0suk3 | last post by:
Hello, I was hoping to get some opinions on a subject. I've been programming Python for almost two years now. Recently I learned Perl, but frankly I'm not very comfortable with it. Now I want to move on two either Java or C++, but I'm not sure which. Which one do you think is a softer transition for a Python programmer? Which one do you think will educate me the best?
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.