←back to thread

296 points gyre007 | 1 comments | | HN request time: 0s | source
Show context
onion2k ◴[] No.21280617[source]
JavaScript isn't a functional language itself, but you can use a functional library like lodash/fp (https://github.com/lodash/lodash/wiki/FP-Guide) on top of it to get all that lovely functional goodness in your frontend and node code. Using lodash/fp has made my frontend state management code a lot nicer, and I'm really only just starting out with it.
replies(4): >>21280640 #>>21280696 #>>21280761 #>>21281273 #
Tade0 ◴[] No.21280696[source]
You may want to consider Ramda.js instead: https://ramdajs.com/

IMHO does a better job than Lodash, because:

1. All functions are automatically curried.

2. The order of parameters lends itself to composition.

EDIT: 3. Transducers.

replies(3): >>21280709 #>>21280791 #>>21281336 #
enlyth ◴[] No.21281336[source]
I never understood the point of Ramda. It's like it's trying to replace the core functionality of JS with something that's completely orthogonal to what the language actually is, but it's just a bolted on library.

I've worked on codebases where people ignore all built-in JS functions (like Array.map/filter) and write Ramda spaghetti instead with multiple nested pipes and lens and what not to show off their FP purism.

Most of the time, you don't need any of this, it just makes the codebase unreadable, and hard for new people to join the project and be productive in a timely fashion.

replies(4): >>21281470 #>>21281810 #>>21281831 #>>21292365 #
wdroz ◴[] No.21281810[source]
Maybe to avoid questionable behaviors, like in the article posted 3 months ago "Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3] in JavaScript" [0]

[0] - https://news.ycombinator.com/item?id=20242852

replies(1): >>21289076 #
1. Roboprog ◴[] No.21289076[source]
Things like Ramda and jquery help avoid fighting against IE and other browser nuances, as well.

Even when there seem to be native functions/ methods to do something. That’s where the monster lives.