Hacker News new | ask | show | jobs
by munificent 2508 days ago
I think you're roughly right, though I shy away from "intuitive" since it can come across as excluding people who haven't learned certain things yet.

What I've observed is that a lot of learning programming is about becoming comfortable with thinking of more and more concepts as first-class entities. Turning larger pieces of code, procedure, and patterns into object/values you can pass around, hold, create, etc.

1. small-scale one I see a lot is that many programmers don't realize boolean expressions produce values. Instead, they think they are syntax that can only be used inside control flow statements. It is a mental leap to realize that you can go from:

    if (thing == otherThing) { doStuff(); }
    moreStuff();
    if (thing == otherThing) { doLastStuff(); }
To:

    var sameThings = thing == otherThing;
    if (sameThings) { doStuff(); }
    moreStuff();
    if (sameThings) { doLastStuff(); }
2. In some sense, recursion is about thinking of the procedure itself as an operation you can use even while being in the middle of defining the procedure itself. The mental trick is "Assume you do already have this procedure, how could use use while defining it?"

3. Closures are another big one where you take a piece of code and turn it into a value that you can delay executing, pass to other procedures, etc.