salwan
Posts: 2
Joined: Tue Apr 29, 2014 10:58 am

which language better c++ or Python

Fri Sep 19, 2014 5:15 pm

Hi guys i have a first time use raspberry pi Please i need your advise which programming language better to program raspberry pi C++ or python to control gpio with Gui graphical applications ? so i used to program c/c++ to program microcontroller by using compilers

riklaunim
Posts: 265
Joined: Tue Apr 22, 2014 7:34 pm

Re: which language better c++ or Python

Fri Sep 19, 2014 7:16 pm

For Raspberry Python is the official supported as well as much easier to learn and use. It's also use by few microcontroller boards like PyMCU or pyboard, and some other single board computers (like PcDuino or Beaglebone Black).

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

Re: which language better c++ or Python

Fri Sep 19, 2014 7:18 pm

The right answer is "both". You should choose the language that's best suited to the task you're trying to achieve rather than having a "C++ is better than Python" or "Python is better than C++" dogma.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

talm
Posts: 22
Joined: Thu Jan 17, 2013 10:14 pm

Re: which language better c++ or Python

Fri Sep 19, 2014 11:01 pm

Unless running speed is number one, start with Python.
The learning curve for c++ is SOOO much steeper than for Python.
I have been a programmer for 50 years and I have done programming
in assembler, Fortran, Cobol, C, Pascal, Python.... Python was
easy to get into as it is a script language, It is easy to debug.
Python is compatible between systems, a program developed
on a PC runs directly on RPi.

Torbjörn Alm
Developer for 50 years.
RPi owner since 2013.

salwan
Posts: 2
Joined: Tue Apr 29, 2014 10:58 am

Re: which language better c++ or Python

Sat Sep 20, 2014 12:03 pm

salwan wrote:Hi guys i have a first time use raspberry pi Please i need your advise which programming language better to program raspberry pi C++ or python to control gpio with Gui graphical applications ? so i used to program c/c++ to program microcontroller by using compilers
Many thanks for all , and how can i program graphical gui with python ?
and is python real time language ?

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: which language better c++ or Python

Sat Sep 20, 2014 12:05 pm

For gui, use the Geany IDE.
There are 10 types of people: those who understand binary and those who don't.

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

Re: which language better c++ or Python

Mon Sep 22, 2014 8:00 pm

salwan,
...is python real time language ?
Depends what you mean by "real time".

In one way there is no such thing as "real-time" programming. No matter what you compute it will take time. The results will be after the event that created the inputs.

So then the question is "When do you need the results?". This week, this day, this hour, this minute, this second, this millisecond, this microsecond... ?"

"real-time" is about dead lines. A super computer forecasting the weather for tomorrow is "real-time" if it gets a result before tomorrow comes.

As it happens, the Unix operating systems and hence Linux and hence Raspian make no assurances about how long some program takes to run. So before we talk about "real time" languages we have that to deal with that.

C++ may well be faster than Python. That is no use if your OS is taking your time when you don't expect it.

So, what actually do you want to do? What are the "real-time" deadlines you have.
Memory in C++ is a leaky abstraction .

webwiseguys
Posts: 2
Joined: Sun Jan 29, 2017 4:06 am

Re: which language better c++ or Python

Sun Jan 29, 2017 4:20 am

Huh? Deadline? Are we talking about software development? I think you meant The "Software Life-Cycle". What Salwan meant is that Python is an "interpreted" language vs C++ which is a "compiled" language. You can run Python script right after it's written, whereas C++ needs to be compiled before it can be executed. Python is as "real-time" as you can get.

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

Re: which language better c++ or Python

Sun Jan 29, 2017 4:39 pm

webwiseguys wrote:Huh? Deadline? Are we talking about software development? I think you meant The "Software Life-Cycle". What Salwan meant is that Python is an "interpreted" language vs C++ which is a "compiled" language. You can run Python script right after it's written, whereas C++ needs to be compiled before it can be executed. Python is as "real-time" as you can get.
The OP never mentioned software lifecycle, he just asked if Python is a real time language.

Heater is correct:
"real-time" is about dead lines.
sums it up, whatever that deadline is. Perhaps the distinction is that the deadline must be met. An OS should respond to user keystrokes or mouse movements in a timely manner or people complain, but its not called "real time" because the world will not end if the mouse lags a bit now and again.

For real time stuff the execution time should be predictable. There are languages specifically for this, but a language like C with no run-time overheads is a better choice than a slow interpreted language such as Python. And any language that pauses at unpredictable intervals for garbage collection say, is a no no.
salwan wrote:Hi guys i have a first time use raspberry pi Please i need your advise which programming language better to program raspberry pi C++ or python to control gpio with Gui graphical applications ? so i used to program c/c++ to program microcontroller by using compilers
You dont need C++ for the GPIO, there is a great library http://abyz.co.uk/rpi/pigpio/ intended for C and its probably the fastest around. The Python support is excellent too of course.

As previously stated, choose the best language for your ability or your application first.
Last edited by jahboater on Sun Jan 29, 2017 5:43 pm, edited 2 times in total.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: which language better c++ or Python

Sun Jan 29, 2017 4:48 pm

webwiseguys wrote:Huh? Deadline? Are we talking about software development? I think you meant The "Software Life-Cycle". What Salwan meant is that Python is an "interpreted" language vs C++ which is a "compiled" language. You can run Python script right after it's written, whereas C++ needs to be compiled before it can be executed. Python is as "real-time" as you can get.
Look up real-time on wikipedia: https://en.wikipedia.org/wiki/Real-time_computing . And deadline: https://en.wikipedia.org/wiki/Time_limit .

webwiseguys
Posts: 2
Joined: Sun Jan 29, 2017 4:06 am

Re: which language better c++ or Python

Sun Jan 29, 2017 6:36 pm

We're not talking about run-time. The question is about the difference between the two languages.

User avatar
B.Goode
Posts: 9048
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: which language better c++ or Python

Sun Jan 29, 2017 8:09 pm

webwiseguys wrote:We're not talking about run-time. The question is about the difference between the two languages.
Actually, "we" weren't talking about anything. This thread had been dead for well over 2 years until you chose to resurrect it with your contribution that seems to deliberately misinterpret the language previously used. The original questioner has lost interest and has not been here for over a year.

Return to “C/C++”