Learning to code question: Beginner programmer, should I skip python and go for C++?

Hi everyone, would appreciate some advice

I'm currently playing with ardunio for a hobby but also implement very basic circuits and microcontrollers for my job, but it's very basic and I rely a lot on using other peoples' code and I don't understand the space enough to create my own beyond very rudimentary scripts

I've decided to attempt to learn programming to improve my arduino chops. I watched a few "here's what I wish I'd have know before I started to learn" videos and a couple suggested:

  1. Completing the CS50 course, then;
  2. Learning python

But obviously, Arduino uses C++ so is it more efficient to learn that instead? I assume they're quite similar.

I build escape rooms so microcontrollers are fantastic for controlling the physical input/output devices, but I'd imagine I'd want to start controlling my puzzles and integrating them together (I've heard a lot of my colleagues use a program called Node) via an IoT/WiFi setup. These are my two main goals for learning to code

Any advice for me? I'm planning on scheduling 1 to 5 hours a week to learning computer science stuff, mostly using youtube tutorials

Why are you even thinking about learning Python? Who gave you this . . . idea? I am truly fazed.

Arduino IS C++.

They're really not. Python is dynamically typed and has poor performance and C++ has actual freedom and runs blazing fast. Don't listen to anyone who says C is better than C++; they have no idea what they're talking about.

Don't learn Python. Bury that thought deep into your mind and never think about it again.

Learn C++.

Not at all. Python is easy to learn but has very limited uses with microcontrollers, is much, much slower than compiled C/C++ and is limited to small programs by the interpreter package. Furthermore, with Python, you will be way behind in incorporating new or unsupported (by Python) MCUs and sensors into your projects.

Consider Python to be a learning toy, but for any serious Arduino applications, you need C/C++.

This is an Arduino forum. You are not likely to get any encouragement about Python here. If you want to discuss some of the strong points of Python I suggest the MicroPython Forum.

Arduino.cc are heavily invested in supporting C++ because their products are C++ platforms. They have made a laughable attempt at supporting MicroPython on some of the products that have chips for which there is a distribution but don’t expect much from it. It is not in their best interest to have to support two programming ecosystems.

Talk to your professors about the advantages of each and if you intend to get into scientific computing, talk to people in the field.

Learn both.

1 Like

Speed: C++
Easier to Learn: Python
Flexibility: C++
Arduino Support: C++

C++ Score: 3
Python Score: 1

C++ 11/10 Highly recommend. Would use again.
Python -11/10 Not recommend. Would not use again even if bribed. Refund not given.

@milklizard88 If you want to do ML/AI/Neural Network programming on large cloud installations, you will be using Python.

1 Like

I avoid the cloud when I can. The cloud sucks. Google and Microsoft can have it and rot it for all eternity, for all I care.

1 Like

lol

I started with Assembler, then on to Basic, C, C++, Occam, Java, then various others all intended to make the task of programming easier. Whichever flavour was popular at any given point in time.

If you want something simple the Python is fine, but you need to understand that with every change/creation of, dare I say, a newer language, some functionality/speed can be lost.

One reason I really don't like C++ is its loss of functionality over C although it does make for tidier programs, providing it is written properly, which most people don't, including myself, just out of time constraints.
Even C is bloated in some areas although there has been improvement over the years. At one time it was far faster to write your own print function, than use the bloated C print function. Just in terms of speed of the code on slower MPU's

Many different people get used to writing in their preferred language and tend to overlook the benefits of other languages, only seeing the drawbacks, usually from past experience.

As far as Python being slow, that was in the past, these days there are both fast compilers and Interpreters, with the code being designed for many different key systems.
Most python is actually written in C, so there is no reason why it should be slower than CPP and in fact the original name for Python was CPython.

What you should do is learn both and whichever you like best and get along with better, is the one for you.

My daughter tends to use both Python and R, neither of which I can be bothered with. :slight_smile:

2 Likes

What sorcery and/or witchcraft have you been teaching your daughter, to the point they prefer Python! I am shocked and in dismay.

1 Like

Please explain in detail "C++ is its loss of functionality ".

1 Like

Is your intent to make a career of what you learn?

For programming arduino learn C++ . That’s the target language,

Once you have mastered that keep an open mind. Python is powerful too esp. on fast computers with a true OS and lots of ram (not an arduino) and has a super rich ecosystem so whilst it’s slower than a code written in C++ your productivity is increased.

1 Like

He meant the compiler is not happy with dirty (but sometimes efficient) hacks he learnt in assembly language :wink:

1 Like

If you can program in C++ && you have internet acces && you know how to use Google, than you can already program in python. The other way around is not entirely the case (eg that pyhton does not teach about pointers)

I use python to assist me with programming in C++, this varries from simple scripts to set up a new project folder, scripts to build and upload via CLI, script to initialize repository and push it to github.com to generating entire state machine skeletons. I also use a python script to release software versions. Both timestamp and version number are generated into source code and is printed to the monitor upon booting. No 2 compiled binaries are ever the same

I suck at pyhton, like real bad :wink:. I still have to look up how to do something simples like a for-loop from time to time, but I do get every job down with it and it helps me with my real job.. programming C++.

Bas

I'd learn Python and C++ and ... After all even though Python is given a bad rap. Which language is the Arduino IDE uses to compile C++?

Over all, I use Python way more then C++. The Library availability for Python is vast and using Machine Learning is a breeze with Python. Learn as many languages as you can.

What do people feel about the CS50 course? Will that be a waste of time?

Can anyone suggest some tutorial

https://www.learncpp.com/

1 Like

Thanks for your advice.

I would love to know first should I complete the course of C++ and then learn arduino C++ or directly come to arduino C++

Arduino is using C++.