My hobby: answer beginner SO question after a night out

4 points by starmole ↗ HN
So, sometimes when I get home too early but still keep drinking I like to answer random stuff on SO. And every now and then, there is a random question that is so wrong and clearly by somebody just starting to learn programming, that it becomes a challenge to answer it.

In this case: http://stackoverflow.com/questions/18026506/i-need-something-similar-to-sleep-function-for-a-program-that-uses-opengl

I probably did a piss poor job as a teacher, but it got me thinking, how would one approach this in a functional language? I did my share of Haskell when it was still a pure academic experiment, but never really took to it.

So, how would a functional approach to this simple but natural problem look like?

2 comments

[ 2.7 ms ] story [ 15.7 ms ] thread
There are various methods and various languages. Scheme uses continuations, javascript can use futures/promises, sometimes you just see a 'yield' operator. Many of these ideas are close to Tony Hoare's 'Communicating Sequential Processes' paper/book [1], so if you want the low down, read the paper.

[1] http://usingcsp.com/cspbook.pdf

Thanks for the reply. I was really drunk when posting this, sorry :) I know how things are done in different languages. The thing that stumped "drunk me" was how much harder it would be to explain them. "sober me" realizes that my premise was wrong. I was answering a beginner imperative question. There is no good functional answer. A beginner functional question would be different and have a different answer. In reading my post it is kind of funny to see my own weird tunnel thinking - don't drink and think :).