6 ms·
Functional Programming in JavaScript: A Collection of Hands-on Exercises
- damncabbage 12y agoTo just see the content on the page, paste this into the console: $('body').append('<style>.lesson,.post{visibility:visible;}</style>'); (I enjoyed reading the content, but found it infuriating to skim.)
- ObviousScience 12y agoWow, it's terrible UI to hide most of your content until I complete a challenge when all you're making is an educational piece. I wanted to read it, then noticed most of the page as blank space, shrugged, and moved on.
- gt565k 12y agoSame. I literally scrolled down, didn't see anything, so I figured the page must be buggy / not working and I closed it...
- agumonkey 12y agoIt was design for IRL teaching. That said, if you know FP already and want to see what they say about it, it's annoying to go through the steps manually. Time to hack the class I guess. Functionally. jQuery(".lesson").css("visibility","visible")
- mattpodwysocki 12y agoRxJS author here and creator of some of those exercises. This was meant as a hands on lab where we proctor the event. We've given this at a number of conferences including QCon, CodeMesh, among others to great success. If you have suggestions, please do file an issue and I'll make sure we get them addressed: https://github.com/jhusain/learnrx https://github.com/jhusain/learnrx
- michaelmior 12y agoI just consistently get the following on Firefox TypeError: verifier is not a function
- blackkettle 12y agosame. seems to work only in safari and chrome.
- Nyubis 12y agoSame here. More and more websites seem to target only Chrome (or Webkit), it's the IE6 situation all over again.
- acqq 12y agoSorry! I wanted to upvote. I'm also trying to find out how the the downvote got registered. Edit: I've found it, it's curiously related to the "which browser" discussion(!): https://news.ycombinator.com/item?id=8475210 https://news.ycombinator.com/item?id=8475210 (Posted from the Firefox this time!)
- mattpodwysocki 12y agoRxJS author here. I'll make sure that it's more cross platform as I do actually work for Microsoft. This has been a Netflix only training platform, but in order for us to teach more, we have to be better about supporting all browsers.
- DCoder 12y agoFunny, an issue for that error was filed back in March 2013: https://github.com/jhusain/learnrx/issues/9 https://github.com/jhusain/learnrx/issues/9 And a pull request fixing it was submitted back in August: https://github.com/jhusain/learnrx/pull/27 https://github.com/jhusain/learnrx/pull/27
- bcrescimanno 12y agoFormer Netflix employee here; I think I can give some context (and I'll ping @jhusain to let him know this is here if he wants to chime in). These tutorials were created initially to share functional programming concepts with Netflix engineers who were unfamiliar with FP. Jafar created these exercises and taught classes using the material here as the primary source material for the courses. This was all back in 2012 into early 2013 when Netflix was going big with Reactive Extensions. What good is Rx when a huge number of your team don't really get FP--let alone FRP. I know a lot of folks have found these exercises useful. I think the odd format of not showing further material until an exercise is complete was more tailored to the structure of the class that these accompanied rather than something meant for standalone presentation online. That said, the exercises are still quite valuable.
- seanmcdirmid 12y agoI know this is pedantic, but are we still calling Rx as FRP? It doesn't even work well to Rx's advantage (simplicity): grokking Rx can be much easier than grokking FRP, which is much more pure and restricted (though also more powerful).
- mattpodwysocki 12y agoRxJS author here. We on the RxJS team have never called RxJS FRP as we do not have a continuous notion of time, instead we have a notion of virtual time. That and we do not distinguish between events and behaviors as they all are Observable objects.
- seanmcdirmid 12y agoVirtual time as in Jefferson's Time Warp system?
- mattpodwysocki 12y agoAs in you can specify the time at which things execute and swap out the concurrency model at any time. This makes it perfect for testing: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/schedulers.md https://github.com/Reactive-Extensions/RxJS/blob/master/doc/...
- softbuilder 12y agohttp://underscorejs.org/ http://underscorejs.org/ For those not already familiar with it, Underscore is a wonderful functional programming library that lets you code in a functional style while insulating you from many of Javascript's quirks.
- yazaddaruvala 12y agoTo be more explicit. Underscore is a great library and it let's you use functional programming concepts on collections. However, RX is about unifing that use to streams and more familiar events.
- yazaddaruvala 12y agoSummary: I wouldn't skip this great tutorial because you've used Underscore and think some of these concepts are similar.
- nawitus 12y agoI think Lo-Dash is a better alternative.
- thejosh 12y agoNot trying to start a flamewar, but are there instances where you would use underscore instead of lodash?
- dustingetz 12y agoyes, for example, https://github.com/documentcloud/underscore-contrib https://github.com/documentcloud/underscore-contrib
- ninjaplease 12y agoYou could theoretically use this on top of lodash though, correct?
- Yadi 12y agoOh I love this Thanks! Gotta try some of them out!
- unknownBits 12y agoType error: verifier is not a function. is what I got for the first exercise.. Btw, keep it real and solve in CS like so: console.log name for name in ["Ben", "Jafar", "Matt", "Priya", "Brian"]
- pluma 12y agoI'm pretty sure the exercises are called "Functional Programming in JavaScript", not "Functional Programming in CoffeeScript".
- aikah 12y ago2 very good "donationware" books about javascript functional programming,for those who want to study it in depth : https://leanpub.com/javascript-spessore/read https://leanpub.com/javascript-spessore/read https://leanpub.com/javascript-allonge/read https://leanpub.com/javascript-allonge/read please check it out and tip Reg,frankly his work is outstanding.
- andrzejsz 12y agoFrom what I can see functional programming is significant but not only part of javascript allonge and javascript spessore contains references to fp but it doesn't seem to be focus of this book
- aikah 12y agoSorry but these books are in my opinion the best one can find about FP in JS,and I read a lot of them,especially allongé,which goes in detail in a lot of advanced FP concepts.You should actually read these books.
- andrzejsz 12y agoI did not deny that FP is leading theme in javascript allonge quite the opposite but it does not apply to javascript spessore I am afraid
- klibertp 12y ago"Allonge" is very much about FP and - more importantly! - about the uses of FP in a language with mutable state, objects and so on. It's more pragmatic and immediately useful than The Little/Seasoned Schemer, but this doesn't make it any less about FP. "Spessore" is about OOP, but described from unusual angle: it reminds me of "The Little Java, a Few Patterns" in this regard. It's a great description of how and why OOP works, from the most basic concepts up. Reg's articles on FP in JS and Ruby let me fill the gaps in my knowledge I had because of having no formal education in maths. I was interested in FP for years, and I learned much about it on my own, but Reg's texts made it all "click" for me. I definitely recommend reading all of them; unless you're really familiar with this stuff, from both theoretical and practical sides, I can guarantee that you'll learn something new and useful. Really, go read them. See also https://leanpub.com/coffeescript-ristretto https://leanpub.com/coffeescript-ristretto if you prefer CS.
- Noelkd 12y agoIf you want a version that works in firefox: git clone https://github.com/M0ns1gn0r/learnrx.git And you can keep it forever!
- rcfox 12y agoI don't know if this was obvious to anyone else, but based on the comments here, the tutorial seems to be discussing RxJS[0]. The tutorial itself makes no mention of using any libraries. It's a little disappointing because the Observable object sounds like a neat way of solving some complexity that I've run into recently, but I'm not sure that I want to pull in a whole library for it. [0] http://reactive-extensions.github.io/RxJS/index.html http://reactive-extensions.github.io/RxJS/index.html
- mattpodwysocki 12y agoThe RxJS author here. This was meant to be training for Netflix team members to become familiar with RxJS as they use Rx for pretty much all of their systems, whether front end or back end. We've made great strides recently making Rx more accessible including making it easier to pull in only the things you want/need: https://github.com/Reactive-Extensions/RxJS/releases/tag/v2.3.12 https://github.com/Reactive-Extensions/RxJS/releases/tag/v2....
- jhusain 12y agoOriginal Author here. I fixed the Firefox bug and merged a pull request to allow answers to be transferred to other browsers. I will add a Show All Answers button soon for folks who just want to browse. rcfox: These exercises teach functional programming concepts, and that includes composition as it applies to the Observer pattern. I use RX but you could also use bacon JS or build your own lightweight Observable library. You should check out rx.lite.js which is a minimal subset of the library. As for your concerns about including a library, I urge you to reconsider if you can afford the extra download size. The Observer pattern is ubiquitous in software and you'll be amazed how versatile Rx is. At Netflix we use it on the server and client for a wide variety of different tasks. Rx has more than paid for itself 10 times over.
- mattpodwysocki 12y ago@jhusain not only that but we did introduce a CLI which allows you to bring in only what you need: https://github.com/Reactive-Extensions/RxJS/releases/tag/v2.3.12 https://github.com/Reactive-Extensions/RxJS/releases/tag/v2.... Still in its early days but is very promising for making RxJS as small as you wish.
- ibash 12y agoI went through this tutorial a few weeks back. It's very well laid out and by the end of it you really want more lessons.
- levlaz 12y agoThis is very helpful! Thanks to OP for sharing. :)
- deleted 12y ago[deleted]