• Stars
    star
    335
  • Rank 125,904 (Top 3 %)
  • Language
    JavaScript
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Intro to Functional Programming Workshop

First Steps into Functional Programming

A super fun(ctional) programming workshop by @AnjanaVakil (slides)

Why am I here?

You may have found yourself hearing more and more about this trendy topic of “functional programming", from a bunch of excited coders enthusiastically gushing about how it helps them write elegant, modular code that's easier to test, debug, and reason about. If you're like me, you may have started wondering:

  • What is functional programming anyway, and why are people so excited about it?
  • What does functional code look like? How is it different from imperative or OO code?
  • What tools do I need to write functional programs? Do I have to learn Haskell? (spoiler alert: no!)

If you too have been asking yourself questions like these, you're in the right place! If you're a functional programming pro or have zero interest in learning a new paradigm, then this probably isn't the workshop for you.

What will we learn in this workshop?

This will be a friendly, practical exploration of functional programming fundamentals.

We'll learn how to follow the basic principles of the functional programming paradigm, such as:

  • construct programs from pure, “input in-output out” functions through which data flows
  • use higher-order functions like map & filter instead of iterative loops, and closures instead of objects & classes
  • avoid mutation (changing things in-place), and use immutable data structures for efficiency

How do I use this repository?

The examples in this repository are written in Node.js, and exercise instructions will assume that you're working in Node.

  • Install Node (version 6 or 8 recommended), if you don't already have it - I recommend installing via NVM (Node Version Manager). Installing Node also installs the package manager npm.
  • Clone the workshop repository: git clone https://github.com/vakila/functional-workshop.git
    • Feel free to fork the repo first, and track your work in your own fork!
    • If you don't use GitHub, no problem: download a zip file of the repository instead, and unzip it.
  • Change into the repository directory and install the project dependencies:
    $ cd functional-workshop
    $ npm install
    
  • Follow along with the exercises in each section's readme.md, linked in the schedule below.

Do I have to use Node?

Not necessarily! If you prefer to use client-side JavaScript, that's also fine: you can follow along with the exercises by copy-pasting the code samples into your browser's web console. For the closest similarity to Node.js, you may want to use Chrome.

What should I do if I get confused?

If you are struggling to wrap your head around a functional concept, that means you're completely normal and doing things right! But to keep things from getting too frustrating:

  • Ask questions at any time - there are no dumb questions!
  • Read up on the topic with the resources listed below. You might find an explanation or example that makes it click for you.
  • Ask the facilitator for additional exercises you can do to practice working with the concept

What should I do if I get bored?

If the workshop is moving too slowly for you or you're already familiar with some concept(s) we're working on, no worries! Take your learning into your own hands:

  • Work on solving small programming problems in a functional style. Find a problem from Exercism, Daily Programmer, or a similar site you like, and force yourself to solve it functionally.
  • Feel like reading rather than coding? Dive deeper into the topic(s) we're covering by checking out some of the resources listed below.

Outline & Schedule

9:00-9:30 Intro & icebreakers

9:30-10:30 Functional Programming in a nutshell

  • Pure Functions vs. Side Effects
  • Time, state, and (in)sanity
  • Imperative vs. Declarative programming

10:30-10:45 Coffee break

10:45-11:15 Staying out of the loop with Recursion

  • Iteration vs. Recursion
  • Recursive function basics
  • The problem with the problem with the problem with recursion

And now, a word from our sponsors: Tail Call Optimization

11:30-12:00 Flying first-class with higher-order functions

  • Functions as values
  • Filter, Map, Reduce

12:00-13:00 Lunch

13:00-13:45 Getting Closure

  • Closures
  • Currying
  • FP & OOP: BFFs

And now, a word from our sponsors: The Lambda Calculus

13:45-14:00 FOOP demo & discussion

14:00-14:30 It's functions all the way down

  • Function composition
  • Data flow
  • Pipelining

14:30-14:45 Coffee break

14:45-15:30 Immutability and you

  • Time, state, and (in)sanity, revisited
  • Copying vs. Mutating
  • The pitfalls of immutability

And now, a word from our sponsors: Persistent Data Structures

15:30-16:00 Recap & takeaways (discussion)

  • Review: Thinking functionally
  • When is FP the right choice?
  • Libraries & languages to try

16:00 End

References & Further Reading

FP Principles & Concepts

Closures & Currying

Immutable data structures

Messaging & OOP

Libraries & Languages to try

Functional JavaScript Libraries

Functional Languages

More Repositories

1

kimi

A toy programming language that keeps it minimal
Python
138
star
2

dunders

Using and abusing Python's double-underscore methods and attributes
Python
84
star
3

vakila.github.io

Personal site & blog
CSS
44
star
4

net-set

A networked multiplayer game inspired by the card game Set®
JavaScript
36
star
5

game-of-life

Simple interactive browser-based visualization of the Game of Life
JavaScript
30
star
6

mapbox-concatenate-workshop

Building Interactive Maps with Mapbox, Concatenate Conf 2019
HTML
19
star
7

dastralgos

Various data structures and algorithms implemented in various languages, for fun
Python
11
star
8

de-stress

Prototype German Computer-Assisted Pronunciation Training tool for lexical stress errors
Groovy
10
star
9

javascript-first-steps

Companion site & code exercises for the Frontend Masters course "JavaScript First Steps"
HTML
10
star
10

search-retro-games

An app to search retro games data built with Xata and Next 13
TypeScript
10
star
11

selfie-cam

A tiny photo booth created with create-vite vanilla JS template
CSS
10
star
12

observable-demo

Demo of embedding Observable cells into a static web page on Github Pages site
HTML
9
star
13

egghead-lessons

Code & resources for Anjana's Egghead.io lessons
HTML
8
star
14

brainlord

A colorful code-breaking game implemented in Python 3
Python
8
star
15

vanilla-js-projects

Companion site for the FrontendMasters course 'Vanilla JavaScript Projects'
HTML
8
star
16

meme-me

Make a meme as beautiful as you are
HTML
7
star
17

coducks

Demo app for "Codux Live: Building an eComm product page ft. RadixUI & TailwindCSS"
TypeScript
7
star
18

realtime-graphql-workshop

Materials for workshop "Building Realtime Apps with GraphQL and Hasura"
JavaScript
7
star
19

questferret

A D&D-themed app built with Convex & Vite
TypeScript
7
star
20

rc-projects

Miscellaneous little projects I'm working on at the Recurse Center
HTML
4
star
21

thesis

TeX
4
star
22

dataviz-for-react-devs

Companion project for the workshop "Data Visualization for React Devs"
JavaScript
4
star
23

search-xata-next13

A simple app demonstrating boosted full-text search, built with Xata & Next.js 13 app directory
TypeScript
3
star
24

studdai-buddai

Learning is better with friends :) Get a GPT-powered study buddy (or 2 or 3...) who is always up for a chat!
CSS
2
star