makerbiles6
Posts: 1
Joined: Tue Jun 02, 2020 6:16 pm

Questions about programming on the Raspberry Pi

Tue Jun 02, 2020 6:17 pm

Hello everyone, i was wondering what would be the best programming language for the raspberry pi.

I am a software developer which works with C#, so I got that going for me.

I also already finished quite a big project with C# and Windows IOT on the Raspberry Pi but I wondered if there are better languages / possibilities out there.

My question, what is the favourite language on the Raspberry Pi?

What is the most beneficial language on the Pi because it can do the most (Fast, UI)?

I would like to do a little "homeautomation project" where I get myself a Pi with a 7" Touch Display.

So I would definetly need a possibility to create a nice UI (like UWP).

This is something I would like to programm on my own, even if there are some solutions out there.

Also I am thinking about doing this as a web service which then is displayed on the Raspberry Pi.

What would you recommend me to use as the programming language?

Thanks for your feedback and answers.

User avatar
recantha2
Posts: 321
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
Contact: Website Facebook Twitter

Re: Questions about programming on the Raspberry Pi

Wed Jun 03, 2020 8:46 pm

Hello,
First of all, "best" is very difficult to pin down, because it very much depends on what you're trying to do.
With what you've said though, I would start off with Python (which is a language that sits well on the Pi) and then using something like GUIZero (https://github.com/lawsie/guizero) or the Python Tkinter library to create you GUI.

Good luck! :-)
--
Michael Horne - @recantha
Raspberry Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam

W. H. Heydt
Posts: 12700
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Questions about programming on the Raspberry Pi

Wed Jun 03, 2020 8:57 pm

With your background, I'd suggest C or C++.

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

Re: Questions about programming on the Raspberry Pi

Wed Jun 03, 2020 9:02 pm

makerbiles6 wrote:
Tue Jun 02, 2020 6:17 pm
Hello everyone, i was wondering what would be the best programming language for the raspberry pi.

I am a software developer which works with C#, so I got that going for me.

I also already finished quite a big project with C# and Windows IOT on the Raspberry Pi but I wondered if there are better languages / possibilities out there.

My question, what is the favourite language on the Raspberry Pi?

What is the most beneficial language on the Pi because it can do the most (Fast, UI)?

I would like to do a little "homeautomation project" where I get myself a Pi with a 7" Touch Display.

So I would definetly need a possibility to create a nice UI (like UWP).

This is something I would like to programm on my own, even if there are some solutions out there.

Also I am thinking about doing this as a web service which then is displayed on the Raspberry Pi.

What would you recommend me to use as the programming language?

Thanks for your feedback and answers.
First thing is to get you off Windows IoT.

Windows IoT has not been maintained by MS for two or more years and there is no Windows IoT that works on the recent models of Raspberry Pi. It is a effectively a dead end.

You need to use the Raspberry Pi OS, based on Debian Linux, for the best support and guarantee of the longevity of your creations.

At that point you find that just about every programming language ever is available for the Pi under Raspberry Pi OS.

You will find as many favorite programming languages as there are programmers!

Given your requirement for a fast UI the C++ and the Qt GUI libraries are a popular choice.
Memory in C++ is a leaky abstraction .

jahboater
Posts: 5799
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Questions about programming on the Raspberry Pi

Wed Jun 03, 2020 11:56 pm

makerbiles6 wrote:
Tue Jun 02, 2020 6:17 pm
My question, what is the favourite language on the Raspberry Pi?
If you look at the number of posts in the programming section of this forum, you will
see that Python is the most popular followed by C/C++.

If you want speed, then as noted above, C or C++ would be best.
Pi4 8GB running PIOS64

ghellquist
Posts: 76
Joined: Thu Aug 02, 2012 8:47 am
Location: Stockholm Sweden

Re: Questions about programming on the Raspberry Pi

Thu Jun 04, 2020 10:55 am

makerbiles6 wrote:
Tue Jun 02, 2020 6:17 pm
My question, what is the favourite language on the Raspberry Pi?
There are so many to choose from. And each programmer has his or her own favourite. They go from assembly directly on the hardware over to Basic and C and C++ and Python and Perl and PHP and javascript and java and SQL and Ada and Erlang and Cobol and maybe a bit of R or Mathematica or Haskell or Fortran. Or something else.

Generally, Pi programmets tend to stay away from the Microsoft Languages, say C#, or the Apple language Objective C, but there are lots of exceptions even to that.

