5 ms·
Greenspuns tenth rule: “Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of C
by viksit 8y ago
Greenspuns tenth rule: “Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.”
I’ve always wanted a clojure style thread operator [1] in other languages :)
[1] https://clojure.org/guides/threading_macros https://clojure.org/guides/threading_macros
- emmanueloga_ 8y agoIt is interesting to note the overhead it has to define such simple construct in JavaScript. Pages and pages of a spec, all the work to herd ppl behind the proposal, etc. In Clojure, the threading macros are awesome and they are not even a language construct, just some ~10 lines of code per macro! [1] In ML, the pipe operator is even shorter: `let (|>) x f = f x` 1: https://github.com/clojure/clojure/blob/4ef4b1ed7a2e8bb0aaaacfb0942729252c2c3091/src/clj/clojure/core.clj#L1669-L1699 https://github.com/clojure/clojure/blob/4ef4b1ed7a2e8bb0aaaa...
- deleted 8y ago[deleted]
- andreareina 8y agoI used to think the same, until it was pointed out to me that the semantics have to be nailed down exactly, so that conforming implementations (e.g. Chrome/FF) do the same thing. This includes figuring out how (if at all) it works with generators and async functions, if you want to support implicit lambdas, etc[1]. Clojure and ML (and related languages I imagine) have the advantages that it is expressible in code which at least makes the specification part simpler. Fortunately the simple version is easily approximated, I have this sprinkled in various files where it's useful: const pipeline = (val, ...funcs) => funcs.reduce((a, b) => b(a), val); [1] https://babeljs.io/blog/2018/07/19/whats-happening-with-the-pipeline-proposal https://babeljs.io/blog/2018/07/19/whats-happening-with-the-...
- jhanschoo 8y agoThe converse is also true when you want to do side-effecty stuff in Haskell.