I was never a big fan of using Arduino libraries (i.e. libraries written by people other than yourself), but this time it’s gone too far. They simply can’t be trusted. They do more harm than good. These libraries are evil. Do you think I’m exaggerating? Well cover your nose, because we’re about to go where things really stink!
To clarify, I’m talking about all the libraries one can use for the Arduino – those that come with the IDE and those you can find on the web and install.
Libraries Eat Your Brain
The whole point of Arduino is that with libraries and built-in functions, one can start doing fun things immediately, without being an expert on electronics and programming. And yeah, it works great for blinking some LEDs or rotating a little motor. But when things get just a wee bit more complex, this house of cards collapses because not only is the user clueless how to continue – he or she don’t even know how what they did so far worked. I’ve seen it happen to people a thousand times. The “there’s a library for it” attitude numbs the brain. It makes the users lazy. Too many of them prefer to ignore the details, skip the low-level learning and hope things will just work. You know something? They won’t.
Libraries Are Written By Satan
This is not meant as an insult to some good, honest folks who write and share libraries for the common good. However, anyone can publish a library without proper testing, debugging and/or documentation, and this frequently leads to serious monstrosities – libraries that either don’t work as expected, work with hidden bugs and hindrances, or don’t work at all. I’m not talking just about beginner programmers – you saw how a library by FTDI was useless, and recently I discovered that even Arduino’s own SoftwareSerial does not deliver as promised (more on that in a separate post, soon). You think debugging your own code is hard? Try to understand and debug code written by someone else! When you go beyond a certain level of project complexity, this kind of BS happens so often it’s just ridiculous.
The Road To Hell Is Paved With Semi-Decent Libraries
The fact that there are so many libraries available gives users the impression that they can use multiple libraries freely in a single Arduino project. Nothing could be further from the truth. Even if each and every library was perfect by itself, the people who wrote them could not predict all library combinations they would be part of. In simple words, libraries collide.
And how they collide! On every possible parameter, be it memory space, processing resources, interrupts, timers – whatever. The program may fail entirely, or intermittently, or have a disastrous hidden bug that will attack you only well after you think everything is done. Either way you’ll have to dig deep into the source code of all the libraries you use, in hope of being able to see it all together in your head to spot the culprit.
Now, you could read the library specifications that will tell you exactly what resources it uses and how, except no one writes such information, because they don’t know or don’t care.
No, I Am Not A Hypocrite
I do use Arduino libraries sometimes. It’s unavoidable. I need them to do things that would have taken me weeks to figure out by myself. They help me set up prototypes and tests quickly. But I don’t trust them. If there’s the slightest chance of problems, I actually read their code to get at least a sense of what’s going on. I even modify them on occasion. It’s like doctors, you sometimes have to see a doctor but you don’t want it to happen too often.
You Have Been Warned
I don’t expect people to stop using Arduino libraries after reading this. One has to be realistic. Still, from my personal experience and what I’ve seen happen again and again to others, I can assure you this: the more you rely on other people’s libraries, the more you suffer.
To minimize the suffering, there’s no other option but to actually sit and learn: learn the programming language and the specifications of the microcontroller. Your fancier projects will have to wait, but when they finally arrive, they will actually work and won’t drive you mad.