Hacker News new | ask | show | jobs
by dan-robertson 2784 days ago
One thing which I think might be useful for speaking code is to try to avoid needing a mental stack or going backwards as you go through code (at least for English speakers. Maybe other languages are different). For example consider reading aloud:

  x = some_function(something_else(y), z)
You first need to keep in mind “x =”, then “some_function”, then think about what something_else(y) means, remember about some_function, think about z, then remember it all goes into x.

Now compare:

  something_else(y)
  -> some_function(z)
  :> x
Read forwards as “do something_else(y), now take it and do some_function to it, modified as z; now put it into x.”
1 comments

Yes, for me SQL is very hard to reason about just because of the way it's "phrased"

It's much easier for me to interpret JavaScript or PHP method chaining. I find myself struggling when I can't use an ORM.

I disagree with this. I think sql is actually mostly very good, with the exception that maybe the FROM clause should come before the SELECT.
It's probably just the way my brain works. After a SQL statement goes to more than ten lines or so I have to study it very hard to understand what's going on.

Maybe it's the way I was taught.