Ask HN: What is the single most important concept to understand for programming?
Or alternatively - what was the single concept that made you have an "Ah ha!" moment where everything you had read about and learned before fell into place?
I ask because nearly a year ago - I finally had my "Ah ha!" moment. Now, while I always had understood arrays on a basic level, they never truly "clicked" with me and I often found it difficult to read from or manipulate multi-dimensional arrays. One day though - it clicked and everything else fell into place. My efficiency skyrocketed and I went from feeling like a script kiddie to feeling I actually finally understand what's going on.
I'm going to be in charge of training some juniors at the company I work for. I believe good teaching should focus on the things that provide the greatest value for understanding - so I'm crowdsourcing other peoples' epiphanies in hopes of giving my juniors their own. :)
15 comments
[ 3.5 ms ] story [ 42.3 ms ] threadMy pragmatic answer is OOP.
https://en.m.wikipedia.org/wiki/Abstract_syntax_tree
Point 1: if-else, loops, arrays, pointers. Fizzbuzz is a surprisingly clever exercise which covers all the hard parts.
Point 2: Project management, i.e. to-do lists and Agile. Without it, there's the paralysis of having "too much" to do.
Point 3: OOP.
Point 4: Hacking. The delicate balance between planning and winging it, and getting the best ROI out of technical debt.
Others more concrete ones include recursion, how to build simple VMs, and many data structures.
1) Compositionality - primarily via functions which implement substitution, but also composition of larger program units, e.g. via (ML-style) modules.
2) Recursion and induction -- sure, imperative languages make recursive solutions impractical, but ultimately most data structures (including programs) are defined inductively and algorithms on them are most clearly defined recursively.
3) Abstraction vs. representation (e.g. via existentials/modules, not necessarily or even primarily via OO).
I don't think these things are particularly complicated (although the proper semantics for modules is) but can't be learned overnight.
My most recent:
If you are working on PHP associative arrays are the secret sauce, once you grok that with HTML forms, session storage, and DB fields you will rock.
From that you directly get other key concepts:
OOP principles (minus inheritance): What objects hide is as important as what they expose.
Test-Driven-Development: Code the test, then fix the code to pass the test.
Build only what you need: Components should be as simple as possible but no simpler. Keep the future in mind but don't build future features until they are needed (and better understood).
Nothing is made of magic. Everyone cooks with water. That doesn't mean everything has to be simple or easy, and understanding the theories behind things can be really challenging, but it shouldn't keep us from opening the lid of things once in a while.
While there's a lot of people in programming that are naturally inclined to do that anyway, there are also those who don't dare venture into how something works, which is one of the biggest reason for cargo-culting in my view.
Plus, if you're willing to look at how established things work at least at some level, you're pretty much guaranteed to find useful insights.
2 things I always try to pass on are:
Whatever you write, you don't write for yourself but for the company. (e.g. one-liners that make others waste time)
Team's efficiency is more important then your own (e.g. 10 boring minutes can save hours for next dev).