anders_w
Posts: 15
Joined: Sat Jul 19, 2014 7:27 am

Python, Java or both?

Wed Mar 14, 2018 9:27 am

I am beginning a project where an RPi will be running a big control panel with a lot of lights and switches. In a second phase, it will be interfaced against other HW and SW that runs java code.

I'm unsure as to what programming language to use, though. The panel interface will run through a number of I2C I/O cards from land-boards.com, routed through an I2C spliter from the same company.

The only code I have seen that does this is in Python, but for the panel to work properly, I think I need the concurrency of Java. I have done some Python programming before, but am really a novice at Java. Maybe I should use Python for the I/O and Java for the internal logic (where the concurrency is needed), but how does one interface the two?

Does the collective have informed opinions on what language to use?

Heater
Posts: 9696
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python, Java or both?

Wed Mar 14, 2018 10:11 am

Warning. Language war alert!

I'm sure the "collective" will have as many different views on this as there are members. Or at least as many as there are programming languages.

Personally I'd say:

1) Pick one language and use it. It's frustrating, for me at least, to have to swap between languages while working on the same project. Both Python and Java can do what you want.

2) Neither. I'd do this in Javascript under node.js. When it comes to concurrency Python and Java are verbose and clunky. Javascript on the other hand, with it's event driven programming model makes this sort of thing a breeze.

anders_w
Posts: 15
Joined: Sat Jul 19, 2014 7:27 am

Re: Python, Java or both?

Wed Mar 14, 2018 10:59 am

Javascript, You say? Hm...

Is there any beginner's guide to it that You could recommend? Or one for node.js? Or both?

User avatar
jostle
Posts: 16
Joined: Tue Mar 06, 2018 6:26 am

Re: Python, Java or both?

Wed Mar 14, 2018 3:46 pm

Have a look at
https://www.w3schools.com/
for JavaScript and node.js tutorials
Have Fun ...

Lorqq
Posts: 1
Joined: Wed Apr 11, 2018 8:30 am

Re: Python, Java or both?

Wed Apr 11, 2018 8:34 am

Of course pick one language
Look here: https://www.codementor.io/javascript/tu ... t-properly

jahboater
Posts: 2854
Joined: Wed Feb 04, 2015 6:38 pm

Re: Python, Java or both?

Wed Apr 11, 2018 1:01 pm

What about: Java -> JNI -> C

Though I would code it all in plain C personally, easier (better support) and faster.

rin67630
Posts: 121
Joined: Fri Mar 04, 2016 10:15 am

Re: Python, Java or both?

Sat Apr 28, 2018 5:21 am

anders_w wrote:
Wed Mar 14, 2018 9:27 am
Maybe I should use Python for the I/O and Java for the internal logic (where the concurrency is needed), but how does one interface the two?
The best would have been to keep in one language. Else you could use named pipes / UDP ports to transfer the data between the programs.

ghans
Posts: 7784
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Python, Java or both?

Sat Apr 28, 2018 7:38 am

Python has the theading and multiprocessing module. Threading in Python is somewhat limited, that is why the multiprocessing module was introduced as work-around.

I too believe sticking to one language is essential.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

millers
Posts: 2
Joined: Fri Aug 17, 2018 10:27 am

Re: Python, Java or both?

Fri Aug 17, 2018 10:33 am

If you ask me - Python. :D

Heater
Posts: 9696
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python, Java or both?

Fri Aug 17, 2018 11:12 am

Any particular reason for that choice? In light of our opening posters stated application.

hippy
Posts: 3580
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python, Java or both?

Fri Aug 17, 2018 12:56 pm

jahboater wrote:
Wed Apr 11, 2018 1:01 pm
What about: Java -> JNI -> C
One could probably put a Python wrapper around that and call it from a Free Basic program :twisted:

I think choosing one language is best, which suggests Java given that's already being used. But it's not clear how tightly integrated this control panel project has to be with the Java side of things. If it's just a data connection rather than an API connection it would be perfectly acceptable in my books to treat them as independent and develop the control panel side of things in a different language.

User avatar
DougieLawson
Posts: 33606
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Python, Java or both?

Sat Aug 18, 2018 10:36 am

Heater wrote:
Wed Mar 14, 2018 10:11 am
Warning. Language war alert!

I'm sure the "collective" will have as many different views on this as there are members. Or at least as many as there are programming languages.
You weren't wrong. The language wars have started.

I'd say COBOL but the support on a Raspberry is a bit patchy (although you can get COBOL code to spit out Java JAR files with Elastic COBOL).

The obvious answer is "pick a language you know". The less obvious answer is "pick a language you want to learn" (which is why all the code I've written recently has been in C++).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Heater
Posts: 9696
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python, Java or both?

Sat Aug 18, 2018 11:54 am

Hmm...COBOL... An interesting choice.

How easy would it be to access the GPIO pins from COBOL? How easy would it be to get interrupts from those pins or other devices? Things that our OP needs for his project.

A couple of years back I decided I'm done with it. I'm old enough that I don't ever want to learn yet another programming language. I have done enough. What a pointless waste of life.

Then I found myself learning Verilog because I wanted to get something done with FPGA's. This year I found myself learning Scala because it can be used as an HDL for said FPGA projects using the Chisel or SpinalHDL libraries. That is far easier and nicer than fighting with Verilog. At least these last two are conceptually very different from your run of the mill programming languages.

Return to “General programming discussion”

Who is online

Users browsing this forum: PhatFil and 5 guests