HORUS/blog

Sep 5, 2026 · python · cpp · getting-started · learning-robotics

C++ or Python for Robotics: Which Should You Learn First?

Learn Python first and add C++ when one part of the robot must keep time. On a bare microcontroller, C or C++ is the only door in — here is how to choose.

Learn Python first, then add C++ once one part of your robot is too demanding to stay in Python. Python puts a wheel turning tonight and nearly every tutorial meets you there; C++ earns its place later, in the parts that must keep time. That flips on a bare microcontroller, where C or C++ is the only door in — ROS 2 and HORUS accept both. The rest of this post is for someone with no robot yet, deciding which language to open tonight and worrying about choosing wrong.

Every thread you read says two things that contradict each other. Half the replies say that real robotics is C++, that anything else is a toy, and that you will hit a wall the day your loop has to keep time. The other half say start with Python, that you will have something moving in an evening, and that the C++ crowd is gatekeeping. You have eleven browser tabs and no robot.

So you split the difference badly. You start a C++ course, get through pointers, meet a build system, lose a Saturday to an error message about a linker, and quietly stop. Then you try a Python tutorial, get a servo sweeping in twenty minutes, feel good for a day, and then read that Python is not used for anything serious and wonder whether the week was wasted.

Underneath sits a real fear, and it is not about syntax. It is that the first choice locks you in, that you will build habits you later have to unlearn, and that a year from now you will discover you learned the wrong thing while everyone else learned the right one.

Should you learn C++ or Python first for robotics?

Learn Python first, unless the robot in front of you is a microcontroller with no operating system on it. The reason is not that Python is the better language; it is that a first robot is limited by how many ideas you can try per evening, and Python removes almost everything standing between an idea and a moving wheel. There is no build step to configure, the error message names the line, and the sensor you bought probably shipped with a Python example written by the manufacturer. Starting in C++ means meeting three unfamiliar things at once — the language, the way memory is handed out, and a build system — before anything twitches. Self-taught beginners who try that usually give up somewhere in the build system, which teaches them nothing about robots. Now the honest other half: a great deal of production control code on working machines is C++, and you will very likely write some of it. Learning Python first does not cancel that. It changes the order, so that when C++ arrives you already know what a control loop is for and are learning one new thing instead of four.

What does the language actually decide on a robot?

The language mostly decides which existing code you can borrow and how fast you can change your mind. A robot has three rough layers. At the bottom is code touching hardware, usually written in C or C++ because that is what chip makers write, and you will use it whether or not you author it. In the middle is the loop keeping the machine steady. At the top is the code deciding what to do next — drive to the kitchen, look for the cup, give up — and that layer is happy in Python, which matters because it changes daily while you work out what the robot is for. The middle is the ground people argue over. What the language does not decide is whether the robot works. Nobody's machine fails because the planner was written in Python. Machines fail because a message arrived too late to be useful, because a calibration drifted, or because nobody handled the case where the sensor returns nothing. Those failures happen in every language, and understanding what a control loop is and why its timing matters will help you more than winning the language argument.

What are the real options, and who is each one for?

There are more than two options, and one of them is deciding not to decide yet. You can start in Python and stay there far longer than the internet suggests. You can start in C++ because your course, your team or your target board already has. You can start on a microcontroller in embedded C or MicroPython, where the board makes the choice for you. You can pick Rust because you have heard its compiler catches the bugs that crash robots. Or you can pick the foundation first and let it hand you a language: ROS 2 supports Python and C++ side by side with shared message definitions, so perception can be written in one and control in the other, while HORUS, an open-source real-time middleware for Rust, Python and C++, puts all three languages on the same shared-memory ring buffers so processes on one machine exchange messages without serialising them. Read the table below as descriptions of people and situations rather than as a ranking, and notice how many rows end in the same advice: start where you can see something move.

OptionWho it is forWhat it assumes you knowWhen to pick itWhen not to
Python firstBeginners and solo builders with a single-board computerInstalling packages and reading an error messageYou want a wheel turning this weekYour board runs no operating system
C++ firstStudents on a course that requires it, or joiners of a C++ teamCompiling, linking, and where memory comes fromYour class, team or robot already speaks C++You are teaching yourself alone with nobody to ask
Embedded C or MicroPythonBuilders whose robot is a board, two motors and a batteryPins, timers, and how to flash firmwareThe robot has no computer, only a chipYou want cameras, maps or recorded logs
Rust firstProgrammers who already know one language wellTypes, ownership, and patience with a strict compilerYou want the compiler to catch what crashes robotsThis is the first language you have ever learned
Python now, C++ for one part laterAnyone whose robot grew a part that must keep timeWhere your loop hesitates, and why it hesitates thereOne subsystem misbehaves while the rest is fineNothing is late yet and nothing stutters
ROS 2 with Python and C++Builders who want existing drivers, mapping and navigationLinux, workspaces, launch files, package layoutBorrowed packages are the point of the robotYou must show something moving before you can learn tooling
HORUSMixed-language builders working on one machineYour message shapes and how your loops are scheduledPython, C++ and Rust parts must share data on one boxThe value of your robot lives in ROS 2 packages
The vendor's SDK languageOwners of a complete arm or mobile baseThe vendor's API in the one language documentedYou want the machine to do its documented jobYou must mix in hardware the vendor never planned for

