You could use a simplified Linux (without the X-Windowing and other graphics utilities that a robot may not need). Raspian-Lite is one such OS.
Then there are a number of robot frameworks that will run on the Raspberry Pi. They run under the Linux OS.
ROS (the Robot Operating System) is one of the most popular frameworks, but also the most complicated to learn. As Peter Parker learned: With Great Power Comes a Great Learning Curve. :)
ROS is written in C++, but can be accessed in a number of languages including Java and Python.
Go is a C-like language that is fairly easy to use, created by Google. I think of it as C's BASIC (Go is to C like BASIC is to Fortran). It compiles very quickly.
I am thinking of starting a Rust port of Gobot (Rust is yet another C-like language similar to Go, but it was designed to be as type-safe as possible. Many pointer errors common to C/C++ are caught by the Rust compiler.