Recommend me a beginner ES6 Functional Programming resource

Hi friends!

I’ve recently landed a job that requires me to use Javascript to develop game prototypes, mainly using a functional programming paradigm.

I have some competence in OOP using C#, but only a basic-level JS in which I pretty much port what I’m already familiar with. :)

This is not ideal so what I’d love is a good resource that would crash-course me beginner-level functional programming using ES6, in particular the functional composition, lambdas, closures, etc. and maybe some common patterns preferably pertaining to game dev.

Anyone know something good along these lines? Most beginnner resources seem to focus on an imperative style, and most ES6 topics seem to assume prior expertise in ES5.

How familiar are you with LINQ ? LINQ is very ‘functional orientated’

My big breaktrhu with JavaScript was to realize that it was a functional language with object orientated ‘stuff’ added to it (not the other way around). Functions as (as first-class citizen) are your friend!:)

Sorry don’t have any resources just yet :-)

How did you get hired for a job that requires you to do something you don’t know how to do?

I’m not really familiar with LINQ either, I only ever used it a couple times and that was mostly copy/paste/modify without bothering to really understand it. :)

But yeah over the past week of looking into JS I too have had that functional language realization. I just need to wrap my head around how that all works together to build stuff.

I got really lucky. :)

The prototyping is not the only thing I’ll be doing, it’s a generalist role and I have a range of technical artist and other skills that also apply. I delivered a prototype in c# to demonstrate I could build something quickly and they are graciously allowing me to upskill into the JS/web dev side of stuff.

Technically they would let me build the prototypes in c#, but doing it in JS makes more sense as that’s what the actual products are using and I’ll be more useful to the team after acquiring those skills.

Think of functional programming as inputs transformed into outputs instead of objects that represents a real world thing that are acted upon. JavaScript is a mix of oo and functional - but I think it’s more useful to think of it as a functional language than oo.

Functions are ‘objects’ in Js. They can be created and passed on as any variable, similar to Delegate in C#, but their main concern is tranforming inputs to outputs.

Maybe that sounds complicated, but it’s really not (the complications are elsewhere :-) )

Thanks, I do understand that basic level of input/output, and have done some reading on the concepts.

I guess what’s initially most confusing is seeing chained functions using the arrow notation, which is somewhat intimidating and unreadable to me atm. I really need some examples of how they’re best used, and exercises to practice. :)

I read a couple of books on functional javascript a few years ago and wasn’t impressed with any of them. Hopefully they have advanced since then, though ES6 was pretty young back then and it makes several techniques like currying much more palatable.

Given your time constraints to come up to speed quickly you probably can’t afford the time to do this, but I would recommend starting off in a “real” functional language like Haskell or even Clojure. Those have much stricter impositions on mutable data and better first class function support. They will force you to use functional style programming whereas with JS it’s easy enough to not even realize you are straying. If you grew up with imperative style programming it’s a pretty big mind fuck at first but it really doesn’t take that long to get going with forced immersion.

Yeah I’m not sure I have the time or brain bandwidth right now to learn another language first. :)

I found this book which seems well-regarded:
https://leanpub.com/javascriptallongesix/read

Also this series by Eric Elliot seems ok?

Your mention of currying lead me to Google which ended up here:

I found this really helpful in solidifying the concepts in my head. The examples were good and seeing it laid out as old-style functions made it easy to understand.

And since I’d already done the reading on the ES6 arrow function I was able to convert to that as I worked through the examples, and gain a great appreciation for the newer sytnax as well. :)