Java or Python?

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
I am at cross roads. I want to learn a new language, but i am not sure which one to learn. I am an EE and I know C/C++. They tried to teach me Java in college, but it did not compute (i.e. too much partying). Which should I learn? From what I remember, Java is similar to C, it's just a little syntax here and there, but it's a much better and cleaner for OO coding (no pointers!). The one thing i do see about Python is that you do not declare variables since they are not static. From the looks of it, Java is sort of like a dynamic language because it uses the run time environment, but you still code things in a static way. Is that correct?

So, I guess the question is, what is more applicable for an EE?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,835
4,815
75
Gibson, both languages are going to be very different from what you're used to.

First, you've noticed the syntax differences. I personally much prefer braces over indentation as block delimiters. But that's about the only bad thing I have to say about Python.

I don't know how much object-oriented programming you got with C++; I got some then forgot it. :p But Java really forces OO on you. Python doesn't quite so much.

Then, both languages have large libraries. You may get away with avoiding them a little more in Python, but you basically have to be able to use the documentation in both cases. Look over the Java API and The Python Standard Library. See if you can find some common tools, like, say, finding the last character in a string. (Hint:
Most of Java's useful classes are in java.lang or java.util.
)

Java...(no pointers!).
That's kind of a marketing lie. Every variable in Java that's not a primitive (int, char, etc.) is a pointer. You just can't dereference anything or do pointer arithmetic with them.

P.S. If you can't decide, there's always Jython. :p
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
What do you want to do for a learning project?

Web server = PHP + MySQL for general purpose, or some domain-specific framework like Ruby

Web App = iOS for Apple, Silverlight & XNA for WinMo, Java for Android -or- HTML + JavaScript for some lowest common denominator cross-platform app

I've used Perl, PHP, Flash ActionScript and HTML + JavaScript for dabbling in web stuff, but mostly use C/C++, MFC and Win32 for work.
 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
What do you want to do for a learning project?

Web server = PHP + MySQL for general purpose, or some domain-specific framework like Ruby

Web App = iOS for Apple, Silverlight & XNA for WinMo, Java for Android -or- HTML + JavaScript for some lowest common denominator cross-platform app

I've used Perl, PHP, Flash ActionScript and HTML + JavaScript for dabbling in web stuff, but mostly use C/C++, MFC and Win32 for work.

Not sure yet. i am unemployed now because I got laid off. I was a consultant, so my job was to delegate engineering work, not really do it. I am thankful to leave the job, but as i try to get into a core position (like mixed signal design), I have met great resistance because 1. I have no masters, and 2. My previous experience after college is not really applicable.

