Before I ask the question I realize that selection of a programming language depends on the context of a problem at hand.

Related to this I would like to know (if anyone) how many of you use which language for programming microcontrollers, embedded systems and even generally on PC.

Here is an example:

  • Webcam interface for face recognition. (USB or inbuilt)
  • Visualizing the data in real-time plus GUI.

Example languages which could be used for the above:

  • C
  • C++
  • Python
  • Java
  • C#

What do you recommend and why?

(I am asking this question because a lab I worked in were using Java to control a robot on wheels for object detection/avoidance etc. This seemed a bit wrong considering that for time critical apps. C or C++ seem to be good choices).

Dani AI

Generated

A pragmatic way to choose a language is to think in layers and let the constraints of each layer decide the tool. For the webcam + face recognition + robot example in the thread, separate the system into: (1) low-level firmware and motor loops, (2) real-time control/coordination, (3) perception (camera/vision), and (4) GUI/visualization. Latency, determinism, memory, and library support should drive the language choice for each layer rather than a single global preference.

Echoing , C (or a constrained subset of C++) remains the workhorse for microcontrollers because of tiny runtimes, predictable timing, and broad toolchain support. Keep ISRs short, avoid dynamic allocation and exceptions in time-critical code, favor static buffers and fixed-point where FPU is absent, and be cautious with heavy STL use on constrained targets. For control loops that must run with tight jitter bounds, choose bare-metal or an RTOS and measure worst-case execution times.

As noted, higher-level languages speed development. Python plus OpenCV and NumPy is excellent for rapid prototyping of vision and GUI code; it makes experimenting with detection algorithms fast. When profiling shows bottlenecks, refactor hotspots into C++ or use native bindings (for example via a C API, Cython, or pybind11) or leverage GPU acceleration on the SBC/PC. This preserves developer velocity while meeting performance needs.

Practical workflow: prototype perception in Python, define a minimal, well-documented messaging interface (serial, UDP, or ROS topics) between perception and the MCU, then port critical loops to native code only after profiling. Always test on target hardware, monitor end-to-end latency and packet loss, and keep responsibilities small and modular so parts can be swapped (language or hardware) without a full rewrite.

Recommended Answers

All 4 Replies

In Uni courses all we have used is C (programming microcontrollers), and now that I have started working (programming for different types of hardware/processors) C is also used. It seems it is the most portable. I think C++ is more widely used, but is slightly less portable.

It all depends on how fast you need to develop the program/robot, and how fast you need the program/robot, to respond or to perform.

Python would undoubtedly be easier to develop than C or C++, but you'll never get the responsiveness in Python or Java, that you would get in C/C++.

If I'm programming a car to drive itself in a race, or a fighting bot, then I'm using C/C++ - period. If it's for a 2 mph robot that traverses a maze, then Python/Java/C# would be my choice. Very fast action/reaction time, just isn't needed for a slow mover.

Thanks, this gives me an idea to the good way of thinking about the problem.

C/C++ for hardware interface which requires instant action and Python/Java for UI etc.

C++ (pronounced see plus plus) is a programming language. It was started in 1979 at Bell Labs as an enhancement to the C programming language.C++ is also used for hardware design...


-----------------------------------------------------------------------------------
Want to get-on Google's first page and loads of traffic to your website? Hire a SEO Specialist from Ocean Groups seo pecialist

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.