What should you learn if you are teaching yourself after work?

Python, without hesitation, because your scarce resource is evenings and not compute. A self-taught builder gets perhaps two useful hours on a weeknight, and the difference between a language where those two hours end with a servo moving and a language where they end with a linker error is the difference between continuing and stopping. Momentum is the whole game when nobody is grading you. There is a second reason that matters more than it sounds: when you are alone, the size of the answer pool decides how long you stay stuck. Python robotics questions have been asked and answered by thousands of hobbyists, and the answers are usually short. The counter-case is real, though. If you are teaching yourself specifically to join a team, contribute to a codebase you have already found, or work on a machine whose entire driver layer is C++, then learn the language of the thing you want to touch, and accept slower evenings for a while. Learning in a vacuum favours Python. Learning towards a specific destination favours whatever that destination speaks.

What should you learn if your robot is a microcontroller and two motors?

Learn C, though starting in MicroPython is a legitimate on-ramp and not a shameful one. A microcontroller has no operating system, no package manager and very little memory, so the environment itself decides most of this: the vendor's examples are C, the datasheet talks about registers, and the community answers are C. Fighting that is a strange hill for a beginner to die on. What MicroPython buys you is the same thing Python buys you everywhere else — you can change one line, reflash, and watch the behaviour change, which teaches you what your motors actually do. Where MicroPython stops is predictable. A behaviour that reacts at human speed is fine. A machine correcting itself constantly against changing load, like anything that balances, will feel the interpreter's hesitation as a wobble you can watch. When that arrives, the fix is not a cleverer Python program; it is moving that one behaviour into C while everything slower stays where it is. Plenty of good robots live permanently in that split.

What if you want a job or a working demo by the spring?

Split the question, because those two goals point in different directions. If the goal is a demo, choose Python and accept nothing else, because a deadline is not the moment to learn a build system alongside your own control logic. Spring demos are won by robots that do one impressive thing, not by well-architected robots that do nothing yet. If the goal is a job, the answer depends on which job. Roles centred on control code, embedded work and anything running on the machine itself will ask for C++ and will test it. Roles centred on perception, data, machine-learning glue and tooling will ask for Python and treat C++ as a nice extra. Look at ten adverts for the specific work you want and let them decide rather than asking the internet in general. The one thing that helps in both directions is a robot that exists. A candidate who can describe why their arm overshot and what they changed is more convincing than a candidate with a certificate and no machine, in either language.

What if you have never written code before at all?

Start with Python, and do not start on the robot. This is the one case where the robot should wait a week or two, because trying to learn programming and electronics simultaneously means every failure has two possible causes and you cannot tell which. If nothing happens when you run your program, is the code wrong, the wiring wrong, the motor unpowered, or the sensor dead? A beginner cannot answer that, and days disappear into it. So spend a short while with Python on a laptop — variables, loops, functions, reading errors calmly — until a program failing feels ordinary rather than alarming. Then plug in one sensor and print its number. Then one motor. Then both together. That sequence looks slow and is by far the fastest route anyone has found. C++ can absolutely be a first language, and computer science courses prove it every year, but those students have a lecturer, a lab, deadlines and peers who have hit the same error. Alone, in the evenings, that scaffolding is missing and the language will feel far harder than it deserves to.

What does it look like when Python stops being the right tool?

It looks like a robot that mostly works and occasionally hesitates, and the hesitation is not in your logic. The arm moves smoothly and then twitches for no reason you can find in the code. The wheels hold a straight line and then briefly surge when the camera code is doing something heavy. You add a print statement and the behaviour changes, which should worry you. The pattern is that timing has become the problem rather than correctness — your program does the right thing but occasionally does it late, and a correction that comes late is not a smaller correction, it is the wrong one. A second, unrelated signal is availability: the sensor you want ships only as a C library with no Python binding, and writing that binding is now your project instead of your robot. Neither symptom means abandoning Python. Both mean one part of the system moves to a compiled language while the rest stays put. If your symptoms look more like missing data than uneven timing, why a robot drops sensor data is a different diagnosis with a different fix.

Does Rust change the answer?

