3 ms·
I think people tend to think in terms of explicit state as a default rather than being forced to by poor syntax. I've had experience teaching amateurs and this
by greendestiny 19y ago
I think people tend to think in terms of explicit state as a default rather than being forced to by poor syntax. I've had experience teaching amateurs and this really tends to be bourne out in what I've seen. Students tend to find functional languages very easy to use until the problems start to involve things that need to change over time and then they can't get past the idea of storage.
- curi 19y agonothing about s-expressions is bad for using state and little nesting. something about C/etc is bad for nesting heavily. Edit: example. both lisp-style versions are nicer. if C has advantages, it isn't in making state work better. (def avg (numbers) (/ (sum numbers) (count numbers))) (def avg (numbers) (= total-number (sum numbers)) (= total-count (count numbers)) (= result (/ total-number total-count)) result) function avg (numbers) { /(sum(numbers) count(numbers)) } function avg(numbers) { =(total-number sum(numbers)) =(total-count count(numbers)) =(result /(total-number(total-count)) result }
- greendestiny 19y agoState in procedural languages has more to do with side effects than nice syntax for it. This article has a nice description of how why explicit state is good in procedural languages sometimes: http://prog21.dadgum.com/3.html http://prog21.dadgum.com/3.html