fun-js



fun-js

0 3


fun-js

Functional Javascript Slides.

On Github kirel / fun-js

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
Keine

functional programming

  • first class functions
  • higher order functions
  • purity
  • immutability (not today)
  • composition
  • partial application & currying
  • recursion (neither)

purity

  • data in, data out
  • no sideeffects
  • referential transparency

Example 1

Example 2

Hilft bei Testbarkeit

first class functions

Functions should be treated like everyone else...

Example

Keine

higher order programming

Functions taking functions as arguments and returning functions.

Example

Keine

partial application

Preloading / preconfiguring functions with arguments

Example

Keine

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

Keine

Interlude:

closures

How is this all working?

Example

a = 5

intermezzo

Code

keine

composition

Stitching functions together...

Example

Keine

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

Keine

Category Theory:

Functors & Monads

Just kidding...

Nachfragen ob tiefergehender Vortrag gewünscht

source

Talk von Brian Lonsdorf - functional javascript talks

What's my point?

point free

  • 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'.

Down the rabbit hole...

Talks

by @drboolean