←back to thread

110 points jackdaniel | 1 comments | | HN request time: 0s | source
Show context
adamddev1 ◴[] No.44972696[source]
Ah, in an alternate world where Brendan Eich wasn't pressured by his superiors to make JS more Java-like, we could have had something like this as very normal.

I wonder how much faster that would have pushed the world into FP ideas. While sometimes I prefer the bracket/C syntax, I wonder how things would have evolved if JS was a lisp originally. Instead of things moving to TypeScript, would they be moving to something like typed Lisp or OCaml, or PureScript ?

replies(5): >>44973351 #>>44973702 #>>44976138 #>>44976751 #>>44977298 #
behnamoh ◴[] No.44976751[source]
You say that as if FP is objectively superior to the imperative style, but as someone who's done both, I still find FP style like "swimming against the river"—if my brain thinks in steps and iterations, why do the mental gymnastics to convert that into recursion?
replies(2): >>44977017 #>>44986191 #
1. ux266478 ◴[] No.44986191[source]
FP is principally about function composition, folds and zippers. I still find myself thinking in terms of iteration, it's just not expressed as a for-loop. Instead, the iteration conditions are expressed by the composed function which builds a list, and the body of the for-loop is expressed by the composed function applied to the members of the list.

  for(int i = 0; i < N; ++i) { ... }
becomes

  foldl (fn (i, acc) => ...) 0 (range N)
It's technically recursion, but I don't really see any of it, and I don't really think about it that way.