@garretoconnor9877

Important to note that in JavaScript, Array.sort() sorts the array in place. However, ECMAScript 2023 introduced a new non-destructive method for sorting an array, Array.toSorted(). 

PS. It also introduced Array.toReversed() and Array.toSpliced(), non-destructive alternatives to Array.reverse() and Array.splice().

@scheimong

Take note that doing FP in JS may induce a steep performance penalty, for you are allocating a new array at every chained step and copying the data. And in most cases the runtime cannot optimise this because the closures have no pureness guarantee (i.e. may have side effects).

If you want the true functional experience, learn SML or Haskell. If you want the practical functional experience and still keep your sanity (i.e. the choice to opt-in/out at will), learn Rust.

@kylewollman2239

The timing on this video is perfect. I've been on an fp video binge the last few weeks and you have a way of visually explaining things that I've always appreciated.

@ntrgc89

"functional programming bros are bad marketers" ... proceeds to rewrite a for loop as a recursive function

@zactron1997

This pipeline approach is one of the things I love about Rust. In JS, the array methods operate on the entire array at each step, whereas Rust iterators work on a single item from the iterator at a time across the entire pipeline.

@bobDotJS

These videos are always so insanely good. Incredible channel!

@LetsGetIntoItMedia

Functional bro here! Guilty as charged. You're totally right...

The concepts aren't actually that complex (a Monad is basically something that has a map() and flatMap(), and you can arrive at the need for that with a few simple code examples), but the words can be used to gatekeep or show off your smartness

Also, the focus is often elegance for elegance's sake, rather than usefulness, simplicity, composability, safety, testability, etc. Though it is, in a way, the elegant foundations in math that allow FP patterns to get so powerful

Also, I do think there's value in the words. It would be extremely difficult for society to function if we never put labels on things... how could we ever succinctly talk about anything without terms for concepts? Learning the FP words are useful not because knowing definitions is useful, but because they help you see those patterns in a problem space and then go r you immediate strategies for breaking them down into smaller bits and solving them concisely

@davidzwitser

I love the visualisation of the functions!

Btw, you would be super cool if you did a video about array programming! Like with APL or BQN etc. Those are the most aesthetic language in my opinion and it would blow a lot of peoples mind if they saw that video!

@t3dotgg

We love you too

@lethicanthus

The problem with functional programming in a language like JavaScript is that the JS runtime does not optimize functional techniques. Languages like F#, LISP, Scala, etc. can eliminate stack overflows and sometimes even do something called loop fusion where, in your pipeline example, all operations happen in a single loop instead of looping multiple times which is always the case in JS.

@sugarsama7716

Please, come back.
I need more of your videos 🥲

@Emil_96

I recently watched a video on "hardware programming" which I now realize is just basically building functional programs into hardware.

@nate7803

This channels has 8 videos and 300k+ subs. Shows the quality of the videos. Keep them coming please. DI was my favorite so far.

@davidfrischknecht8261

If you're looping through a large amount of values using recursion, there's a good chance you'll run out of stack space.  At least with an imperative loop, you can overwrite the state from previous iterations, thus saving stack space.

@rodolphov.santoro8829

I find FP to work best for simple data transforms and filtering. As soon as you have too many steps on the pipeline, it becomes
- Code that becomes useless as soon as a single requirement changes for what that function/method must do. So you have to rewrite it
- Code that's really hard to debug, since you can't easily keep track of state or where data is going
- Code that's so concise, you forget what it's meant to do after a few days (although breaking up the steps into well named variables helps)
But even for simpler ones, it is quite sad that in languages like js, you'll be doing a lot of unnecessary  copying, or sometimes on others, even worse, speedrunning a stack overflow.
So i'm only inclined to use FP when i know the others maintaining the code are FP bros. Other than that, i usually avoid it. I find imperative easier to follow/maintain anyway.

@ethancriss4145

Gosh I love your videos, I hope you make more

@WHYUNODYLAN

One issue is that many of the more well-known functional languages are a pain to get into. Scheme is easy to pick up at first, but it quickly becomes challenging to tackle problems that are a breeze in other languages. Haskell is wonderful, if you can ever get it to compile. Some of the newer functional languages, though, like Clojure and Elixir, make FP much easier to get into.

It is probably true that the most useful languages take some functional features (e.g. Rust), but it's good to have some experience with functional programming so you know when it's useful to bust out the maps, filters, and reduces.

@ChronotronTronochron

one issue with the recursive list comprehension might be exceeding the call stack, which using a for loop would avoid.

@laztheripper

Mutating state in JS is how you make things faster. It just is. The more array methods you do, the worse it gets for garbage collection because every new map() and filter() call creates a new object and copies all of the key pointers to the new array. Also recursive "data pipelines" as described are just a neat way to speedrun stack overflows and increase memory usage.
In short, most of the "clean" code these days is just a direct downgrade from regular for loops.

@AJRobinson

So I watched about 5 of your videos, and I felt myself saying to things like "don't use comments" that this guy is taking everything to the extreme. Then about a week later, I found myself really cleaning up my code using different techniques that you've discussed, especially about inverting the logic of the if statements! I understand now that having knowledge of these different styles doesn't mean you have to use it 1000% of the time, but it really helps to sprinkle it in here and there and made your code that much better! Thanks my guy, you definitely earned my sub.