Want to Learn JavaScript? Learn Haskell First

Be functional.

Be functional.

Srsly?

I’m serious about this.

Anyone who wants to master JavaScript had better learn Haskell beforehand.

This article explains the “why“s and “how“s of it.

Why Do I Need Haskell?

Modern JavaScript has become and more functional. Also, the modern JavaScript frameworks and libraries strongly encourage (sometimes, to the point of enforcing) you to think functionally.

Moreover, most of the functional constructs that modern JavaScript implements have been borrowed straight out of Haskell or are easier to grok when you already know their Haskell counterparts.

Not only vanilla JavaScript, but also many popular JavaScript tools and frameworks such as Redux, or the React Context API, or immutable.js are tools that are * highly inspired* by functional languages like Haskell.

Even Promise s are Monadic constructs, and Monad is a data type that Haskell programs use extensively to modify state.

Haskell is a Paradigm Shift

Learning Haskell will change how you think: You’ll look at programming problems from a simplistic, elegant, pure, and different perspective. That’s what matters.

The reason many developers have a hard time understanding JavaScript is not about the complexity of it: JavaScript is an easy-to-understand language. You can learn the basics of it in a couple of days to a few months tops.

The problem is not the rules, or semantics of the language: Learning to “think in JavaScript” is what takes time, effort, and energy.

When you learn a purely functional language, and Haskell is the best “pure” functional language out there, thinking in JavaScript will be a cakewalk for you.

Where Do I Learn Haskell?

Here are a few links to help you learn Haskell:

Bonus: Read K&R’s C Programming Language

Even if you don’t professionally plan to write C, every developer should read K&R’s C Programming Language —It teaches you a lot in so little; it’s a classic.

Rant

A programmer who has not read K&R’s ANSI C is like a geek who has not read Asimov. Don’t be that person.

Conclusion

After learning Haskell, I’d recommend you give Go a go too.

Don’t Forget Your HTML and CSS
It would even be better if you dig into some HTML, CSS, and a good dose of Web Application Security before you begin your JavaScript journey.

I hear some of you asking, “What’s the advantage of learning two other languages, just to learn a third language?”.

If you ever watched The Karate Kid, then you know the reason: Even if you have studied a couple of weeks of * Haskell* and **Go **, you’ll be “miles ahead” when you begin your JavaScript journey.

Your mind will be wired to think in JavaScript without you even realize.

There are countless articles, books, videos, and tutorials to cover your * JavaScript* bases. I’ll write about it later. Yet a quick web search will provide you with more resources than you need 🙂.

So off you go, learn some cool $#!%.

And until next time… May the source be with you 🦄.


Section Contents