Good magic just works. It’s invisible and you quickly forget that it’s there.
Bad magic works sometimes. It’s mysterious and hard to understand.
Good programming abstractions are the right kind of magic. You can depend on them and build on top of them with confidence.
Bad programming abstractions are the wrong kind of magic. It’s equally a mystery when it works as when it doesn’t work. They’re leaky and you end up spending more time cleaning up after the magic than benefiting from it.
Links to this note
-
Abstractions Save Time Working, but Not Learning
Software abstractions save us time doing work by not having to write programs from lower level building blocks. Programming languages like Python provide an easier way to write general purpose software than say, assembly language.
-
Keeping React Hooks With Usestate in Sync With Props
An annoying footgun with React hooks is using
useState
with an initial value fromprops
. It might appear like useState will be called each render, but it doesn’t (the bad kind of magic). Instead, it will run once when the component is initially rendered and you will run into stale read bugs when you rely on props to re-render the component with updated data.