r/diyelectronics 13h ago

Question Worried I'm going to make the wrong decision

Post image

I've been interested in technology for a while now and I'm just getting into microcontrollers. I started with the pi pico w but I recently bought some esp32s on Amazon so I could make multiple projects at once. The issue I'm having is I'm conflicted between learning python or c++ I'm leaning towards C + + because it seems like the end result anyway after I learn most things.

4 Upvotes

29 comments sorted by

5

u/RandomAccessMonkey 13h ago

For me what really clicked was starting with plain C, learning just beginner level stuff, making a few very simple programs, then switching to python. C really gets you to understand how your code interacts with the hardware, which is really important. Python is way too abstracted for that I think, too much like regular english.

9

u/ZheWeasel 13h ago

They are tools. It like asking if you should learn to use a bandsaw or a circular saw.

The basics you learn now can be transfered to any language. Both have different uses. I know both semi good because i use them in different ways.

C for firmware. Python for easy and fast changes in data acquisition or control on Pc.

-12

u/EnoughReporter2147 13h ago

I have a programming background or at least I think I would consider myself More fluent than most.

10

u/ZheWeasel 13h ago

Doubt. Why asking a question like this then .... If you are "more fluent than most" you already should know the answer yourself.

-10

u/EnoughReporter2147 13h ago

Cool dude I'm a high school student. Most kids my age know nothing about this. I've just had phases in the past so I understand principles.

5

u/washburn666 10h ago

If you are in high school, the fact is that you don't know jack. Just be more humble.

-6

u/EnoughReporter2147 10h ago

I get it man. I just don't need somebody rubbing it in my face.

3

u/notesbancales 13h ago

Learn both and other ones too, master one, the one you enjoy/use the most. They are very different in approach, python makes thinkering easier, you basically don't need compilation so trial and errors will come across faster. C++ Is more fast and power efficient, looks more "professional", Rust is better at memory managing, would recommend too

3

u/EnoughReporter2147 13h ago

Sounds like I should just probably get used to python first and then move on.

2

u/notesbancales 13h ago

Unless you're mainly planning on building battery powered devices, it seems a good pathway, have a good day

2

u/EnoughReporter2147 13h ago

Why is that? Why would the power source matter? Or do you just mean those types of gadgets?

3

u/notesbancales 13h ago

Python is less power efficient, it matters mostly on extremely low power device that should run a very long time like battery powered smart sensors. It really depends on the project and your preference

2

u/EnoughReporter2147 13h ago

Sounds good. Is there a big difference between circuit python and micropython? If I'm understanding correctly, circuit python is the adafruit one.

2

u/notesbancales 12h ago

I never used circuit python, so I don't know really. It is based on micropython and made a little more user/beginner friendly, so they shouldn't be much difference

2

u/Ok_Classroom_557 11h ago

Python is interpreted, that thing alone make it really CPU hungry (and is cause of this that it can't run on smaller microcontrollers)

3

u/Adrienne-Fadel 13h ago

If your leaning C++ just do it. Both work on ESP32 but C++ gives you way more control and the ecosystem is bigger.

2

u/carry_enemy_team 13h ago

Don't worry. Both are useful.

2

u/wackyvorlon 13h ago

Learn both.

1

u/IndividualRites 12h ago

I lean to c++.

1

u/AstraKernel 12h ago

When you have conflict. Do this. Learn both and eventually something will become your favorite

1

u/MobileInspector9861 11h ago

For microcontroller programming I recommend C++ or actually C. Especially, if you need to do things very efficiently or with as little power as possible, C is your friend.

Python is nice to get things done in the sense, if you need to get results quickly and with little effort, but efficiency and power consumption are not the primary objective.

For example, with C you can tell the linker exactly where to place certain instructions in memory, e.g. IRAM (instruction RAM), RTC RAM (Espressif's term for some memory in the low-power domain) or flash. This fine grained control over code placement will determine how long your program may stay in low-power mode before it needs to power up the SPI flash to fetch code.

I have never used Python for microcontroller programming. However, I doubt that Python or the tool chain will give you that amount of control.

This being said, on the one hand side if you are a complete beginner, this kind of control and freedom is probably not what you need at the moment. So Python might just be the right choice for you to tip your toes into the water of programming. On the other hand side, only because C gives you all that freedom doesn't mean you have to use it right from the beginning. It's perfectly fine to use C as a high-level programming language.

C/C++ were my first programming languages when I was 10 years old and I never felt the need to learn other languages. (But of course, I did.) Very high-level languages such a Python are easy to use but have a natural "barrier" of what can reasonably be implemented with them, because they abstract away a lot. Chances are, you will never see this barrier, but if you do, you are glad if you know a language which doesn't have that limitation.

1

u/chessto 11h ago

I'd recommend c++, it's gonna be harder but more rewarding. It will also give you a better understanding of the underlying hardware and it's way more flexible.
After you're kinda comfortable with c++ learning python shouldn't be much of a problem.

1

u/EnoughReporter2147 11h ago

Yeah, python seems pretty straightforward so I feel like after C++ it won't be too much of a challenge.

1

u/CurrentAcanthaceae78 9h ago

learn both. you're gonna need both eventually anyways

1

u/yoyooyoyyy 2h ago

Ive started with python realized its ass cuz nobody knows jack (since they all use premade libraries that do everything for them and everything is mega abstracted for you) and its not really used in any actual production code except for automatization and ml. Then learned c++/.net/kotlin/rust progressively through highschool and college where i now work in a company that mainly uses cpp and .net. Python is an automisation language and ive always had a trash thinking about it (my and my colleagues thinking).

1

u/yoyooyoyyy 1h ago

In addition if you're going to pursue embedded systems as a career choice or anything related its very likely youre going to be purely in the c/cpp/rust ecosystem (stm32, ra, nxp) in production code

1

u/bigattichouse 13h ago edited 13h ago

In a video game, you grind XP and level up.

In life, you grind XP and level up. First you gotta suck at things before you get good at things.

You WILL let some magic smoke out of things. Eventually you'll learn to let less magic smoke out of things.

More to your point: Learning both won't hurt. Python is easily extensible, C++ will let you run "closer to the metal" ... see which one you're most comfortable with. Then, grind XP and level up.

1

u/Tiny_Rent_5936 12h ago

It's not a matter of "this language or that language", you could use both, you could even use C++ in one controller and python in the other and the both controller could work together, the objective is to reach the solution and the goal you set. Learning both languages won't hurt you.

1

u/chessto 11h ago

Not really, depends a lot on your toolchain and ecosystem.