I tried dabbling into DSP, but it is tough without an actual application. However, I got an unpaid part time internship where I deal with assembly code and C for communications to a DSP. The internship is really slow though:(

I figure that in my downtime, i can learn a new language. Whenever I see job postings, I see ruby on rail, Java, and Python. I think Ruby may be to high level, but I can see using Python or Java.
 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
Gibson, both languages are going to be very different from what you're used to.

First, you've noticed the syntax differences. I personally much prefer braces over indentation as block delimiters. But that's about the only bad thing I have to say about Python.

I don't know how much object-oriented programming you got with C++; I got some then forgot it. :p But Java really forces OO on you. Python doesn't quite so much.

Then, both languages have large libraries. You may get away with avoiding them a little more in Python, but you basically have to be able to use the documentation in both cases. Look over the Java API and The Python Standard Library. See if you can find some common tools, like, say, finding the last character in a string. (Hint:
Most of Java's useful classes are in java.lang or java.util.
)

That's kind of a marketing lie. Every variable in Java that's not a primitive (int, char, etc.) is a pointer. You just can't dereference anything or do pointer arithmetic with them.

P.S. If you can't decide, there's always Jython. :p

LOL @ Jython...
 

wantedSpidy

Senior member
Nov 16, 2006
557
0
0
It's like saying, I've eaten grapefruit. But now I want to eat some more. Should I eat Oranges or Pizza? Oranges seem a lot like Grapefruits but there are differences. Pizza is just cool, I don't have to peel before I eat.

In terms of what is applicable to EE: Stick to C. Nothing else comes close. As an EE you want to get as close as possible to machine language in order to develop a strong understanding of the systems. C enables you to do a ton on very little memory, which is the key for a lot of hardware programming you will do as an EE.
 

esun

Platinum Member
Nov 12, 2001
2,214
0
0
For a EE, learn Python. It is gaining popularity as a MATLAB replacement (due to packages such as Numpy and Scipy) and many EEs use it for simulations (for example in signal processing, communications, networks, etc.). Also good for various other automation tasks like instrument control.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,835
4,815
75
Not sure yet. i am unemployed now because I got laid off. I was a consultant, so my job was to delegate engineering work, not really do it. I am thankful to leave the job, but as i try to get into a core position (like mixed signal design), I have met great resistance because 1. I have no masters, and 2. My previous experience after college is not really applicable.

I tried dabbling into DSP, but it is tough without an actual application. However, I got an unpaid part time internship where I deal with assembly code and C for communications to a DSP. The internship is really slow though:(

I figure that in my downtime, i can learn a new language. Whenever I see job postings, I see ruby on rail, Java, and Python. I think Ruby may be to high level, but I can see using Python or Java.

Hm, so you're a C/C++ programmer who's familiar with EE signals processing, and would like to learn a new language. Given a thought to the GPU processing languages CUDA and OpenCL?

I happen to know of an open-source application that uses FFTs and could use some help. First, for some reason it doesn't work when compiled on a 32-bit OS, and I don't know enough about the FFTs involved to know why. (It works perfectly on 64-bit Linux, anyway.) Second, any speedups you see would be great! :D Third, a port to OpenCL for AMD graphics cards would be really nice too.
 

wand3r3r

Diamond Member
May 16, 2008
3,180
0
0
I've dabbled with python a bit, it has very broad uses and libraries for just about anything. It seems to be quite powerful but I'm not sure about the job market. There are always jobs for java programmers. Java is a more traditional programming language whereas python has a lot of functionality that can be used. For example a program to track gestures on a screen and so forth requires little code as does a simple web application. A java based web application would require a bit more from your end.

I'd take a look at the jobs in your area (assuming you are trying to strengthen your resume) if you need a bit of direction. I think python may be a bit quicker to learn the basic syntax but to really learn Java you need to do a larger project(s).

I didn't learn enough about python to make a deep comparison and only made a simple web application to test it out. Java on the other hand can be studied as deep as you have time. (generics, concurrency/multi threading, design patterns)
 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
For a EE, learn Python. It is gaining popularity as a MATLAB replacement (due to packages such as Numpy and Scipy) and many EEs use it for simulations (for example in signal processing, communications, networks, etc.). Also good for various other automation tasks like instrument control.

Whoa, really? I liked Matlab too, but you really have to have a use for it in order for a company to deem it useful. The package is like, $1000 for one license now and they are only going to raise it. For the longest time, me and a group of friends contemplated making a company to go against Matlab. Then my fiancee got a job there on the business side and told us how they just bring you to court and just suck you dry by milking the case for a long time.
 

Gibson486

Lifer
Aug 9, 2000
18,378
2
0
I've dabbled with python a bit, it has very broad uses and libraries for just about anything. It seems to be quite powerful but I'm not sure about the job market. There are always jobs for java programmers. Java is a more traditional programming language whereas python has a lot of functionality that can be used. For example a program to track gestures on a screen and so forth requires little code as does a simple web application. A java based web application would require a bit more from your end.

I'd take a look at the jobs in your area (assuming you are trying to strengthen your resume) if you need a bit of direction. I think python may be a bit quicker to learn the basic syntax but to really learn Java you need to do a larger project(s).

I didn't learn enough about python to make a deep comparison and only made a simple web application to test it out. Java on the other hand can be studied as deep as you have time. (generics, concurrency/multi threading, design patterns)

Yeah, I went through tutorials. Java makes me feel like I have to learn programming all over again. It's not difficult, but I feel like, as someone mentioned above, you have to be forced to learn OO programming to do Java. that said, it probably would not hurt to learn OO programming (again). Python....man, I only spent, what, 2 hours yesterday on it. I already feel like I know it very well.
 

gnawrot

Golden Member
Mar 5, 2003
1,211
0
0
I would vote for Java. More popular and should be easy to learn for C++ developer.
 

beginner99

Diamond Member
Jun 2, 2009
5,320
1,768
136
I didn't learn enough about python to make a deep comparison and only made a simple web application to test it out. Java on the other hand can be studied as deep as you have time. (generics, concurrency/multi threading, design patterns)

Yeah, I went through tutorials. Java makes me feel like I have to learn programming all over again. It's not difficult, but I feel like, as someone mentioned above, you have to be forced to learn OO programming to do Java. that said, it probably would not hurt to learn OO programming (again). Python....man, I only spent, what, 2 hours yesterday on it. I already feel like I know it very well.

Python is an OO language just as Java and even more. There are no primitive types. everything is an object in Python.
You can do non-OO stuff in java just as easily.

If you want to learn Object Oriented Programming, the basics are the same regardless of the language. And you can do multi threading in python just as well as you need to use design patters if you use it for anything "serious" too.

I don't know about creating GUIs with python. May be easier in Java. Plus Java is certainly a lot faster (but for learning this is irrelevant).
 

hooflung

Golden Member
Dec 31, 2004
1,190
1
0
Java is good but so is Python.

Java does in fact have pointers. The very foundation of Java's pass by value defines the fact that java has pointers. They are called reference values. When you create a new object and then pass it around to functions/methods you are actually passing the reference value (pointer) as an argument, not the object.

For Python...

Python has one very, very crippling thing about it. The Global Interpreter Lock.

http://wiki.python.org/moin/GlobalInterpreterLock

This stops Python from being able to be truely multi-core enabled. You can try green-threads with Stackless Python will scale very well. So well in fact the near entirety of EVE Online's server execution software and game mechanics are written in Stackless Python only going to C/C++ for overly-expensive calls where Python just cannot cope and drivers/middleware core libraries (which are wrapped by stackless.)
 

esun

Platinum Member
Nov 12, 2001
2,214
0
0
Whoa, really? I liked Matlab too, but you really have to have a use for it in order for a company to deem it useful. The package is like, $1000 for one license now and they are only going to raise it. For the longest time, me and a group of friends contemplated making a company to go against Matlab. Then my fiancee got a job there on the business side and told us how they just bring you to court and just suck you dry by milking the case for a long time.

Somebody beat you to it. It's not a commercial package, but lots of people are looking to Python as a MATLAB replacement. See www.enthought.com for example. There are also other packages like Sage (Python-based) and Scilab. And you're right, MATLAB is ridiculously expensive. Not only is the base MATLAB license $2,100, but each toolbox (which really make MATLAB useful) is an additional $500-$2,000.

Anyway, I would say that in my day-to-day experience as a EE nobody I know uses Java while many use Python, either for its scientific computing features or as a general-purpose scripting language. That's why I would recommend it over Java.
 

AyashiKaibutsu

Diamond Member
Jan 24, 2004
9,306
4
81
Normally, I'd say Java, but if you're already very good at C++ Java should be trivial to learn so you might get more out of learning Python.