SSB_17
Posts: 1
Joined: Fri Jan 03, 2014 3:29 pm

Python or Java?

Fri Jan 03, 2014 3:39 pm

I am new to Raspberry Pi and to developing a software, in which it takes voltage and current as in input after every 0.5 seconds.
Can anybody tell me which language(python/java) should I prefer for the fast processing of input?
(i have some idea about java but python is new to me)
Also which version of LINUX would be more suitable?
HELP PLEASE!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12665
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Python or Java?

Fri Jan 03, 2014 4:57 pm

Java can go into sudden garbage collections, and is then unresponsive for a period, don't know if this is also true for python, but I suspect not. Java is quite notorious because of its hidden garbage collection.

Greystone
Posts: 9
Joined: Fri Jan 03, 2014 3:38 pm

Re: Python or Java?

Fri Jan 03, 2014 5:09 pm

Java. You have access to an unparalleled eco-system. Also, I'd bet the performance of the Oracle HotSpot JVM compares quite favorably to the Python implementation you'd normally use on the Raspberry.

Greystone
Posts: 9
Joined: Fri Jan 03, 2014 3:38 pm

Re: Python or Java?

Fri Jan 03, 2014 5:10 pm

That said, for the Raspberry PI there are a lot of examples and libraries in Python, so it all depends on where you want to go next with your code...

User avatar
Douglas6
Posts: 4826
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Python or Java?

Fri Jan 03, 2014 5:27 pm

I'm a Java programmer, but I mostly use Python on the Pi (learning if for that purpose). As mentioned, there's a ton of Python libraries for Pi stuff, like the GPIOs, I2C, SPI, etc.

If you decide on Java, by all means get Pi4J.

Oh, and I'd go with Raspian for the OS. Stable, well-supported, familiar.

User avatar
clicky
Posts: 425
Joined: Thu Oct 25, 2012 7:34 am

Re: Python or Java?

Sat Jan 04, 2014 10:36 am

I am very Java biased and used it for more than 15 years now.

I would say that you need to predict how complex your program is going to be and decide on that. Simple things that tend not to evolve and do not need complexity of JVM would probably be far better done as simple Python scripts.

If you can foresee more complexity (web server/XML processing/lots of object oriented code/threading/interoperability with other systems/etc) then you'll probably be far better using Java.

Or, if you just love coding in Java as I do - then there's no competition there.

Oh, BTW, changing existing Python script and running it again is very simple operation and you can easily do it just by ssh-ing to RPi and using vi (or any other editor). If you want to do more complex stuff in Java you would be far better off doing it in Eclipse (or similar) on a PC (or laptop) and then send result back to RPi to execute (copying .class files, creating .jar and send it there or do it in many other ways). All this adds complexity - but when set properly gives you far more powerful system.

And - GC problems can be sorted out... :)

Return to “Java”