What if PureScript emits smaller code than TypeScript?

I believe PureScript enables developers to write robust, concise and error-less code than TypeScript.

But PureScript community is small compared to TypeScript’s. TypeScript has become the de facto standard among AltJS languages, and there are many libraries written in TS.

Compared to TypeScript, PureScript is difficult to learn for non-FP developers because of Type Class, HKT, ADT etc…
Even if a developer wants to use PS in their buiseness, it’s very hard to convince their boss or stakeholders because TS offers many libraries, and they can avoid reinventing the wheel.

What prohibits developers from using PureScript is the feature that really matters in term of business not like developer experience or code quality.

Compiled code size is the one IMO. As you know, modern web development aims for faster response. You can reuse a logic once you write it in PS, thanks to the fact that everything in PS is function. Evenmore, PS code can be analyzed and optimized easier than TypeScript. Say, you can mangle most of compiled code using terser as you can tell which function is pure or which code causes side effect.

So, what do you think? It would greatly benefit the PS community if the PS compiler supports to emit smaller code like cooperating with minifier or emitting smaller code by itself.

1 Like


I think it’s only partially true that it’s harder to learn.
Yes if you focus on the advanced features it seems overwhelming but don’t underestimate TypeScripts “type features” - people just don’t focus so much on them especially when onboarding beginners.

Similar with Rust: for me borrowing, lifetimes etc. where harder to grasp then type classes but that does not seem to generate as much fear - maybe it is because of the mathematical names after all.

And there is really great progress with PureScripts generated code and speed (great improvements with the latest purescript-versions and the es-backend) but as you said: the community is much smaller.

1 Like

Yes, I totally agree mathematical names look overwelming than it actually is.

The PS compiler is excellent. It emits readable and es-module-formatted code. But regarding minification, It looks like there seems to be some room for additional optimization.

For example, if you compile add a b = a + b, you get

var add = function (a) {
    return function (b) {
        return a + b | 0;

You can see how long it is, right? If you use arrow function, it gonna be just var add = (a) => (b) => a + b | 0. terser doesn’t minify this add function by default. And there could be other points to improve (for mangling probably).

I just think it’s good to gain attention from developers if PS features emitting small code.

1 Like

Have you tried GitHub - aristanetworks/purescript-backend-optimizer: Optimizing backend toolkit and modern ECMAScript backend for PureScript ?


I’ve heard of it but I misunderstood its functionality. Okay… what I considered is already solved. Thank you for letting me know it.