Comment

Comment by toastal

I won’t disagree that JavaScript isn’t multi-paradigm and you can write in a functional style, but you have to look at where the ergonomics are:

• dot, `.`, syntax on objects vs. composition/pipe operators

• no autocurry

• no ADTs or basic pattern matching

• has null + undefined but no Maybe/Option (there is null coalescing and null chaining, but it’s easy to accidentally skip)

• const can still mutate the on the object, freeze incurs a massive performance cost

• no tail-call optimization outside Safari despite being in the ECMA2015 spec

• `class` keyword existed and private methods and values now, FP is pretty anti-encapsulation

• no immutable data structures in the stdlib

• no way to prevent side effects (/* __PURE__ */ in code generation is a hack)

Can you get benefits from avoiding state/mutation and choosing composition over inheritance? Sure, but it’s nothing like being in a language where these aren’t something you can do or the default, but the only way to write code and having the tool to express it.

parent toastal 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton