Approaching Programming From First Principles
A possible approach to programming is the “throw mud at the wall and hope it sticks” approach. This consists in the following steps:
- Some behavior from the program is desired;
- Searching and copying snippets from online sources;
- The code is continually tweaked and the desired behavior is eventually achieved.
The approach which I think is more technically sound goes as follows:
- Some behavior from the program is desired;
- Start reasoning from the available tools on how to best achieve it;
- Compose the tools in a logical way and use online sources as technical references;
- While the end goal is not achieved, reconsider where the reasoning may be incorrect or incomplete.
I find the second approach to have the following advantages:
- The solution starts from the programmer's own mental model about the problem-domain and the tools at their disposal, which allows...
- Challenging the mental model, revealing where it is inconsistent with reality or where it is still incomplete, which leads to...
- A solid understanding about what are the capabilities, limitations and trade-offs of the available approaches.
I believe the value of reasoning from first principles -- as represented by often starting a reasoning from a smaller set of “solid” ground -- is that we keep refining and deepening our understanding about the fundamentals by continuously challenging it against new scenarios.
While the particular applications, problems and solutions do change over time as the computing industry evolves, having a firm grasp of the fundamentals undoubtedly pays dividends over time.
Reasoning from first principles succeeds where the “analogy” approach falls hostage to being presented a similar previously achieved solution. It allows one to tackle novel problems with confidence.