Hacker News new | ask | show | jobs
by vasco 673 days ago
People think imperatively though. If I think of visiting my friend, grabbing gas on the way back, the way I'll visualize the steps is not functional.
4 comments

I disagree. People are sometimes just forced to think imperatively when dealing with computers, but I usually think declarative when I design my programs.

Say if I want to filter a sequence of users and omit users below the age of 18, I'll construct my predicate (a "what"), and want to apply that predicate to create a new sequence of user (another "what").

I really don't want to tell a computer how to process a list every single time. I don't care about creating an index first and checking the length of my list in order to keep track that I process each user in my list sequentially, and don't forget that important "i++". All I want at that moment is to think in streams, and this stream processing can happen in parallel just as well for all I care.

But I also do think Python, Haskell etc. are the most expressive here with list comprehensions. It can't get more concise than this IMHO:

  users_adult = [
    user
    for user in users
    if user.age >= 18
  ]
That's quite debatable.

In this case, you first declare the end-goal - visit a friend and have full gas tank, with the actual steps to achieve them being much less important and often left to be defined at a later point (e.g. which particular gas station, which particular pump etc.). This corresponds more to functional thinking.

An imperative thinking would correspond more to "I will sit in the car, start the engine, ride on highway, stop at address X, converse with Y, leave 2 hours later, stop at gas station X" - in this case the imperative steps are the dominant pattern while the actual intent (visit a friend) is only implicit.

Your second part is how I think and how I think most people think. That's exactly what I meant.
So when you arrange the visit with your friend two weeks in advance, you first think about sitting in the car, driving out of the garage, getting on the highway, turning on the radio, parking the car, ringing the bell and this other myriad of actions, and the actual talking with the friend is just one of the actions, with no prominence over the others?

I certainly don't think like that. My main goal is to visit a friend. The transportation is subordinate, it's only a mean to the goal, an implementation detail which I don't care about much. I might even take a train instead of driving the car, or even ride a bike, if I feel like it and the weather is nice on the day of the visit.

Now reflecting on this, I think such focus on the process (as opposed to focus on the goal), exact imperative order, not being able to alter the plan even if the change is meaningless in relation to the goal, is a sign of autism. But I don't believe most people think like that.

No, we just think "I'll get in the car and drive to the hospital, talk to my sick friend, and then drive home by way of the petrol station". Higher-level, but definitely still procedural / imperative. (Then while we're driving we'll think "I'll turn left here" or "I'd better overtake that lorry", or whatever. But we don't need to plan all that beforehand; we do stepwise refinement on-the-fly.)

I think most people think more or less like that, and that it is not "a sign of autism".

You're the one that added all those conditions about exactness, about needing to replay every step (even this is a problem because steps are fractal), or not being able to change the plan. I can think imperatively and still do those :)
I dont know a lot about the brain but I do know that people that research modeling brains have used models in which there are two types of things to think: declarative things AND procedural things. See SOAR and ACT-R.

The caveat here is to which extent computers have tinted their models of a brain, but they are professional cognitive researchers so I’d give them the benefit of the doubt :)

While I think of things in a defined order, I also think in sets. If I grab a bunch of peanuts, I don't visualize grabbing every single peanut one by one, I visualize getting a bunch at the same time.
If you grab a bunch of peanuts you're probably thinking in "hand fulls", but the fact that the world and actions we take are fractal in the way we can analyze them doesn't prove one or the other.