Why Arduino Libraries Suck

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.

4 thoughts on “Why Arduino Libraries Suck”

  1. New Arduino user so pardon the long delay in commenting.
    I found this post by searching for Arduino libraries suck. You are so right. Not only for your reasons but for many more. Libraries often don’t compile cleanly. WTF.
    The example code doesn’t work, often doesn’t compile and is totally lacking in comments. Basically the authors are saying read our minds.
    This includes libraries published by the Arduino group, Adafruit, et. al. All organizations you would think are dedicated to a quality product.
    What is needed is a repository that only includes code vetted by others to meet a minimal level of rigor and documentation.

    1. I like your choice of search keywords 😀
      Part of the problem, as time goes on, is that there are new Arduino boards and updates to the IDE itself that may no longer be compatible with older libraries. But let’s be honest: if there was a vetting on libraries, how many libraries would actually be written and published? 😉

  2. While I believe you are correct about the libraries, I contend that the problem is with the C+ language structure itself. I have written extensively on the topic, however the material is scattered throughout my blog over a period of decades (talesfromthetrailercourt. blogspot).

    I refer to C+ as “count the feet and divide by four” programming; the standing joke is the it is called C+ because that is the average grade of the people who use it.

    Thank you for your excellent and accurate review of these libraries. I have included a link to your comments in my blog of November 8, 2017.

    I believe that C+ is a degenerate step in programming and one of the worst languages ever invented. One spends more time searching for punctuation errors than actually writing code. It is not self-documenting and cannot be attractively formatted.

    Furthermore, I do not believe C+ is any kind of improvement. It’s command set contains no new features that were not pioneered long ago in BASIC and COBOL. Thus any claim that C+ is elegant or improved is not consistent with the facts.

    1. Thanks for the comment. I’m not an expert on any programming language, so in that respect I can only say that indeed C++ seems messy. However, I still believe that the Arduino library situation is well below the level where language choice actually matters.

      Good microcontroller code requires only a small subset of C++; even C can be more than enough. The programs are usually short, too – a few hundreds lines of codes, without any super complex data structures. So it’s not the language limitations that come into play here, merely the inexperience of the programmers – and the lack of a systematic review and selection of these libraries.

      To quote you back… the issue is really “libraries are written by Satan”, not “libraries are written in Satanic programming language” 🙂

Leave a Reply to igendel Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.