6 ms·
What was the motivation for including OO capabilities for a language targeted at embedded systems? The docs seem to make quite a fuss about the fact that it can
by not_knuth 6y ago
What was the motivation for including OO capabilities for a language targeted at embedded systems? The docs seem to make quite a fuss about the fact that it can do OO. As someone who doesn't work professionally in this space I was curious how the domain of embedded stuff is a good fit for thinking in OO?
- Banana699 6y agoNot the person asked, but OOP is a great fit for embedded devices IMO. Even the most superficial aspect, a mandatory init function called at creation time and a free function at destruction time, is such a powerful and general method of resource managment and reasoning about lifetimes that C++ folks made it a freaking ideology. Any generic, cliché driver code written in C almost always has the obligatory xyz_init and the corresponding xyz_free/reset boilerplate that has to be remembered and called manually by the programmer. Why memorize patterns when we have compilers though? Digging deeper, the hardware analogy is pervasive in OOP. Alan Kay called the internet the best and most successful OOP system, Brad Cox saw objects as "software ICs", message passing is explicitly and pervasively modeled after hardware protocols by both. Java was born from research that sought to make OOP the norm in embedded ("Java runs on 3 billion devices!"), and Ada was a reality 10 years before that. How do you define systems in Hardware Description Languages? you seperate the system into interacting thingies called "modules" whose state is strictly private and communicate through well-defined protocols, sounds familiar? its not a panacea off course, but modeling a black box machine whose behavior is defined by how it responds to messages - ideally how embedded devices should be designed - is the classic OOP sales pitch.
- mmedum 6y agoReally great answer! A large part of the motivation, is also making it easy to work with embedded devices. We try to take a lot of learnings from other languages, which our engineers have worked on, and mix in elements that makes it easy to create well architectured applications. In general we find that many OO principles provides a great foundation in the embedded space.
- not_knuth 6y agoThank you for taking the time to explain it so succinctly. This has to be one of the best comments I've read in a while. Now I can't wait to take Toit for a drive...