Link: “Role Of Algorithms”
Monday, August 14th, 2023 10:25Consider this part of my current series of programming advice posts. Role Of Algorithms, by matklad:
“Algorithms” are a useful skill not because you use it at work every day, but because they train you to be better at particular aspects of software engineering.
...
Second, algorithms teach about properties and invariants. Some lucky people get those skills from a hard math background, but algorithms are a much more accessible way to learn them, as everything is very visual, immediately testable, and has very short and clear feedback loop.
There's a lot here I agree with or at least consider worth thinking about. However, the article is focused on the process of learning to program, and I'd like to suggest a different perspective too: rather than “you don't use algorithms at work every day”, every single function you write can be considered as an algorithm. Many of them are trivial algorithms, but if you have the experience with looking through the algorithmic lens, you can notice as you write (or read) useful facts like:
- “Oops, this is going to be O(N²); can I do it more efficiently?”
- “This almost has an invariant or postcondition that …, but it could be violated if …, so let's think about where to check for that and what we want to do about it then, or what will happen if we don't check.”