Curious if the devs on SN have any insights, opinions, or recommendations regarding FP. I've been aware of it for many years, I get the basic concepts but I'm now working on a rewrite of an existing app and another dev and I are considering FP.
Its gonna be a Typescript based node application likely using ExpressJS.
My college is a huge advocate for FP and really likes fp-ts.
242 sats \ 2 replies \ @k00b 9 Jul
I think every programmer should spend time doing fp. It encourages/reinforces many best practices like immutability, coding without side effects, bottom-up abstractions, and higher order functions.
I did some Haskell programming in college. After I didn't do much fp until I started programming in Lisp a few years ago which I found much more satisfying to program in than Haskell. I started with clojure which is a fantastic dialect with lots of active developers and can be transpiled to javascript with clojurescript. Later I started writing toys in Chez Scheme.
Lisp is incredibly simple syntactically and you can write a naive Lisp interpreter in 10s of lines of code yet you can trivially write DSLs in Lisp (ie the most powerful abstractions a programming language can offer). Pound for pound, it's the best programming language imo and it's an fp.
Most modern programming languages allow you to do fp in them. They don't enforce functional purity, or give you all the latest fancy named abstractions, but fp is more about a way of programming than it is any language or specific abstraction imo.
reply
Thanks @k00b. That's helpful. I've been fascinated by the concepts but the work I've done has been so far away from FP until now. That said the concepts I am learning about in FP content are things I have been doing for years but this is just way more systematic.
reply
That said the concepts I am learning about in FP content are things I have been doing for years but this is just way more systematic.
I have a similar feeling. I’ve noticed a lot of overlap with techniques I use and those of FP, without having much of any structured FP experience. I think using React got me a lot of if, with the pattern of props being read only. I tend to think of every function as a transformer function now. And I love chaining array method calls together :D
reply
You should also focus on Composing functions together, it allows developers to build complex behaviors from simpler ones, promoting modularity and scalability.
reply
Yeah, that is a pattern I've noticed. Honestly, it is one of the more appealing aspects of FP I've seen.
reply
As long as we are agile lol
reply
Ha!
reply
My FP experience is mostly with Scala and it produced generally the most beautiful code I have ever seen, although I think it can also leads to a pile of shit if developers are inexperienced or make 0 effort at following idiomatic conventions.
Language constructs like for-comprehensions and built-in pattern matching were really making using monads a dream. I feel TS is more cumbersome to use in this regard, but still looks fine for most commonly used combinators.
Overall it is certainly a good addition for backends if you have a team of programmers that are eager to learn FP.
reply
Functional programming with typescript and fp-ts can enhance code structure and maintainability in your Node app rewrite, especially with expressjs
Embracing FP principles could streamline development and improve scalability.
reply
NGL, this reads like AI
reply
@remindme in 3 hours when I have a chance to reply
reply