Should I learn PureScript or JavaScript?

In my life as a programmer I have spent years learning, using and working on multiple different programming languages. I have mostly been using the more mainstream languages, such as JavaScript and Java, but for a while now I have been looking at alternative programming languages with the express purpose of creating a language which is closer to what I think the web should be like and easier to use for a web developer.

What is PureScript?

PureScript is a purely functional programming language with no side-effects and static type-safety. In fact, it takes the “just pure code” philosophy to the extreme. It has one of the best type systems of most programming languages I have come across.

First of all, it is excellent at creating new programming concepts which allow programmers to express ideas in a pure functional style. For example, PureScript uses higher order functions extensively to allow for programming patterns which would not be possible in JavaScript.

PureScript also offers lots of other high level features which make programming in the functional style easy and safe. For example, PureScript has no global state, has minimal mutable data and allows you to use recursion safely without the need to escape the recursion.

So why would you use PureScript?

This language has many attractive features, such as the pure style, ability to express higher order functions easily and the type system. PureScript has Haskell-like syntax. It transcompiles to JavaScript. So you can start developing in this language now and run it through the compiler as you create your own library or use it to write your own code.

PureScript is still a young language, but the type system is more advanced than most type systems available today. The type system also has a very flexible ability to do dependent types and polymorphism. This means that a very high level of type safety can be achieved in a type safe way.

Should you learn JavaScript before PureScript?

In my opinion, you should learn PureScript after you are already good in JavaScript. PureScript is a language which can be understood by a JavaScript developer. You will immediately be able to extend your existing knowledge into a more powerful way. Also, the syntax of PureScript is very similar to Haskell. So if you already know Haskell you will find it easy to get started with PureScript.

Comparing PureScript and JavaScript sample code
PureScript vs JavaScript syntax

Comparing PureScript vs JavaScript

Now we will have a closer look at how these two languages compare to each other.

PureScript pros

  • Elegant Haskell syntax: the code is beautiful.
  • Strong static typing: if something is a number, it cannot be a string (like in JavaScript)
  • Type inference: there is no need to specify if variable is an integer, PureScript can understand it in most cases without explicit type keywords.

PureScript cons

  • Unpopular. PureScript is not used too much.
  • The PureScript community is small.
  • Can be hard for a newcomer.

JavaScript pros

  • Extremely popular and widely used. There is a huge demand on JS programmers.
  • Highly versatile. With Node.JS, you can use JavaScript outside your browser.
  • Easy to get started with. JavaScript is really straightforward.

JavaScript cons

  • Sometimes counterintuitive. So do not forget to read documentation.
  • Hard to scale. To create a large project, you should use external libraries or frameworks.

What to learn, PureScript or JavaScript?

If you are new to programming, my advise is to learn JavaScript. Otherwise, if you are already a programmer and are willing to learn something new, you can learn PureScript. By the way, you might learn Haskell before PureScript, as they are very similar.


I hope this article helps you understand PureScript and its benefits. It is always good to know JavaScript. For me, PureScript seems to be the only language which can bridge the gap between functional programming and the JavaScript world.

Leave a Comment