4 ms·
I recently started arduino programming as well. What is weird is it’s basically the opposite of most software best practices. You need to use global variables,
by boatsie 5y ago
I recently started arduino programming as well. What is weird is it’s basically the opposite of most software best practices.
You need to use global variables, not use heap allocations, avoid stl library classes, avoid strings, etc. The constraints due to the minimal resources mean you need to throw out elegant and robust programming in order to perform well. So the code ends up looking super hacky.
- rhodozelia 5y agoIn embedded and machine control robustness is in simplicity. It is ok to repeat your self. PLCs until recently only had global variables and a great deal has been accomplished with them. A lot of machine controls and embedded work is more waterfally and less agile. Figure out what it has to do, make it do that, then it is done and you hand the machine or plant over to the customer and you can’t change it.
- rvense 5y agoMost Arduino code I've seen at the hackerspace I used to go to barely had anything defined as functions. Just setup and loop. There were people who coded for many years and did very cool stuff and they didn't know what a struct was.
- qiqitori 5y agoCalling code like that super hacky seems a bit weird to me. That's basically all I'd like to say, but to expand a bit (and possibly I'm missing your point somehow), in my opinion, "best practices" in software aren't "best practices" just because, but for reasons that may or may not apply in a specific situation. If they don't apply, then best practice dictates that they are no longer best practices. That said, I'm not sure what I'd consider to be hacky code in a constrained environment. Looking at https://www.reddit.com/r/learnprogramming/comments/3cd0x4/what_constitutes_a_hack_or_hacky_code/ https://www.reddit.com/r/learnprogramming/comments/3cd0x4/wh..., for example, many things people feel are hacky don't apply to Arduino programming mainly because there is hardly anything external to interface with.