HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

Hey Underscore, You're Doing It Wrong!

InfoQ9 HN recommenders · recommended in 7 months, 2014-2022
YouTube
141K views · 13 years ago · talk · evergreen

Brian Lonsdorf explains why Underscore.js falls short as a functional programming library, then introduces currying, composition and point-free style in JavaScript. He argues for data-last argument ordering.

A repeatedly recommended introduction to functional JavaScript that explains currying and why data should come last.

Functional programmingWeb development#currying#functioncomposition#point-free#underscore.js#ramda

12 comments from Hacker News

@r3a1d33p2022 · in “Ask HN: Learning Functional Programming in 2022?”

I find this talk inspiring. Underscore.js got many things wrong for FP: ▶ this video . I've read Grokking Simplicity too. It's very approachable book. Highly recommend it for JS/TS developers who want to learn FP!

Strongly recommendsView on HN
@splintercell2017 · in “Currying vs. Partial Application (2015)”

With all due respect, I don't think you understand the purpose of currying and partial application. In your defense, the article merely explains what currying is, but does not explain why you need it. For instance while writing functional Javascript code, I never curry my methods, instead I use helper methods from functional libraries such as lodash or Ramda to curry. Where currying is useful is in cases like this: ```javascript //Definitions const filterUsers = (fieldName, value, users) => //Implementation const sortUsersBy = (fieldName, users) => //Implementation const takeUsers = (count, users) => //Implementation //Without currying UserService .getUsers() .then(users => filterUsers('active', true, users)) .then(users => sortUsersBy('age', users)) .then(users => takeUsers(3, users)); //If these methods were curried UserService .getUsers() .then(filterUsers('active', true)) .then(sortUsersBy('age')) .then(takeUsers(3)); ``` Here is a video which explains proper uses of currying (and does it very well) [1]. Here is another article if your coworker start using functional programming and you want to stop them [2]. 1. ▶ this video 2. link

RecommendsView on HN
@patricklynch2016 · in “Just: A library of dependency-free JS utilities that do just do one thing”

Because then you can curry/partially apply functions independent of your data. It's _not_ because it's convention everywhere else. (I realize that only really makes sense if you know why it makes sense, so this video gives a pretty good explanation in ~30 minutes - ▶ this video )

RecommendsView on HN
@ignoramous2015 · in “Mostly Adequate Guide to Functional Programming in JavaScript”

