Hacker News new | past | comments | ask | show | jobs | submit login

This is how simple it would be in Clojure, for comparison:

    (defrecord Task [future task-sender])
Probably used something like this:

    (defn create-task []
      (let [future (atom nil)
            task-sender (async/chan)]
        (->Task future task-sender)))

Not sure it makes sense but a pretty much direct translation as far as it goes.



Having never used a lisp outside an AI class a quarter century ago, that isn't comprehensible to me, and I don't think it is just my lack of caffeine. The rust example makes more sense, but I've used rust for almost a decade at this point and c++ for over three. Familiarity matters.


But honestly only for a very short time. It took me two weeks of learning for Clojure to start looking completely natural to me. Surface syntax is such a trivially minor thing, which is why it seems ridiculous to me that the OP author even mentions things like "Swift uses switch rather than match, such familiarity" among other much more solid points.


Yeah, of course. If you show me Brainfuck or APL code I won't be able to make head or tails of it either. But familiarity should never stop one from learning new things, otherwise we miss out on a lot of simple, interesting and useful stuff :)


So it's the same but without type annotations? Meaning that the clojure IDE has a much harder time providing completion and that you need to write all sorts of tests to get the same guarantees as the rust compiler provides for free. Type systems aren't just about memory representation, they also tell the next programmer about the intent and performance characteristics of the code at hand.


That's why I moved from Scheme to Common Lisp, it's nice being able to do...

  (defstruct Task
    (future :type Future)
    (task-sender :type Sender))
And have SBCL warn me when I try to jam the wrong type in.


If you really badly want types, you'd slap something like this below it:

    (s/def ::future atom?))
    (s/def ::task-sender async/chan?)
    (s/def ::task
      (s/keys :req-un [::future ::task-sender]))

    (s/fdef create-task
      :ret ::task)

    (stest/instrument `create-task)
But then I don't think you'd reach for something like Clojure if static typing is something that you require.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: