Hacker News new | ask | show | jobs
by alkonaut 1096 days ago
Yeah that's exactly why (I imagine) the first course in programming I was taught at University was Haskell. All of us who had been programming since age 8 had to reset our brains. A fantastic strategy for a curriculum if you ask me.

Lisp/Scheme/Clojure I'm sure are elegant and great for the same reasons as Haskell. They have unique traits that work well for teaching CS concepts.

I have one single issue: the syntax. I'm not getting past it. I'm 45 years old and have coded since age 8. I have tried and failed to manage learning or reading Lisp many times. I have tried picking up clojure, reading SICP I have had to tinker with AutoCad (AutoLisp) stuff for work. I'm just accepting that I'm not going to enjoy doing anything Lisp-related to the point where I'll ever manage to usefully read SICP, or learn one Lisp-y language to the point where I'd choose it for anything. And frankly it doesn't matter. I just accept it and move on. And I also understand that I can gaze at some Typescript monstrosity with sixteen levels of curly brackets, and while it's terrible syntax, my brain accepts it. But I can only imagine that it's 30 years (or just 1, who knows!) of curly bracket coding that makes my brain able to swallow that. But I'm not ready to invest even a week or two of time in teaching my brain to accept Lisp syntax.

1 comments

While I had a class in '94 using LISP, it wasn't until dabbling with using "compute pi using pi/4 = 1/1 - 1/3 + 1/5 - 1/7 ..." as a replacement for FizzBuzz. In 2013 (and I can point to the date) I was also playing with Clojure and wrote:

    (defn pi
      ([] (float (* 4 (pi 1 0.01 0 true))))
      ([term tol accum pn]
        (let
          [t (/ 1 term)
           a ((if pn + -) accum t)]
          (if (< (* 4 t) tol)
            a
            (pi (+ term 2) tol a (not pn))
          )
        )
      )
    )
While I won't claim that that is beautiful Clojure, the `((if pn + -) accum t)` part was a lightbulb moment for me about how LISP and functional programming really worked.

With Java 8 (and beyond) I've become comfortable with passing around functions themselves or creating a Map<String, Function> or having an enum with a function field.

    if (type == enum.FOO) {
      UnaryOperator<String> trim = s -> s.replaceFirst("^0+", "");
      idFun = trim.compose(DTO::getFooNum);
    } else {
      idFun = DTO::getBarNum;
    }

    // ...

    Set<String> ids = results.stream().map(idFun).collect(Collectors.toSet());
As to LISP-ish concepts with {} syntax... https://en.wikipedia.org/wiki/Schwartzian_transform

    @sorted = map  { $_->[0] }
          sort { $a->[1] <=> $b->[1]}
          map  { [$_, -s $_] }    # get the size of the file on disk
          @files;