views:

2414

answers:

23

I'm fast approaching the point in my coding where I would like to quickly write object oriented code in languages other than C++ for a variety of reasons.

After a lot of research, my choices have pretty much narrowed down to Python and Java. I'm leaning towards Python because of its relationship to C, but with Java, from what I can see, I get a good introduction to using and creating test suites with Eclipse - there is also Processing which is pulling me towards Java.

I'm not the kind of guy to tackle two languages at once, so which one would you recommend and why? What I want at the end is to have an additional language I can use for rapid development. Ease of learning isn't important to me as I'm willing to put in the time regardless. Ability to use the new language widely is.

+5  A: 

Python
Java is just C++ with a decent library, you don't learn a lot by putting an extra word in front of the class definition.

Martin Beckett
A: 

I would say Python. After C++ Java should be very easy to pick up as it is quite similar. Both are pretty widely used these days, and support for Python is growing, so that's my recommendation.

mdec
A: 

I would try JAVA

  1. it is more alike c++
  2. as a somehow compiled langauge it has a much better performance than python, which is a scripting language.

good luck!

kiwi
Doesn't Python compile to bytecode as well? What are those pyc files?
paxdiablo
Pythons performance is probably more to do with the dynamic typing. Ironpython is as fast as any other .net language
Martin Beckett
I wouldn't be overly concerned about the performance of the runtime of the language when picking a new language to learn. Assembly is much faster than C which is much faster than ... you get the point. Developer time is often, but not always, a more important resource constraint.
Burly
+3  A: 

For rapid development you should go with python. Reason for that is all of the built in methods, great documentation and simplicity.

This document here is a great overview and resource on python and its built in functionality.

Many items there are done in 2-3 lines where it would take a magnitude of code in either java or c++ to do.

Ólafur Waage
+1  A: 

It all depends on what you're after. If it's GUI applications, then Java or C# would be the way to go. I find Python is great for quick little apps to help me automate mindless tasks, but it's also powerful enough to get some cool stuff going.

Some points to consider:

  • Java is more similar to C++ than Python
  • Python is easier to learn (pseudocode, anyone?)
  • Python is an interpreted scripting language, so it's comparatively slow-running
Smashery
I've developed Python GUI apps with WxPython - it's remarkably similar to Swing and SWT with its layout managers, so I don't necessarily think GUIs force you towards Java.
paxdiablo
A: 

If you are programming for fun, python has more features and is a good language. It will probably expose you to a few more programming concepts than Java will.

If you want to do it for work, most of the work I've seen is in Java. I'm not saying there aren't any python programming jobs around, but (at least according to my recruiter), the market is almost all split down the middle between Java and .net right now.

If you want to go to the extreme, you might also glance at Scala. If you're just picking up a language to mess with, that's going to probably expose you to more features than either of the others you mentioned.

Bill K
If you are programming for fun, the assumption that easy = fun is not true for all cases. Demoscene coders program for "fun." But what they do is beyond the capability of 99% of the programming community.
NoMoreZealots
A: 

I upvoted mgb because I agree with him.

However, I think there would be value in learning both... though Python first.

The advantage of learning both is because right now Java is so pervasive... there are a lot of libraries you can leverage, both third party and built into the Java standard libraries. Then, with the library knowledge of Java, you can leverage it with Jython and have the power and rapid development of Python with the library support of Java.

I can't help but mention Ruby, as it is my favorite language... it is a very fun language once you learn it, and you get the same kind of power and rapid development capabilities as with Python, and there is JRuby also to leverage Java libraries. Just brought it up in case you hadn't considered it yet, I'm sure you would be just as happy with Python, as both are going to serve you much better than Java/C++ in terms of giving you a broader vision and alternative paradigms to aid in problem solving.

Mike Stone
+7  A: 

Python: Java won't teach you much, and will subtly annoy you, at least at first. ("Why can't I just chuck this new class at the bottom of this file? Why does this function have to be in a class?") Python will be weird as well, but you should at least be learning new ways to think. If Python is too weird, or you can't use it on a project for some reason, there is a reason C# is popular: it is pretty much Java for C++'ers.

Simon Buchan
+3  A: 

If you want to learn a different way of doing things, I would go Python. It has a lot of features that make your coding just easier.

