Live data from Hacker News

Functional Programming using JavaScript

scott.sauyet.com

31–40 of 88 posts

Re: Functional Programming using JavaScript

#31

Intrestingly it seems that the functional version he proposed is much faster than the OO version. http://jsperf.com/oop-vs-ramda

(Author of that talk (and co-author of Ramda) here. Your perf test only times the parsing of the function -- not exactly fair.

Re: Functional Programming using JavaScript

#32
post #17

finally, a slide deck that uses `history.replaceState` instead of `history.pushState`. no more having to hit "back" 90 times to exit the deck. how the latter ever became a pattern is beyond me. [EDIT] it probably became a pattern because of browsers that didnt implement the history API, so all hashchange events were pushed onto the history stack.

To be honest, using replaceState for this doesn't seem to make sense to me. A user would probably want to go backward and forward through this using browser history navigation (for instance using the navigation buttons on their mouse). If you're launching a link from a page you expected to come back to, surely opening the link in a new tab would be the way to accomplish this?

Yelp does this with its photo gallery, and it's really annoying.

When the user is in a linear sequence such as a slide deck, photo gallery or similar, the "previous"/"next" buttons don't map to the browser's back/forward buttons, they navigate the sequence. Littering the history with the navigation history of this sequence does not make sense.

However, it'd be nice if browsers could perhaps record the history (perhaps as some kind of sub-tree history), allowing me to see that I not only visited this slide deck, but that I also visited these specific slides.

Re: Functional Programming using JavaScript

#33
post #6
post #4

There is also @fogus' book: http://shop.oreilly.com/product/0636920028857.do I haven't read it yet.

It's a fantastic book for getting your mind used to the functional way of thinking. I'd also recommend JavaScript Allonge on the same topic. https://leanpub.com/javascript-allonge

For JS people wanting to learn FP, I'd recommend Allonge first. For FP people wanting to see how they can use JS in and FP manner, Fogus' Functional Javascript is a good book, and it's not a bad second book for the JS crowd.

Re: Functional Programming using JavaScript

#34

I believe this is the author of Ramda, yes? I can't find the talk, anybody got a link? (Ramda is pretty bad ass.) http://ramda.github.io/ramdocs/docs/

One of the co-authors, yes. Mike Hurley and I have been developing the library for around 18 months. For the last six months, we've had many additional contributors, including some prolific ones, and David Chambers has recently joined the team.

Re: Functional Programming using JavaScript

#35

I believe this is the author of Ramda, yes? I can't find the talk, anybody got a link? (Ramda is pretty bad ass.) http://ramda.github.io/ramdocs/docs/

There is no video for this. I gave the talk several times to small groups, but never recorded it. Sorry. But you don't want to see my ugly mug, anyway.

Re: Functional Programming using JavaScript

#36
post #12

For those you want to learn the functional programming I'd suggest to immedeately commence looking at Ocaml/Haskell instead to see the real big picture. Because it's of course adorable that you can write map and compose in JS (it's 2014, it can do it everywhere), but FP = many more serious things.

Strong agreement. "Adorable" is exactly how I describe it. Even if it's already producing practical advantage in Javascript, it's mostly a cute toy given how it stacks up against "normal" usage.

Learn Haskell/OCaml and you'll see how to really take this kind of reasoning many, many orders of magnitude upward. Learn Coq/Agda to see yet another meteoric jump.

Re: Functional Programming using JavaScript

#37
post #12

For those you want to learn the functional programming I'd suggest to immedeately commence looking at Ocaml/Haskell instead to see the real big picture. Because it's of course adorable that you can write map and compose in JS (it's 2014, it can do it everywhere), but FP = many more serious things.

I'm currently in one of the last chapters of Learn You a Haskell for Great Good (http://learnyouahaskell.com/), which is a really nice introduction into functional programming in general and the kind of thought process behind it. It also really helped me thinking recursively and out of the procedural/OOP box (and also learning Haskell, of course). Learning about FP has been the most eye-opening thing I have done since I'm programming.

Re: Functional Programming using JavaScript

#38

I put together a similar talk last summer: http://thedrearlight.com/functional-js-wut unfortunately, don't have the vid either, but the slides might be complementary to the ones linked by the OP. --edit It's formatted kinda weird, where both up/down and left/right arrows navigate through the different sections.

Very nice talk! I've used that formatting too, and while it can be very useful when running a presentation by yourself, it's not so nice for slides shared with someone who doesn't know it.

Re: Functional Programming using JavaScript

#40

Bravo for promoting functional programming and showing how it can be done in JavaScript. One issue concerns me, though: using strings to reference attributes. This makes static checking tools much less useful and can lead to difficult to find errors due to refactoring and typos.

Promoting FP using SQL as an example for encoding business logic doesn't look to me like a nice example...

The idea was just to show that, contrary to many people's expectations, OOP is not the only widely used paradigm in business programming.
Post reply on HN