by sramsay · 12y ago · 0 comments
I really enjoy functional programming, and with those two libraries I feel like I'm writing in something approaching Clojure (but with less ceremony, faster startup times, a truly colossal user community/ecosystem, and less memory bloat). I never thought I'd say this about Javascript, but it clicks off more items on my dream-language list than anything else I've used (and I've used at least a dozen, across several paradigms).
It's honestly fun to write in JS these days (at least for me).
- https://github.com/puffnfresh/bilby.js
- https://github.com/fantasyland/fantasy-land
- https://github.com/baconjs/bacon.js
- https://github.com/kriskowal/frb
- https://github.com/swannodette/mori
- And essentially all things PureScript: https://github.com/purescript/purescriptThe language looks good and it seems to be somewhat popular with more than 700 stars on GitHub. Thanks for the suggestion!
That stuff is definitely getting you pretty close to Clojure.
Edit: While I use it primarily for ajax, skipDuplicates and flatMapLatest are a godsend for building autocomplete
This is a small command-line program that I use to compute grades (I have larger stuff, of course, but this one is easy to follow).
There are important differences between Clojure and Javascript (cum lo-dash and Immutable). Perhaps the most important overall difference is that Javascript is never mandating immutability -- you have to watch carefully (and I'm probably screwing it up a few times in that code). In fact, I just noticed a bad example of mutating state when I pasted it. :( I also use imperative constructs from time to time, but I like that I can.
I originally wrote this code using JS's object system. I absolutely hated it (and I do understand prototypal inheritance quite well).
What's more important to me, is that actually writing the code feels "lispy." In that code, you'll see all the classics (especially as you move down): each, map, range, zip, and compose (my favorite). Lo-dash, of course, has many, many more.
Of course, I have no idea what your use-cases look like . . .
You should look into it.