However, if you want marketable skills, Java is still the way to go. Just about every corporation person I talk to will baulk if you mention Python but has no issues with Java, simply because it's so ubiquitous.

paxdiablo
+3  A: 

First Java (as you see a semplification in a lot of aspects of C++), and then you will eat Python for breakfast.

Enreeco
A: 

I think it completely depends on what you want to make. I choose Python over Java when I want to make websites. I find it easier to host and I love Django and did not like JSP/Struts/J2EE. I'm not sure that there's much that would make me choose Java over anything, but if you want to play with Processing, then you have a good excuse -- you could try Jython or Processing.js.

When I choose a language (or any other tool) it's because it's the best at making what I am trying to make -- it makes the right deployable -- not because of the language itself.

Lou Franco
+25  A: 

It depends on what your goals are. In terms of your resume, Java certainly has a much larger market than Python. In terms of your personal "knowledge portfolio", Python offers a greater potential for growth than Java does.

As many people have pointed out already, Java is very similar to C++ syntactically and has a better library. Python makes it very easy to just Get Things Done. Yes there is a performance penalty for interpreted languages, but often this is of little to no consequence for a project. CPU time is much cheaper than developer time. Without digressing into a comparative languages discussion, I wouldn't worry about the performance too much. Use your head and pick the right tool for the job.

I believe you can write your applications "faster" in Python than you can in Java - the language is certainly more terse. Python is a better choice for rapid prototype in my opinion. Also, you can use Eclipse w/ Python as a first class language (with things like PyDev) and do unit testing (with things like PyUnit).

As a slight aside, if you are considering Java, I would highly suggest you seriously consider C# instead. C# has broad market applicability (similar to Java), "evolutionary" rather than revolutionary syntax from C++ (like Java), is a newer and in many ways, better language than Java (from a purely language perspective). Quite frankly, I find C# a much more enjoyable language than Java, as do many others. In terms of the goals you have laid out however, the Python vs C# decision has all the same points as the Python vs Java decision.

Burly
I'm a Java guy but I tend to agree on the Python front. I learned Java after a little C. Its what I get paid to do. But to *really* learn OO I picked up Ruby (another option to consider) which also ticked the dynamic box.
Andrew Harmel-Law
I don't think that C# meets the "ability to use the new language widely" requirement. I'm assuming that widely means across operating systems.
David Locke
David - I actually meant being able to use it widely as in within the job field. However, in terms of widely for OS, you can use it for Win32, Unix/Linux, Mac OSX, and Solaris via Mono.
Burly
Burly: Assuming you stick to .NET code. I can't begin to tell you how many .NET apps I've tried to run on Mono in Linux, only to find they p/invoke to the win32 API
Branan
Running someone else's .NET application in Linux is a whole different ballgame than developing your own. Just like C++, you can't write everything on one platform and guarantee that it will compile and run properly on another. It is possible to develop cross-platform with C# if you wish however.
Burly
Cross platform compatibilty is important to me. It would seem that Java and Python are both essential. I will do Python first, because rapid prototyping is important too. Not too worried about performance. Thank you.
carleeto
+1  A: 

You want a rapid development cycle so definitely choose Python over Java. I have never heard anyone describe Java as a rapid development language. I do, however, know plenty of ex Java developers who, once they've learned Python, never go back to Java. They cite the verbosity of Java (and consequent longer development time) as a primary reason.

Also there are plenty of test suites for Python and a Python Eclipse plugin if you prefer an IDE.

mhawke
A big hello from a Java-wielding ex-Python developer :-).
paxdiablo
Ouch, you must miss it though!
mhawke
A: 

Well... this is a Holy War question, but I'll foolishly dive right in :-) ...

Personally I greatly prefer Python. I believe Java has nearly all the hassles of C++, and none of the rapid-prototyping advantages of dynamic languages.

But I'm sure all the Java people can give you arguments in the other direction.

You'll never get a useful answer taking a straw poll like this, sorry. You're going to have to try both, at least a little bit, and see what works for you. There's just no way around it.

Dan
+4  A: 

I really don't understand how people can claim that C++ and Java are more or less the same. Yes, the syntax is (superficially) similar, but everything else from execution model to memory allocation is (very) different.