One good bet is Python as it sits in a bit of sweet spot with enough language features and fast prototyping and with libraries to handle the Pi peripherals such as IO pins and the hardware bus I2C. It is the sort of "goto" language for quick prototyping as there is no need for the compile/link staget of say C. Even as it is more or less interpreted (there is a bit of just-in-time compiling hidden inside it) it is plenty fast on the Pi, even for soft real time control purposes. If you start from fresh, go for Python 3 (there has been a very long transition period from Python 2).

Next up might be C++, if you can stay away from the more "esoteric" parts of the language. It is a large language, and in parts shows that it started as a "fix" to some of the shortcomings in C. My suggestion is to stay off operator overloading and avoid trying to make your own versions of the Std library. There are nice helper libraries around, one example might be Qt.

Have fun!

knute
Posts: 568
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: Questions about programming on the Raspberry Pi

Thu Jun 04, 2020 7:05 pm

If you are familiar with C# I would suggest Java. I would suggest Java anyway but that's just me :-) You can develop on any computer and run it on the Pi or you can develop on the Pi. It has a good selection of widgets, excellent graphics capabilities, a huge stable API and runs quite fast once loaded.

User avatar
RamaSpaceShip
Posts: 60
Joined: Sun Apr 26, 2020 12:19 pm

Re: Questions about programming on the Raspberry Pi

Thu Jun 04, 2020 7:30 pm

I use Ada and C# on the RaspberryPi.
As you already know C#, you can keep C#. That would be what I recommend in your case.

I use MonoDevelop on a Debian desktop, and compile on a Pi4 to target the Pis (we use Pi3 and Pi4).

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

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 3:33 am

knute wrote:
Thu Jun 04, 2020 7:05 pm
If you are familiar with C# I would suggest Java.
I get the idea there.

But I think that if one is going to invest the time and effort it to learning an new language and all it's libraries then one should do oneself a favor and choose a language that is not an almost clone of the language one uses already. It should be a language that is conceptually different. Something that teaches a different approach to programming and makes you thing about programming differently. Otherwise you lean nothing of value for the time wasted.

Somebody who only know C# or Java and the like would be well served by getting into C, C++ or Rust for example.
Memory in C++ is a leaky abstraction .

jahboater
Posts: 5799
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 9:02 am

Heater wrote:
Fri Jun 05, 2020 3:33 am
Somebody who only know C# or Java and the like would be well served by getting into C, C++ or Rust for example.
Yes.

The popular languages like Python, C and C++ are "native" to the Pi and don't need things like mono to be installed before they work.
The system is mostly written in plain C so the manual pages cover all the C library stuff.
Pi4 8GB running PIOS64

User avatar
RamaSpaceShip
Posts: 60
Joined: Sun Apr 26, 2020 12:19 pm

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 5:47 pm

I have learnt 27 programming languages and I would NEVER recommend to use Python, C or C++ unless you are obliged to do so.

As I wrote in a previous post, use C#. The mono project offers a dedicated Rasbian install.
I you want to try something different, use Ada, the most powerful, efficient, robust and safe language.
If you want to use a more fashionned language use Rust.

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

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 6:19 pm

RamaSpaceShip wrote:
Fri Jun 05, 2020 5:47 pm
I have learnt 27 programming languages and I would NEVER recommend to use Python, C or C++ unless you are obliged to do so.
I can sympathize with that point of view.
RamaSpaceShip wrote:
Fri Jun 05, 2020 5:47 pm
As I wrote in a previous post, use C#. The mono project offers a dedicated Rasbian install.
Hmm.. not sure. Seems like a clone of Java. Like C++ but slower.
RamaSpaceShip wrote:
Fri Jun 05, 2020 5:47 pm
I you want to try something different, use Ada, the most powerful, efficient, robust and safe language.
If you want to use a more fashionned language use Rust.
Interestingly, that Ada developers are learning important lessons about memory safety and preventing data races between threads from Rust.

As it stands I would recommend Ada or Rust to beginners or anyone who wants to create a GUI.
Memory in C++ is a leaky abstraction .

User avatar
RamaSpaceShip
Posts: 60
Joined: Sun Apr 26, 2020 12:19 pm

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 7:12 pm

