Think in Math. Write in Code
13 days ago
- #mathematics
- #problem-solving
- #programming-languages
- Programmers often integrate programming languages into their identities, debating their merits and associating them with personal values.
- Programming languages are primarily tools for instructing machines, not for expressing thoughts, which are better suited to free and flexible mediums like mathematics.
- Mathematics, often misunderstood as rigid and symbolic, is actually about creating logical models to solve real-world problems through definitions and deductions.
- Effective programming involves solving logical problems first (steps 1 and 2) before implementation (step 3), with math providing clarity and better code outcomes.
- Programming languages are burdened by implementation concerns, distracting from the core problem-solving process.
- Abstraction in programming (black boxes) hides details but is rigid and leaks, unlike mathematical abstraction which is flexible and adjusts to the right level of problem-solving.
- Math allows reasoning about problems from multiple perspectives (e.g., formulaic, geometric, algebraic), enhancing understanding and solution design.
- Programming languages' rigid data representation forces early commitment to specific structures, whereas math allows problem-solving before choosing representations.
- Example: Graph representations vary widely based on use cases, making reusable libraries impractical without forcing inappropriate structures.
- Modern language features like async/await succeed by addressing practical implementation issues without introducing unnecessary theoretical complexity.
- Thinking in math encourages a 'C style' of programming—tailored solutions with carefully chosen trade-offs, avoiding unnecessary abstraction layers.
- A practical example of mathematical thinking in programming: designing a cryptocurrency pricing API, where rigorous definitions and theorems clarify assumptions and improve outcomes.