I'd go with Python for just about everything, unless performance is a real issue. And if performance is a real issue, you may need to resort to C/C++ anyway.

JesperE
+1  A: 

java has the best open and closed source library support and a syntax that should be fairly easy for someone coming from C++(I should know -- I came from C to C++ and then to Java).

Having worked on Java for the last 8 years and in-between trying out ruby and python, I feel that, it was useful for me to know Java to appreciate Ruby and Python. Java can be pretty verbose and Ruby/Python just the opposite.

If you've coded in C++ using Visual Studio or Sun Studio, you will come to appreciate nice IDEs available for Java, like Eclipse, Netbeans or IDEA. If you go to python/ruby directly from C++, you can still use Eclipse/Netbeans, etc BUT you will NOT quite get the same level of support for debugging, profiling, etc.

Then again, it depends on what kind of apps you want to do. Python has its strength. Google AppsEngine allows only python apps(for now). You might want to consider that Google uses 4 languages inside -- C++, Java, python and Javascript.

anjanb
+1  A: 

I would say Python as well, but with the following caveats:

  1. If you have been programming in C++ for long, you would have come to let the compiler do a lot of work that you would otherwise have to do. Expect no such thing from the Python language itself.

  2. The format fetish is a good thing that forces people to write nicely formatted, readable code. This can be a PITA when you work across platforms, change line endings and work with more than one editor and you have to be take care of tabs/spaces etc.

None of this is probably an issue. It does need getting used to moving to a run-time model vs the compile-time model.

Other than that Python is just fine (together with Boost::Python) and you can accomplish a lot with it.

+2  A: 

Personally, if you want to write OO code quickly then you want to go with Python. Since Java is so similar to C++ there really isn't a benefit to learning it. At least, not the speed increase you will see by using Python.

Python supports extension/embedding using C/C++. You can write code in C/C++ and then import that code into your Python program. Java is strictly Java, AFAIK.

Plus, there is Jython, which is essentially Python written in Java . You can use the Java libraries and everything while still coding in Python.

Java may give you points on your resume but, subjectively, dynamic languages like Python and Ruby are starting to make a dent (at least from comments and articles around the 'net).

IMO, unless you have a definite need to learn Java, try Python.

crystalattice
+1  A: 

This really depends on what are you going to apply this newly learned language for. If you want to create smaller applications, in small(er) teams, getting faster thing done then I'd recommend Python (It doesn't mean Python is not used in big projects/organisations, it simply means Python is less popular in 'enterprise' development)

But if you are after improving your CV regarding work for big organisations, on big projects etc then I think Java is better choice. Personally I don't love Java (it can be very verbose) but I am happy to use it at work because of stability, libraries and tool set.

Two more comments after reading other answers:

1) Java and C++ do not share much apart from some syntax. Execution model, memory model, libraries, tools, best practices are usually very different. Learning Java is not so much learning syntax, it's learning its libraries, API, frameworks etc.

2) You can use Eclipse for Python development. Try Pydev, it also supports unit testing.

You can use eclipse for Python development, but you don't really need it.
jpartogi
+1  A: 

First you should learn Python:

  1. It is a scripting Lanugage, every Programmer should have a Scripting-Language in his Portfolio :-)
  2. The new Concepts you learn will widen your horizon (Java is too near to C++)
  3. With Jython (the java impl) you will quick conquer Java
Blauohr
+1  A: 
Anders Sandvig
+1  A: 

I dont have personal experience with java programming, but as others have pointed out, its more like C++ with extended libraries.

Python makes it real easy to code, so its ideal for rapid development. The annoying thing is it being a interpreter based language rather a compiler based language, so debugging is a time consuming process and it becomes more CPU intensive than Java(or any compiled language).

Assuming that rapid development is your preference, over saving CPU time, I would suggest Python over Java. Its uber-cool and you will simply fall in love with its simplicity.

Mohit Ranka
A: 

I am asking myself the same question nowadays. I am in GIS development. Like in many many other domains, GIS is also being expanded towards the mobile world. Although I'd choose Python without hesitation for all the reasons people wrote about, I think I will eventually have to choose JAVA :o( as it is the de-facto standard for mobile applications... Python is still very much absent in the mobile world.

Please correct me if I am wrong.

servet