3 ms·
This is what I've been thinking lately i.e. C and Lua (throw in LuaJIT too if speed is needed). But I've found out that using functional parts of modern C++ (b
by rwbt 3y ago
This is what I've been thinking lately i.e. C and Lua (throw in LuaJIT too if speed is needed).
But I've found out that using functional parts of modern C++ (bear with me) as a higher level language with C underpinnings also works very well. But you need tremendous discipline to do it successfully. For eg - using only C POD structs, no constructors, no exceptions, no inheritance, limited template usage etc. Some would say a very C style C++ with a lot of syntax sugar.
- dualogy 3y agoThat's how any C++ stuff of mine goes, "given the chance", ie. the self-contained, private/hobbyist stuff. With structs instead of classes you still have the convenience of instance methods (rather than just mynamespace_funcname funcs), statics, even namespaces (hardly necessary with methods and statics), yet can avoid inheritance and the whole public/protected/private noise (public by default, otherwise structs and classes are exactly equivalent in C++) except for the rare case where it does seem beneficial over a simple field.
- rwbt 3y agoI also stopped writing destructors (because eventually that leads to writing move constructors); instead now just use a unique_ptr to wrap resources (covers most of the cases) or a simple scope_exit (ala "defer"). Turns out separating ownership and lifetime really helps to write much better C++ code for me. These simple rules coupled with great modern C++ syntax sugar like lambdas, tuples and 'auto' along with the basic data structures in it's standard library makes it a breeze.
- nine_k 3y agoWhat you describe feels like a good way to write code for the Arduino platform.