Fun(ctional) Javascript
@kirel
Why Javascript?*
*actually I'll use Coffeescript
reach — Javascript runs everywhere
Javascript has Good Parts
Javascript has everything we need — except tail call optimization
functional programming
first class functions
higher order functions
purity
immutability (not today)
composition
partial application & currying
recursion (neither)
first class functions
Functions should be treated like everyone else...
Example
higher order programming
Functions taking functions as arguments and returning functions.
Example
partial application
Preloading / preconfiguring functions with arguments
Example
currying
[...] transforming a function that takes multiple arguments in such a way that it can be called as a chain of functions, each with a single argument (partial application)
— Wikipedia
Example
Interlude:
closures
How is this all working?
Example
composition
Stitching functions together...
Example
underscore.js
Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. It's the tie to go along with jQuery's tux, and Backbone.js's suspenders.
docs
Werden wir benutzen, aber auch sehen, dass das nicht so funktional
ist, wie die behaupten...
scoreunder.js
Underscore got things backwards...
Code
Category Theory:
Functors & Monads
Just kidding...
Nachfragen ob tiefergehender Vortrag gewünscht
source
Talk von Brian Lonsdorf - functional javascript talks
What's my point?
programming without explicit arguments
function decorators
function combinators
function composition
currying
Code
Parameter in der richtigen Reihenfolge.
Underscore unterstützt das nicht direkt.
finale
Another interactive example.
Und alle so: Yeah!
Code
Put your speaker notes here.
You can see them pressing 's'.
Down the rabbit hole...
Books
Down the rabbit hole...
Links
Put your speaker notes here.
You can see them pressing 's'.