Not for a first language, but it changes the destination for some people. Rust's appeal in robotics is specific and honest: the compiler refuses to build a program with a whole family of memory bugs, which is exactly the family that makes a C++ robot crash after four hours of running rather than immediately. For a machine that must run all day beside a person, that guarantee is worth real effort. What Rust costs a beginner is the same thing that makes it valuable — the compiler argues with you about ownership before your robot has ever moved, and to a newcomer those arguments look arbitrary. Learners without a mental model of memory cannot learn from an error about memory. There is also the ecosystem question: hardware drivers and vision libraries reach Rust later than Python or C++, and writing bindings is a detour. So Rust makes most sense as a second or third language, chosen deliberately by someone who has already been burned. Several middlewares now support Rust directly, so choosing it later does not mean rebuilding your foundation.

What do you give up by starting with Python?

You give up early intuition about what the machine is actually doing, and that costs you later. A Python beginner can build a working robot without ever thinking about where memory comes from, how long anything takes, or what happens when two parts of a program want the same thing at once. That ignorance is a gift on day one and a debt in month six, because the day your loop starts hesitating you will be debugging a category you have never had to think about. You also give up some hardware outright — the smallest chips will not run Python at all — and you give up a slice of the job market that filters on C++ before reading further. The gentler part of the trade is that none of this is lost, only deferred, and you pay it back with a robot in your hands instead of a textbook. The costly version of this mistake is not starting in Python; it is staying in Python out of loyalty after the robot has clearly told you which part needs to move.

When is ROS 2 the better choice?

ROS 2 is the better choice whenever the code you actually want has already been written by someone else, and the language question is secondary to that. A robot that must map a building and navigate to a goal is a ROS 2 project, because those packages represent years you cannot reproduce in evenings. An arm doing collision-aware planning is one for the same reason. If the sensor you own has exactly one usable driver and that driver is a ROS 2 package, the decision is made. If your robot spans a machine and a workstation, or a fleet, ROS 2 was designed for that and is well travelled there. And if you are joining a lab or a company where everyone already speaks it, shared vocabulary beats any technical comparison. HORUS is not the answer for those projects, and picking it there means rebuilding plumbing that already exists so you can lose the packages that were the point. For a beginner, ROS 2 also settles the language argument usefully: Python and C++ share the same message definitions, so one node can move between them without changing how anything talks.

Is C++ still required for serious robotics work?

No, and here is why: the requirement was never for the language, it was for predictability in a small part of the system. What genuinely needs a compiled language is the code that must do the same thing in the same amount of time every cycle, plus the code sitting directly on the hardware. On most robots that is a minority of the lines and a minority of the effort. Perception pipelines, mission logic, calibration tools, data collection, evaluation scripts and the whole layer where the interesting research happens are routinely Python in serious companies shipping serious machines. The belief that C++ is a gate persists because adverts for control roles ask for it, loudly. The useful reframing is that C++ is a tool you will reach for at a specific moment, when something must not hesitate, rather than an entry requirement you must satisfy before touching a robot. Beginners who accept the gate version delay their first machine by months and often never build one. Beginners who accept the tool version build something, feel where it hesitates, and learn C++ with a reason attached.

Will starting in Python teach you habits you have to unlearn?

Partly, but not the way you think. The habits that transfer badly are not stylistic — nobody's career was hurt by learning list comprehensions first. What Python lets you skip is the awareness that everything you do has a cost in time and memory, so a Python-first builder tends to write code that allocates freely, copies data casually, and assumes a slow function is fine because the result was correct. In a control loop, that assumption is the whole problem. The other habit worth watching is treating exceptions as flow control, which is comfortable in a script and dangerous in a machine that must decide what a gripper does when the reading is missing. Both are correctable in a couple of weeks by someone who already understands robots, and neither is a reason to start elsewhere. What emphatically does transfer is the valuable part: how a control loop is structured, why you separate the code that touches hardware from the code that decides, what your sensor actually reports, and why the arm overshot. That knowledge is language-independent and it is most of what you are learning.

How do you decide which one to open tonight?

Name the thing you want to see happen this month, and let that decide instead of any argument about languages. If the answer is a wheel turning, a servo sweeping, or a camera detecting something, open Python and have it working before the weekend ends. If the answer is a specific board with no operating system, open the vendor's C examples, because the board has already chosen. If the answer is a codebase or a team you want to join, open whatever they write. Ask one tie-break question when it stays close: is the hard part of my robot behaviour I have to invent, or timing I have to hold? Invented behaviour favours the language you can iterate in. Held timing favours the language that does the same thing every cycle. And notice that neither question is about which language is better, because that question has no answer and has consumed more beginner evenings than any build system. Seeing how little code a working node actually needs tends to settle the argument faster than reading another comparison.

Decide by situation rather than by preference:

When the foundation question comes up later, weigh it on the five axes of the HORUS Fit Framework — ecosystem size, setup effort, team size fit, deployment target, and licence — and take the option that loses on the fewest, with no scores and no numbers involved. If your project keeps landing on one machine with a Python layer, a C++ layer and a growing suspicion that the boundary between them is where your time goes, star HORUS on GitHub so it is in your list when you start building.

Found this useful? Share it:Discuss on HNShare on X