Live data from Hacker News

Functional Programming using JavaScript

scott.sauyet.com

51–60 of 88 posts

Re: Functional Programming using JavaScript

#51
post #46

Earlier quoted context omitted.

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 (perha…

There's no real distinction. If the slides were implemented as separate pages you would get a new entry in your history as you navigate through each of them. Back doesn't mean to go back to the previous domain; it means the previous page. You don't think the slides should be separate pages, but that would mean you couldn't link to them.

with replaceState, you get the best of both worlds - bookmarkable slides and no history foo.

Re: Functional Programming using JavaScript

#52

Earlier quoted context omitted.

No video was recorded on the occasions I gave the talk. I'd apologize, but actually, you should probably thank me. :-)

you missed a golden opportunity to rickroll hacker news readers

Hasn't that meme died yet? Well, I for one won't help keep it alive by pointing to the recently discovered talk video found here:....

Re: Functional Programming using JavaScript

#53

Trying to ride the wave: I have written about functional programming in javascript, see blog posts http://bahmutov.calepin.co/tag/functional.html - Ramda is great!

I've read and commented on many of these posts (the latest one far too frequently! :-) ). Excellent stuff.

Re: Functional Programming using JavaScript

#54
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've been wondering lately, if we skip performance as a consideration (for example lazy evaluation), what is the difference between functional programming and imperative programming without globals, pointers, mutable variables or shared memory? In other words, would an imperative language without side effects (that could do static code analysis) be any different in practice than FP? I'm very serious about this, becau…

It's different in practice because languages have built-in "opinions" (often codified by syntax, or the standard library, or other ways) that heavily influence their ecosystem.

Functional javascript, or python, is not awesome because the default datastructures are mutable, and the ecosystem of libraries are written in an OOP style using mutable data structures. There is some small value in writing the code you control in as FP a way as possible, but you aren't going to have a ton of success in that unless you are willing to rewrite your dependencies to also be more functional.

ReactJS may be a killer app that can influence javascript's "opinions" at the ecosystem scale, but that is going to take more time. I've been using ReactJS since it came out as tech lead on small teams, and it was not without challenges to get an OOP trained team to use React well, and to avoid the OO parts of React.

Edit: In theory, yes, if you could somehow statically enforce that your C code (and dependencies, including the OS) have no side effects, then some hypothetical compiler could combine your imperative C statements into functional expressions, though I don't know what advantage that would give you. Maybe I have misunderstood your post.

Re: Functional Programming using JavaScript

#55
post #4

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

This book is great, it is very upfront that javascript has significant limitations if you're interested in functional programming. But, I think it lays out a great way to write much cleaner javascript code and ways to avoid mutability. There are tons of great functions that Michael writes in the book and would be very useful if not only as a set of utility functions alongside underscore.

Re: Functional Programming using JavaScript

#56

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.

Making each slide its own navigation event isn't bad, the problem is that browsers somehow still don't let you jump back to the previous website, not sub-page.

Re: Functional Programming using JavaScript

#57

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.

Making each slide its own navigation event isn't bad, the problem is that browsers somehow still don't let you jump back to the previous website, not sub-page.

how do you imagine this would work?

Re: Functional Programming using JavaScript

#58
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 hate to be this guy, but learning FP techniques that aren't available in my day to day language isn't terribly exciting. I want to see a short term benefit, so JS or Java focused articles and books are golden for me.

Re: Functional Programming using JavaScript

#59
post #58
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 hate to be this guy, but learning FP techniques that aren't available in my day to day language isn't terribly exciting. I want to see a short term benefit, so JS or Java focused articles and books are golden for me.

The issue is that if you're going to be doing FP, you'll want to use a language in which it's not just possible, but natural and happens without an uphill battle. Similarly, if you're just trying to learn the concepts, you're going to have a lot of noise distracting you if you use a language like JS, etc in which FP concepts are quite unnatural to express.

Re: Functional Programming using JavaScript

#60

Earlier quoted context omitted.

Making each slide its own navigation event isn't bad, the problem is that browsers somehow still don't let you jump back to the previous website, not sub-page.

how do you imagine this would work?

I'd like to have CMD+Backspace do that.
Post reply on HN