You might already be using certain functional programming constructs without being aware of them. Contrary to popular misconception, OOP and functional programming don't have to be mutually exclusive. "Pure" functional programming (ala Haskell) and OOP most certainly are to an extent non-overlapping (since OOP has state+behaviour at its core), and pure fn-languages have no side-effects. High-order function in java don't exist, so one would do : new Thread(new Runnable() { ... }).start(); A builder pattern can be distilled down as a form of partial application (or, currying, if you like. They aren't the same thing, but are very similar): alertDialog .setMessage(...) .setPositiveButtonText(...) .setNegativeButtonText(...) .setPositiveButtonOnClickListener(...) .setNegativeButtonOnClickListener(...) .build() .show() Functors (in OCaml) can be viewed as Java's abstract-generic-classes with dependency injection [0]. Note that functors in different languages mean different things. Monads are tricky to understand [1], I have been led to believe. But if you use the promises API in javascript, then you're using a form of monad [2]. If you're familiar with javascript, have a look at: ▶ this video (Hey Underscore, you're doing it wrong!) I think the best way is to read a book on fn-programming. I've heard most people recommend these (pick a language, and choose a book; you cannot go wrong with any of these): Functional DS: link Real World Haskell: link Real World OCaml: link The Joy of

RecommendsView on HN
@ahallock2015 · in “How to Become a Great JavaScript Developer”

> Reading and understanding underscore will improve your functional programming skills. No. underscore does it wrong (check ▶ this video ) Check some of the real functional libs like Ramda and Pointfree Fantasy

CriticalView on HN
@wizao2015 · in “Lodash v3.0.0”

There is an excellent talk called "Underscore, you're doing it wrong!". The talk explains how well designed param order with currying leads to very short and expressive code -- and how underscore missed the boat. This aspect of it should be interesting as it's related to this post. It's well worth the watch. ▶ this video

Strongly recommendsView on HN
@kaonashi2014 · in “Pun: A small library to enable pattern matching in JavaScript and CoffeeScript”

Recently watched this video, which describes why underscore is actually making this difficult through its design. ▶ this video

CitesView on HN
@lsdafjklsd2014 · in “A Gentle Introduction to Monad Transformers – or, Values as Exceptions”

Meh, I don't know or use Haskell and I'm interested in this stuff. I'm a javascript programmer introduced to these concepts via [1] ▶ this video and link . Programming in a point free style in javascript is great! 1: Hey Underscore, You're Doing it Wrong!

RecommendsView on HN
@hueyp2014 · in “Videos about JavaScript”

I would add: 'Hey Underscore, You're Doing It Wrong' -- ▶ this video It is much better than the title would suggest :)

RecommendsView on HN
@grayrest2014 · in “Don’t Be Scared Of Functional Programming”

If you're interested in FP in javascript, you should check out the relatively new Ramda.js [1]. It switches from the underscore style collection first call pattern to a collection last pattern and automatically curries its functions. The combination allows for easier function composition. [1] link More info on the topic: link ▶ this video link

RecommendsView on HN
@seanwoodward2014 · in “Functional JavaScript, Part 3: apply, call, and the arguments object”

@lrichardson, I agree with "your way", and apparently you are not alone. See Brian Lonsdorf talk about it, ▶ this video

CitesView on HN
@lrichardson2014 · in “Functional JavaScript, Part 3: apply, call, and the arguments object”

That is great feedback. I am actually working on creating a "functional" version of the 2048 game, along with my own implementation of the AI solver, as part of this series. Kinda goofy, and maybe not a "real world" situation as much, but should at least show the concepts being applied. I also very much recommend this video by Brian Lonsdorf, titled "Hey Underscore, You're Doing It Wrong!: ▶ this video

Strongly recommendsView on HN
Monads and Gonads49:47

Monads and Gonads

Google TechTalks
148K views • 13 years ago
Lambda Calculus - Fundamentals of Lambda Calculus & Functional Programming in JavaScript1:02:15

Lambda Calculus - Fundamentals of Lambda Calculus & Functional Programming in JavaScript

Fullstack Academy
227K views • 9 years ago
Monad - FunFunFunction #2111:25

Monad - FunFunFunction #21

Fun Fun Function
128K views • 10 years ago
"Datafun: a functional query language" by Michael Arntzenius42:31

"Datafun: a functional query language" by Michael Arntzenius

Strange Loop Conference
9K views • 9 years ago
Brian Beckman: Don't fear the Monad1:07:10

Brian Beckman: Don't fear the Monad

jasonofthel33t
415K views • 13 years ago
JSON Parser 100% From Scratch in Haskell (only 111 lines)1:50:07

JSON Parser 100% From Scratch in Haskell (only 111 lines)

Tsoding
205K views • 6 years ago
ClojureScript for Skeptics - Derek Slager41:09

ClojureScript for Skeptics - Derek Slager

ClojureTV
72K views • 10 years ago
React.js Conf 2015 - Immutable Data and React31:11

React.js Conf 2015 - Immutable Data and React

Meta Developers
159K views • 11 years ago
Douglas Crockford: Monads and Gonads (YUIConf Evening Keynote)54:27

Douglas Crockford: Monads and Gonads (YUIConf Evening Keynote)

YUI Library
67K views • 13 years ago
The Functional Programmer's Toolkit - Scott Wlaschin1:05:51

The Functional Programmer's Toolkit - Scott Wlaschin

NDC Conferences
79K views • 7 years ago
Ron Pressler - Pull Push: Please stop polluting our imperative languages with pure concepts-Curry On44:43

Ron Pressler - Pull Push: Please stop polluting our imperative languages with pure concepts-Curry On

Curry On!
25K views • 11 years ago
Parsing with Derivatives1:13:10

Parsing with Derivatives

Stanford
13K views • 15 years ago
Evan Czaplicki - Let's be mainstream! User focused design in Elm - Curry On58:23

Evan Czaplicki - Let's be mainstream! User focused design in Elm - Curry On

Curry On!
82K views • 11 years ago
Web Development in Emacs, Common Lisp and Clojurescript - Emacs SG1:18:42

Web Development in Emacs, Common Lisp and Clojurescript - Emacs SG

Engineers.SG
14K views • 10 years ago
Stanford Seminar - Concatenative Programming: From Ivory to Metal1:04:45

Stanford Seminar - Concatenative Programming: From Ivory to Metal

Stanford Online
14K views • 8 years ago
ClojureScript in the Age of TypeScript — David Nolen59:31

ClojureScript in the Age of TypeScript — David Nolen

ChariotSolutions
29K views • 5 years ago
"Outperforming Imperative with Pure Functional Languages" by Richard Feldman34:55

"Outperforming Imperative with Pure Functional Languages" by Richard Feldman

Strange Loop Conference
98K views • 5 years ago
The Algebra of Algebraic Data Types1:04:35

The Algebra of Algebraic Data Types

London Haskell
27K views • 13 years ago
Breaking Down Programming Paradigms: APL's Surprising Learning Curve // Aaron Hsu // Dyalog '1759:03

Breaking Down Programming Paradigms: APL's Surprising Learning Curve // Aaron Hsu // Dyalog '17

Dyalog User Meetings
7K views • 9 years ago
Nordic.js 2014 • Douglas Crockford - The Better Parts33:52

Nordic.js 2014 • Douglas Crockford - The Better Parts

Nordic.js
73K views • 12 years ago