First thank you all for making such a great language,
I’m going through the book again and I find the experience very polished
In particular, setting up psc-ide-mode in emacs was quite simple and super useful to manage import.
So my question is, would it be possible for the compiler to optimize pure expression in their final form?
For example, could this expression "Hello " <> "World!" be compiled as "Hello World!" (instead of "Hello " + "World!") ?
It seems like this isn’t possible at the moment, and I was wondering if purescript being pure could do that easily.
PureScript can theoretically implement that (and might do so at some point). But almost every JavaScript minifier will do that for you. And if you don’t use a minifier, any half-good JavaScript runtime will optimize most obvious stuff for you. So, are simple optimizations like that even necessary?
However, if we’re talking about code size instead of performance here, then the optimizations that you’re presumably thinking about might be worthwhile if the most common JS minfiers can’t do these optimizations, due to not wanting to break code or otherwise.
Note: In case you’re thinking about performance @tristanC, there are many optimizations that PureScript can implement using the plethora of type information and guaranteed purity that the compiler possesses that may not be possible using JIT compilers.
The compiler does not currently have a robust, general optimization framework other than the handful of specific inlining rules it currently performs (function composition/application, operations on primitive types, Effect binds, aka magic-do).
As it currently stands, an optimization like that will probably not be implemented into the compiler in the near future. I think I read somewhere that performance will get more attention after 1.0 is released.