All languages make tradeoffs in various areas and on various spectrums:
- learning curve
- type systems
The question is "Which combination of tradeoffs provides the most benefits in prioritized areas?" "Good" languages happen to select specific tradeoffs that make the language well-suited for specific problems. For example, Python is well-suited for creating dirty one-time-run scripts to do tedious work on a computer. While Python can be used to create financial or medical applications that need to be extremely fast and secure, it would be better to use a different language that is better suited for such a task, such as Rust.
PureScript has chosen tradeoffs that its developers think are the best for creating simple to complex front-end applications that "just work;" that are easy to refactor, debug, and test; and help make developers more productive rather than less.
It can be said that other front-end languages buy "popularity" at the cost of "power and productivity." PureScript buys "power and productivity" at the cost of "popularity."
To fully answer "Why learn PureScript?" we must answer three other questions:
- ...and write Purescript instead of alternatives
- The web browser is the new "dumb terminal" / platform-independent OS:
- Why Founders Should Start With a Website, Not a Mobile App
Some other ideas that are relevant:
- dynamic typing leads to errors that do not appear until after you have already shipped the code to your customers
- a linter is just a basic static type checker
- The Power of Composition
- Code Reuse in PureScript: Functions, Type Classes, and Interpreters
- Phil Freeman's post: 'Why You Should Use PureScript'
- PureScript's "Real World App"s
- A Discourse pose describing some of the disadvantages of TypeScript and Elm when compared to PureScript
Note: the below comparisons are still a WIP. To fully support this claim, it would help to compare each languages' various "overall rating" on various aspects. Unfortunately, since I'm not familiar with every other language mentioned, it's very difficult for me to do that. If you are familiar with such languages, consider opening an issue on this repo and discussing it with me.
In short, the below comparison will be biased towards PureScript and will not yet fairly represent the corresponding side in some situations. Consider this a starting point for your own research.
- TypeScript vs PureScript: Not All Compilers Are Created Equal
- Various examples comparing PureScript and TypeScript
Since Elm is founded on the similar philosophical foundations as PureScript, one can use Elm and gain many of the same benefits as PureScript due to its type safety. However, there is a ceiling on the abstractions one can express in Elm. PureScript's ceiling is much higher than Elm's because it has type classes.
- ... sacrifices the following features ...
- type classes, which
- reduce boilerplate code since the compiler can write code for you
- enable one to define and uphold constraints about their program (e.g. this sequence of commands must be executed in the correct order)
- type classes, which
- ... to gain the following ...
- clear actionable error messages because there are less ambiguous cases to deal with in the type system
Elm and PureScript can both be used to build a complex website. However, one will need to write more lines of code in Elm than they would in PureScript.
This section has not yet been written.
See PS or ghcjs for Frontend with Haskell backend for my summary of the main issues at play here.