Skip to content

Comment on How I lost my faith (in Lisp)parent

Comments

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.

nothing 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
  }

State 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

lisp can do side effects. as i demonstrated. what's the problem?

"... some people prefer not to commingle the functional, lambda-calculus part of a language with the parts that do side effects. It seems they believe in the separation of Church and state." --Guy Steele

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.