Heater wrote:
Fri Jun 05, 2020 6:19 pm
Hmm.. not sure. Seems like a clone of Java. Like C++ but slower.
See https://www.mono-project.com/download/s ... n-raspbian
C# is much better that Java, just a little bit slower than C++, but so much safer.
Heater wrote:
Fri Jun 05, 2020 6:19 pm
Interestingly, that Ada developers are learning important lessons about memory safety and preventing data races between threads from Rust.
Ada developers did that long before Rust even exists. The Ada safe threading model exists since the beginning of Ada in1983. The memory safe management was added to the language in 1995.

ti994/a
Posts: 10
Joined: Mon Jan 06, 2014 11:00 pm

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 7:38 pm

Could I suggest Xojo (previously REALBasic). Object oriented, easy to use and they have special free licences for Raspberry Pi. https://xojo.com/raspberrypi/

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

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 8:54 pm

RamaSpaceShip wrote:
Fri Jun 05, 2020 7:12 pm
C# is much better that Java, just a little bit slower than C++, but so much safer.
I won't debate C# vs Java. They look the same to me. They have the same principles in their design, C like syntax, object oriented, virtual machine, garbage collection etc.That is the result of Microsoft creating C# in response to some legal hassles they had when they wanted their own Java.

I can assure you C# is a lot slower than C++. If you want to argue otherwise I invite you to contribute a solution in C# for the "Million Digit Fibonacci Challenge" https://github.com/ZiCog/fibo_4784969

Granted C# gets you some degree of memory safety. With it's garbage collector.
Heater wrote:
Fri Jun 05, 2020 6:19 pm
Ada developers did that long before Rust even exists. The Ada safe threading model exists since the beginning of Ada in1983. The memory safe management was added to the language in 1995.
Not quite.

If you want a formally memory safe Ada program you are going to write it in the SPARK Ada subset. The SPARK guys were a bit stumped as to how to include some Ada oft' requested features into SPARK for the lack of an efficient and nice way to implement anti-aliasing rules.

Until they were shown how to do it by Rust: https://blog.adacore.com/using-pointers-in-spark
Memory in C++ is a leaky abstraction .

User avatar
RamaSpaceShip
Posts: 60
Joined: Sun Apr 26, 2020 12:19 pm

Re: Questions about programming on the Raspberry Pi

Fri Jun 05, 2020 10:16 pm

Having written a few hundred thousand lines in Java and C#, for me, there is a big difference between the two languages, even if they seem similar.

For the speed of C# versus C++, I am referring to https://benchmarksgame-team.pages.debia ... e-gpp.html, which does not show a so big difference apart on very specific algorithms. On a big project, this appears as a very little impact as you can still implement a specific algorithm in the most efficient language for it, and use native calls..

I see your point for the safety of memory: formally proven.
You need a subset of Ada for that (for what Spark is meant) , but for Rust as well : 'unsafe' must be removed, as it can break everything.
In addition, there is no formal definition of Rust. So it is difficult to formally prove it as a whole.

If you hide pointers in specially crafted classes in Ada (you can even tell the Ada compiler to prohibit the use of allocators in the part of the code you want), you get the same safety as Rust which hides 'unsafe' in its libraries.
That's not formally provable, but it seems to me very similar!

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

Re: Questions about programming on the Raspberry Pi

Sat Jun 06, 2020 11:46 am

RamaSpaceShip wrote:
Fri Jun 05, 2020 10:16 pm
Having written a few hundred thousand lines in Java and C#, for me, there is a big difference between the two languages, even if they seem similar.
Java and C# are certainly in the same class of languages even if their details a very different. That class being: languages designed to compile down to some kind of bytcode, require an interpreter to run them, hopefully cross platform executables, object oriented, with a syntax that looks a lot like C/C++, some kind of memory safety through the use of garbage collection..

