4 ms·
The thing that changed my mind about Node (and Javascript in general) was the discovery of lo-dash and Immutable. I really enjoy functional programming, and wi
by sramsay 12y ago
The thing that changed my mind about Node (and Javascript in general) was the discovery of lo-dash and Immutable.
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).
- calebm 12y agoI didn't mention that, but I totally agree. Maybe it's because of the lack of good OO support, but people don't freak out when you do functional programming in javascript.
- sillysaurus3 12y agoWould you mind copy-pasting some example code? Ideally something similar to what you'd write in Clojure and solves some real-world problem? (The more code you can paste, the better.) I'm quite curious to see whether the claim is true about being able to write something approaching Clojure while solving real-world problems.
- erichmond 12y agoAgreed. We have both clojure and node services in production here and the use cases for each technology is quite different.
- sramsay 12y agoThe big Clojure use-case for me has been Java interop. Aside from that, I'm not sure I'd prefer it to node. Of course, I have no idea what your use-cases look like . . .
- sramsay 12y agoOkay: http://pastebin.com/r40TN3Ni http://pastebin.com/r40TN3Ni 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.
- k__ 12y agoFor me it was the discovery of LiveScript. You should look into it.
- hashtree 12y agoHeck yeah, be sure to also check out: - 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/purescript
- calebm 12y ago+1 for mori. Lovely Clojure goodness :)
- egeozcan 12y agoPureScript was something I've never heard of. Took me a few clicks to see some code though: http://docs.purescript.org/en/latest/intro.html http://docs.purescript.org/en/latest/intro.html The language looks good and it seems to be somewhat popular with more than 700 stars on GitHub. Thanks for the suggestion!
- hashtree 12y agoIt's an absolute dream come true for Haskell-ers. Doing server-side in Haskell and client-side/small services in PureScript is... just wow. Anyone in the Colorado area, we have quite a few amazing FP folks here (e.g. Brian McKenna) and there is a PureScript meetup Oct 1st: http://www.meetup.com/Boulder-Haskell-Programmers/events/199566292/ http://www.meetup.com/Boulder-Haskell-Programmers/events/199...
- sramsay 12y agoWow, thanks. I didn't know about fantasy-land and bilby. Hard core. That stuff is definitely getting you pretty close to Clojure.
- findjashua 12y ago+10 for bacon.js!! Edit: While I use it primarily for ajax, skipDuplicates and flatMapLatest are a godsend for building autocomplete