A Hackaday writer has criticised the Arduino library for DigitalWrite,
stating it is too slow and thereby encourages bad coding practices.
The writer suggests that new developers should learn to code at a lower level,
using hardware peripherals and direct register manipulation to increase code efficiency.
This lowers the barrier to entry, however, as it requires knowledge of hardware
interfaces like SPI and I2C to use them directly in code.
The article also explores the perceived inefficiency of constexpr and generic programming in C++ and why DigitalWrite is slow.
The author suggests that the original designers of DigitalWrite deliberately optimised for ease of use and safety over speed, and that modern C++ features haven’t been fully exploited to increase the code efficiency of DigitalWrite.
Furthermore, the author suggests that DigitalWrite performs several checks internally which may not be apparent to the developer and these checks could be a source of unexpected latency.