Slide 1

Slide 1 text

Stop the Software Apocalypse with Functional Programming

Slide 2

Slide 2 text

Somers, J. (2017). The Coming Software Apocalypse. The Atlantic.

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Reduce complexity with pure functions

Slide 6

Slide 6 text

Mutability let counter = x + 3; // counter = 7 console.log(counter + x); // 25

Slide 7

Slide 7 text

let counter = x + 3; // counter = 7 console.log(counter + x); // 25 Where is x changing? Side effects

Slide 8

Slide 8 text

?

Slide 9

Slide 9 text

No side effects function getX(value) { return value + 2; } getX(2); // 4 getX(5); // 7

Slide 10

Slide 10 text

function getX(value) { return value + 2; } getX(2); // 4 getX(5); // 7 No mutation Different input

Slide 11

Slide 11 text

Optimize for correctness

Slide 12

Slide 12 text

Tests describe("...", function() { beforeEach(function() { // prepare the state }); context("when...", function() { it("returns...", function() { // expects something }); }); afterEach(function() { // clean the state }); });

Slide 13

Slide 13 text

Tests describe("...", function() { context("when value is 2", function() { it("returns...", function() { return expect(getX(2)).to.be.equal(4); }); }); });

Slide 14

Slide 14 text

Types function changeProperty(property) { return property.toUpperCase(); } const user = { name: "Joe", age: 50 };

Slide 15

Slide 15 text

Types function changeProperty(property) { return property.toUpperCase(); } const user = { name: "Joe", age: 50 }; changeProperty(user.email)

Slide 16

Slide 16 text

Types changeProperty(user.email)

Slide 17

Slide 17 text

Types interface User { name: string; age: number; } function changeProperty(property: string): string { return property.toUpperCase(); } const user: User = { name: "Joe", age: 50 }

Slide 18

Slide 18 text

Types changeProperty(user.email)

Slide 19

Slide 19 text

Structure our systems to be more comprehensible

Slide 20

Slide 20 text

Thank you! @feru