What Language Does Arduino Use - C, C , or Processing?
The Arduino platform is a popular choice for hobbyists and professionals alike, but there's often confusion about its programming language. Is it pure C/C , or does it use a derivative of these languages? Or, is it actually the Processing language? Let's delve into the specifics.
Arduino: A Simplified Version of C/C
The programming language used in Arduino environments is often referred to as a simplified version of C/C . This simplified version was designed with microcontroller programming in mind, providing an easier and more user-friendly experience compared to traditional C/C development.
At its core, the Arduino IDE compiles your code using the GCC C/C compiler. This compiler targets the microcontroller's underlying hardware, specifically the AVR RISC processor used in most Arduino boards.
Why Not Just C/C ?
A common myth is that Arduino only uses plain C/C . However, several factors make it a bit more complex:
**Limited Memory**: An Arduino Uno, for example, has a mere 2KB (2048 bytes) of RAM. This restricts the amount of dynamic data you can work with, necessitating a more compact and efficient language. **Additional Libraries**: The Arduino environment comes with a vast library of functions and classes specifically designed for working with different hardware components, which simplifies the development process. **Restrictive Optimizations**: The language and compiler are optimized for the specific hardware, ensuring that the code is as efficient as possible for the microcontroller.Is It Micro - C?
Some sources suggest that Arduino uses a subset or extension of C, sometimes called Micro - C. While this might be a useful term to describe the simplified nature of the language, it's more accurate to say that Arduino is using a version of C/C that is tailored for microcontroller programming.
Since the Arduino board is based on the ATMega328P microcontroller, designed by Norwegian company Atmel (now part of Microchip), the instruction set is optimized for C/C compilation. This means you can write your code in a familiar C/C style, and the compiler will produce efficient machine code.
The Role of Assembly
While most of the code is written in a C/C style, there are instances where assembly language is used for performance-critical sections. The compiler can translate these assembly snippets into machine code, ensuring that the necessary operations are executed as efficiently as possible.
Processing vs. Arduino
Processing, on the other hand, is a distinct programming language and environment, primarily used for visual arts and graphics. However, it's important to note that while you can write Arduino sketches in a style similar to Processing, the underlying language is still C/C .
The Arduino IDE and Processing IDE share a similar history. Both were derived from the Wiring environment, which itself was inspired by the Processing IDE. Wiring was designed to be a more straightforward way to program microcontrollers, similar to Arduino.
Fully Explained
Arduino: Written in a simplified C/C with additional libraries and optimizations for microcontroller programming. Processing: Uses Java, but is similar to C/C due to its design. Wiring: Serves as the base for both Arduino and Processing, providing a simplified interface for hardware interaction.In conclusion, when programming an Arduino, you can think of it as a specialized version of C/C with additional libraries and optimizations. While it shares some similarities with Processing and Wiring, it fundamentally remains a C/C -based language, adapted for the unique needs of microcontroller programming.