My statement about the benefits of learning a language very different from Java/C# was about getting out of that class. Learning a language in a different class that does things differently. Gives one a different perspective on what programming is. Haskell for example for that functional programming view. C/C++ to get an idea about what a stack and heap actually is. Heck even an assembly language so you get some idea how computers work.
RamaSpaceShip wrote:
Fri Jun 05, 2020 10:16 pm
For the speed of C# versus C++, I am referring to https://benchmarksgame-team.pages.debia ... e-gpp.html, which does not show a so big difference apart on very specific algorithms.
I notice on clicking on the first example their, pi digits, that the C# code use the GMP multiple precision library. Which is written in C. That benchmark is comparing C to C++ mostly!
RamaSpaceShip wrote:
Fri Jun 05, 2020 10:16 pm
On a big project, this appears as a very little impact as you can still implement a specific algorithm in the most efficient language for it, and use native calls..
I'm sure that is true. When your high level language is just glue code for using tones of libraries and run time code written in C/C++ then the fact that C# is so slow matters less. See above.
RamaSpaceShip wrote:
Fri Jun 05, 2020 10:16 pm
I see your point for the safety of memory: formally proven.
You need a subset of Ada for that (for what Spark is meant) , but for Rust as well : 'unsafe' must be removed, as it can break everything.
In addition, there is no formal definition of Rust. So it is difficult to formally prove it as a whole.
Rust is pretty new, it has undergone a lot of changes since ten years ago. Only reaching stability and version 1 a couple of years back. So yes, a formal definition is missing. It's being worked on: https://rust-lang-nursery.github.io/wg-verification/ There are a lot of people in the safety critical and secure software worlds asking for that.
RamaSpaceShip wrote:
Fri Jun 05, 2020 10:16 pm
If you hide pointers in specially crafted classes in Ada (you can even tell the Ada compiler to prohibit the use of allocators in the part of the code you want), you get the same safety as Rust which hides 'unsafe' in its libraries.
That's not formally provable, but it seems to me very similar!
I think the point is that the safe subset of Ada, Spark, has limitations that annoy users and they have been asking for those limitations to be removed. As he article I linked to above says the Spark guys realized how to remove those limitations when they saw how Rust does it.
Memory in C++ is a leaky abstraction .

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26685
Joined: Sat Jul 30, 2011 7:41 pm

Re: Questions about programming on the Raspberry Pi

Sat Jun 06, 2020 12:37 pm

Everybody above is wrong.

C is clearly the best option



;-)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: Questions about programming on the Raspberry Pi

Sat Jun 06, 2020 3:27 pm

Yes jamesh. Sorry. I almost forgot for a moment there.

Good job you reminded us. Else I might have been led astray, into a life of ruin, by some fly by night, brazen hussy of younger programming language.

:)
Memory in C++ is a leaky abstraction .

ejolson
Posts: 5426
Joined: Tue Mar 18, 2014 11:47 am

Re: Questions about programming on the Raspberry Pi

Sat Jun 06, 2020 3:48 pm

makerbiles6 wrote:
Tue Jun 02, 2020 6:17 pm
Hello everyone, i was wondering what would be the best programming language for the raspberry pi.

I am a software developer which works with C#, so I got that going for me.

I also already finished quite a big project with C# and Windows IOT on the Raspberry Pi but I wondered if there are better languages / possibilities out there.

My question, what is the favourite language on the Raspberry Pi?

What is the most beneficial language on the Pi because it can do the most (Fast, UI)?

I would like to do a little "homeautomation project" where I get myself a Pi with a 7" Touch Display.

So I would definetly need a possibility to create a nice UI (like UWP).

This is something I would like to programm on my own, even if there are some solutions out there.

Also I am thinking about doing this as a web service which then is displayed on the Raspberry Pi.

What would you recommend me to use as the programming language?

Thanks for your feedback and answers.
The first post to this thread is a verbatim copy of the post appearing in 2018 at

https://www.reddit.com/r/raspberry_pi/c ... pberry_pi/

If you are still interested in using C#, I would suggest looking into making a GPIO library with similar functionality to the C# library described in

https://docs.microsoft.com/en-us/uwp/ap ... vices.Gpio

Given the lawsuit where Oracle is suing Google for reimplementing their Java API, I'm not sure whether implementing this C# API from Windows IOT would result in similar problems. Though obvious, it looks like a well thought out interface. It is also possible that Microsoft will not be as proactive in spoiling the goodwill of their customers, but I'm no lawyer.

Back in topic, you may want to tune the spam bot you are running to funnel old posts through Google translate and back in order that they are not exact quotes of posts from two years ago. This will make it easier for regulatory agencies to track your activities. Also, don't forget to fill out the section in your tax form on the reuse of Internet posts.

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

Re: Questions about programming on the Raspberry Pi

Sat Jun 06, 2020 4:29 pm

Great, we have been talking to a SPAM bot again.

Luck we so easily start discussing things that are totally off topic. Otherwise we would be wasting our time :)
Memory in C++ is a leaky abstraction .

Return to “General discussion”