Sep 5, 2026 · programming-languages · python · cpp · getting-started
Best Programming Languages for Robotics, Ranked by Goal
Python first for learning and perception, C++ for control code that ships, Rust where a crash is expensive, C on bare chips. Rank by your goal, not by opinion.
Python is the best first language for robotics, C++ for shipped control code, Rust for code nobody babysits, and C for bare microcontrollers. The ranking follows your goal, not the language, because ROS 2 and HORUS both accept several languages side by side, so the choice is made per part of the robot. That flips on a bare microcontroller, where C decides for you. The rest of this post is for a beginner with no robot yet, deciding what to open tonight and worried about wasting a year on the wrong choice.
Every answer you have found contradicts the last one. One video says learn Python, robotics is Python now. The next says any serious robot is C++ and Python is for toys. A comment underneath both says everything will be Rust in five years and you should skip straight there. Someone in a university lab tells you it is all MATLAB really. A job advert you half understand asks for all four.
Underneath that noise is a fear that is entirely reasonable: that you will spend six months getting fluent in something, buy a robot kit, and discover on the first evening that the thing you learned cannot talk to the thing you bought. Or the opposite fear, that you will pick the hard language out of guilt, spend three weekends fighting a compiler and a build system, and never get as far as a wheel turning. You have a limited number of free evenings and you would rather spend them on a robot than on a language argument you did not start.
Which programming language should you use for robotics?
Use Python, unless something specific about your robot rules Python out, and add a second language at the moment one part of the machine has to keep time. That is the whole ranking, and it holds because the goal decides rather than the language. If your goal this month is a wheel turning, a distance sensor you can read and a camera image on screen, Python gets you there on the evening you start, since the drivers, the tutorials and the examples for hardware a beginner buys are written in Python first. If your goal is control code shipping inside a product, C++ is where the frameworks, the vendor libraries and most of the jobs live. If your goal is code running for weeks on a machine nobody is watching, Rust removes a family of crashes at the cost of a slower start. If your goal is a motor board with no operating system on it, C is the only door in. Most robots end up with two of these, and that is normal rather than a failure to decide.
What does a robotics language have to be good at?
A robotics language is judged on three things a general programming course never mentions: how easily it talks to hardware, how it behaves once the machine has been running for a week, and how many examples exist for the exact sensor you bought. The first is why Python dominates the beginning, because the board you bought has a Python example in its documentation and the hour between unboxing and a blinking light decides whether you continue at all. The second is why C++ and Rust dominate the parts of a robot that must not hesitate, because a language that stops to tidy its own memory will do so at the least convenient moment. The third is the one people underestimate and the one that quietly settles most arguments. A language with no driver for your motor controller costs you a week writing one, and a beginner does not have that week to spend. None of the three is about elegance, and none is about which language a stranger on the internet respects.
Which languages are actually in play for robotics?
Five, and the list has been stable for years. Python is the entry point and the language of perception, scripting and anything acting at the speed a person would notice. C++ is the language of shipped control code, most vendor libraries and the majority of robotics job adverts. C is what runs on microcontrollers, motor boards and anything with no operating system underneath. Rust is the newer option for long-running code where a crash is expensive, still thinner on drivers but no longer exotic. MATLAB and Simulink sit slightly apart, common in control coursework and in companies that already own the licences. Which of these you can mix depends on what you build on: ROS 2 treats Python and C++ as first-class languages for writing nodes and surrounds them with an ecosystem of ready parts, while HORUS is a smaller open-source project under Apache-2.0 where Rust, Python and C++ processes read and write the same shared-memory ring buffers, so messages between them on one machine are never serialised. Choosing what to build on deserves its own evening of thought.
How do the languages compare side by side?
Read the third column before the first. Most language regret comes from choosing something whose assumptions did not match what the learner already knew, rather than from choosing something unsuited to robots.
| Option | Who it is for | What it assumes you know | When to pick it | When not to |
|---|---|---|---|---|
| Python first | Beginners, and anyone doing perception | Basic programming, nothing more | You want a wheel turning this week | The code must run on a bare chip |
| C++ | People shipping control code | Memory ownership and a build system | One part of the machine must keep time | You are still learning what a loop is |
| Rust | Code nobody will be watching | Ownership, borrowing, patience with a compiler | A crash at three in the morning is unacceptable | Your sensor's driver exists only elsewhere |
| C on a microcontroller | Motor boards and sensor boards | Registers, timers, life without an operating system | The chip has no operating system | You want libraries and a package manager |
| MATLAB and Simulink | Control coursework and teams already there | Control theory notation | A course or an employer requires it | You are self-taught and self-funded |
| Python and C++ under ROS 2 | Most teams building a whole robot | Two languages plus the framework's conventions | You want the ecosystem's ready parts | You wanted one language everywhere |
| Rust, Python and C++ under HORUS | Processes trading data on every tick | Ordinary nodes, plus one new tool | Several languages share one computer | You need a large package ecosystem |
No row here is wrong. The rows differ in what they cost you before the robot moves for the first time.
Which language fits you if you are teaching yourself in the evenings?
Python, and it is not close, because the scarce resource in a self-taught project is momentum rather than time. Evenings are short and they end when something stops working. What kills a solo project is not difficulty, it is the third consecutive evening lost to a build error with no robot movement to show for it, after which the kit goes in a drawer. Python removes most of those evenings: no build system to configure, an error message written in something close to English, and a prompt where you type one line and watch a motor twitch. That feedback loop is the entire reason beginners who start in Python finish more robots than beginners who start in C++. The counterargument, that you will have to learn C++ eventually, is true and irrelevant to the order. You will learn C++ far faster once a working robot sits in front of you and one part of it needs to keep better time, because then the language is solving a problem you have felt rather than one you were warned about.
Does your hardware decide the language for you?
Frequently, yes, and hardware overrules preference every time the two disagree. If your target is a microcontroller, a motor driver board or anything with no operating system, the choice is C, occasionally C++ with most of the comforts switched off, and increasingly Rust in specialist corners. Nothing else is on the menu, and the amount of memory on the chip is the reason. If your target is a single-board computer running Linux, everything is on the menu, and the deciding factor becomes which language your sensor's driver was written in. Check that before you decide anything else, because a beginner will not enjoy writing a driver from a datasheet. If your robot is a commercial platform, look at what the manufacturer ships, since their examples set the path of least resistance and fighting it costs weeks. And if your robot has both a Linux computer and a microcontroller, which many do, you are writing two languages whether or not you planned to, and the interesting question becomes how the two halves talk to each other.
How does your deadline change what you should write in?
The tighter the deadline, the more the answer collapses to whichever language already has the library. If you have a fortnight and a demonstration at the end, do not learn a language at all: use the one with a working example for your hardware, accept the ugly parts, and get the robot moving. If you have a term or a year, spend the first third in Python getting the whole robot working end to end, then rewrite only the part that misbehaves in something stricter. That order matters more than the languages do, because the part that misbehaves is almost never the part you expected. If you have no deadline, which is a real and enviable position, learn the harder language deliberately while a working robot sits next to you, so every concept has something to attach itself to. The failure pattern worth avoiding is picking the strictest language at the start out of a sense of duty, then finding that most of the year went on tooling rather than on the machine.
What does each language ask of you before it is useful?
Each language collects its fee at a different moment, and beginners are surprised by when rather than by how much. Python asks for almost nothing up front and collects later, when a program that grew for months starts failing in places nothing warned you about. C++ asks for a great deal immediately, a build system, headers, memory ownership and a compiler with famously unhelpful complaints, then hands back a program that keeps time once you have paid. Rust asks for a particular kind of patience, because the compiler refuses your program repeatedly for reasons that are correct and infuriating, and the payoff is code that keeps running while you sleep. C asks you to hold the hardware in your head with no safety rail if you drop it. MATLAB asks for a licence and a way of thinking borrowed from control theory. There is a fee none of them advertise: whichever you choose, you also owe the build and packaging conventions of the framework around it, which is often the larger bill.
What goes wrong when one robot uses two languages?
The trouble concentrates at the boundary, and it appears as data that is subtly wrong rather than as an error you can search for. Two languages in one robot is normal, and the code inside each language usually behaves. What breaks is the join: a message defined twice in two places with two people editing them, a field that means centimetres on one side and metres on the other, a timestamp taken when the message was written on one side and when it was read on the other. Nothing crashes. The robot simply believes something slightly untrue and acts on it, and you spend a weekend suspecting the sensor. The way teams avoid this is boring and effective. Define the message once, in one place, and generate both sides from that definition, so the two languages cannot disagree about what a message contains. Frameworks do this for you, which is a large part of what you are buying when you adopt one instead of passing data through files and sockets of your own devising. Whether to use one language or several is the decision underneath this one.
What do you give up by writing your robot in Python?
You give up control over when your code runs, and on most robots that costs nothing until it costs a great deal. Python decides for itself when to tidy up memory, and the interpreter does work between your lines that you never asked for, so a Python loop is punctual on average and occasionally distracted. For mapping, planning, logging or a behaviour tree, nobody notices. For a leg holding a body upright, that distraction is a stumble. You also give up the microcontroller, since the small chips will not run a Python interpreter in any form you would trust with a motor. And you give up part of the vendor world, because a manufacturer's own library often exists for C++ first, with the Python binding arriving later or written by a stranger. None of this argues against starting in Python. It argues for knowing which single part of your robot will eventually need to leave Python, and for keeping that part small and separate from the first week onward.
When is ROS 2 the better choice?
ROS 2 is the better choice whenever your language question is really a library question, which is most of the time for a beginner. If you need a driver for a common lidar, a navigation stack that already avoids furniture, a motion planner for an arm, or a viewer showing what the robot believes, ROS 2 hands you those in both Python and C++ and saves you months of writing them. If you are following a course, a book or a tutorial series, use what they use, because fighting your own teaching material is a poor use of a beginner's evenings. If you are aiming at a job, ROS 2 with Python and C++ is what the adverts ask for. And if your actual problem is that no driver exists for your sensor in your chosen language, HORUS is not the answer, because a message layer does not write drivers. The narrower case where a deadline-oriented layer earns its place is when several languages on one computer must trade data on every tick of a loop that cannot afford to be late.
Do you have to write robot code in C++ to be taken seriously?
No, and here is why the belief survives anyway. C++ dominates the visible surface of robotics: the framework internals, the vendor libraries, the conference papers with code attached, and the job adverts. Anyone reading that surface concludes that real work happens in C++ and everything else is a toy. What that reading misses is the shape of a modern robot, where the part that must be written carefully is a small fraction of the whole and the rest is perception, coordination, data handling, tooling and tests, most of which is Python in practice at companies whose robots you have watched on video. It also misses that the C++ around you was often written by somebody who started in Python and moved down when a specific problem demanded it. The version of this belief worth keeping is narrower and true: you will eventually need to read C++, because the library your robot depends on is written in C++ and one day you will have to see what that library actually does.
Should you skip C++ and go straight to Rust?
Partly, but not the way you think. Rust genuinely does what its advocates claim, since the compiler refuses whole categories of memory bugs that make long-running machines fall over at inconvenient hours, and for control code you intend to leave unattended that is worth real money. Where the advice goes wrong is the order. Skipping C++ entirely means you cannot read the library your robot depends on, cannot follow most tutorials for your hardware, and cannot take a job maintaining an existing codebase, which describes most robotics jobs. It also means learning ownership and borrowing as abstract rules rather than as answers to bugs you have suffered, which is a much harder way to learn them. The workable order for most people is Python to get a robot moving, then whichever of C++ or Rust the specific job in front of you demands, and Rust more readily than the internet suggests when the code is new rather than inherited from somebody else.
How do you decide which language to open this week?
Answer one question: what do you want to be true four weeks from now? If the answer is a robot that moves and a sensor you can read, open Python tonight, buy hardware with a Python example in the documentation, and ignore every argument about language quality until the wheels turn. If the answer is a specific job or a specific course, open whatever that job or course lists, because your goal has already chosen for you. If the answer is a motor board doing something exact with no computer attached, open C and a datasheet. If the answer is a product you will still be maintaining in two years, start in Python anyway, but keep the demanding loop behind one narrow interface so rewriting it in C++ or Rust later is a week rather than a rebuild. And if what is pushing you toward a stricter language is a robot that stutters, work out whether timing is really your problem before you blame the language.
Where that leaves you, in five lines:
- If you are starting from nothing and want a robot that moves -> Python, because the examples for beginner hardware are written there first.
- If you are shipping control code inside a product -> C++, because the vendor libraries, the frameworks and the hiring pool are all there.
- If your code must run for weeks with nobody watching -> Rust, because the compiler refuses the bugs that take machines down overnight.
- If your target is a motor board with no operating system -> C, because nothing else fits on the chip.
- If a course, an employer or a teacher has already chosen -> use their language, because fighting your own teaching material costs more than it saves.
The HORUS Fit Framework is the short version of that reasoning applied to whatever you build on: judge an option on five axes, which are ecosystem size, setup effort, team size fit, deployment target and licence, then pick the one that loses least on the axis you cannot afford to lose. Beginners lose most often on setup effort.
HORUS is open source under Apache-2.0 at github.com/softmata/horus. Star it so it is in your list when you start building.