Object-Oriented Programming (OOP), on the one hand, is a very popular programming paradigm which is based on an object, inheritance, encapsulation, polymorphism, the basic idea is, changing of an object often not only itself but also others, which is a form of imperative programming. Functional programming is a form of declarative programming, on the other hand, it is another programming paradigm that is based on…mathematics. Simply put, functional programming is a language that focuses on the computation of pure functions, avoiding changing and sharing states and mutating data, function composition. I will write more details about functional programming versus OOP and some concepts related to this in the later articles.
- You will approach the new way to do things, which I mean is from OOP to FP, it’s the huge different perspectives!
- Declarative programming is pretty concise, you will write less code and so fewer bugs.
- Learning Haskell is fun!
This article will address each of these reasons in a little more detail as well as provide a roadmap of resources that you can use to get started learning Haskell.
But first, what is Haskell?
Haskell is a statically typed, purely functional programming language with type inference and lazy evaluation. Haskell was made by some really smart guys (with PhDs).
Learning Functional Programming Concepts in a Functional Language
reduce. However if you are just getting started learning about functional programming, it’s much harder to develop the discipline to adhere to the principles of functional programming in a language that provides so many escape hatches. There will be pain points when you try to problem solve without side effects or mutable state. It is likely you have been using these things so frequently that you do so without even knowing it.
Functional languages like Haskell also support function composition natively, which means you will not need a third-party library like Ramda to do things like curry (functions are curried by default in Haskell), compose, map, bind, or flip. Working in Haskell and working through tutorials on Haskell will help you think of functions as small, modular components that can be arranged and rearranged to meet different needs.
Learning Types in a Strongly-Typed Language
Learning Haskell will also help you write better TypeScript. It’s much easier to “cheat” in TypeScript, and having that as an option can be tempting when you run into a difficult problem. TypeScript is also an imperfect system for creating strict type signatures, however without exposure to a good type system, you won’t be able to identify when a problem is caused by the limitations of TypeScript or simply by your own inexperience with types.
Lastly, having a good understanding of types and type signatures from working in Haskell will help you read additional functional programming literature. Many functional programming resources utilize types and type signatures to explain functional concepts and having that vocabulary along with a familiarity of the Haskell syntax, in general, will make many more resources on functional programming available to you.
Haskell is Fun!
Once you have a good grasp of the basics, I recommend getting the Haskell Book if you don’t mind spending the money (it’s worth it!) or Learn You a Haskell for Great Good! (the book that I’m currently reading) There is also a two-hour course on Pluralsight that serves as a nice quick overview but it is by no means exhaustive. The real advantage to Haskell Book over the others is that it includes exercises for each new concept which means you aren’t just reading about a topic, you are practicing it as you go. To that end, Code Signal is also a great site for putting your new Haskell skills into practice by solving algorithm problems.