-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can reflex-frp-dom be compiled with Haste? #86
Comments
When I last checked, Haste did not support System.Mem.Weak. Reflex requires weak references in order to work properly, and I doubt that it is possible to write an FRP system that doesn't require them. There may be other features that Haste doesn't have, but this is the big one I know of. |
Thanks for replying. Do you know of any benchmark that compares Haste & On Mon, Aug 22, 2016 at 5:39 PM, Ryan Trinkle [email protected]
|
No problem! Since Haste can't support Reflex at a technical level, I haven't put any time into testing or benchmarking it. However, my guess would be that its output is probably smaller and at least a little faster. |
I know this doesn't concern the reflex-frp project, but if you could indulge me a little bit, what is the technical difference between Haste & GHCJS? From Haste's home page:
Is System.Mem.Weak a GHC core feature or a GHCJS extension? |
GHC compiles Haskell code by performing a series of transformations into lower and lower level representations. Something like this: Haskell -> A -> B -> C -> Assembly language. Haste and GHCJS do not compile Haskell directly to Javascript. They use GHC to perform some of those transformations, then jump in and convert one of the intermediate representations to Javascript. My understanding is that the basic technical difference between Haste and GHCJS is that GHCJS jumps in at a lower level in the chain. So if we use my above notional GHC diagram, it would be something like this: Haste: B -> Javascript GHCJS: C -> Javascript The further down you start, the more closely you will match GHC. |
Thanks for the explanation @mightybyte It seems that |
Yes, System.Mem.Weak is a core library for GHC. Although Haste does have stubs for it, as you can see, it does not actually function as a weak reference: https://github.com/valderman/haste-compiler/blob/9dbd810d3bc9aade6bb63746ff784690e7674554/lib/Weak.js The net result of this is that anything relying on weak references will (presumably) leak memory on Haste. |
Is this the only problem keeping reflex-frp from using Haste as a compiler? Did anyone try pestering the Haste team to implement weak-reference properly? Btw, will reflex-starter at least compile on Haste, ignoring the memory leak for a moment? @ryantrinkle I remember chatting about weak references on IRC as well. Would it be possible to explain why/how reflex-frp uses them and why they're required for JS callback (IIRC)? Btw, this comment says that they're not required since JS implements its own GC. Is it a misguided comment? |
Feel free to close this issue if Haste is not on your roadmap at all. I'm just trying to understand things better. From a production standpoint, Haste's smaller JS size & better speed is obviously desirable. |
@saurabhnanda @luite is working on JS size right now. He expects GHCJS to have better JS size in the next couple months. |
From Haste's Github repo:
That could a significant downer for people using Persistent to generate common record-types to share between frontend and backend. |
@saurabhnanda I don't know what will/won't work on Haste. Reflex also uses STM, which is a pretty advanced feature, so it's possible that would also be an issue. I'm not sure whether reflex-starter will work with Haste, but if you try it, i'd love to hear how it goes! I believe the Haste comment is incorrect. As far as I know, JavaScript's built-in GC does not support weak references, so a (substantially) more complex approach to provide their behavior. Haste is not on my roadmap for now, but I'm more than happy to discuss it, and it would be great if it supported reflex in the future. And, yes, Template Haskell is extremely important, at least for my applications. |
Here's my short-lived experience FWIW :) |
Closing, since I think we've gone over the major points. Feel free to continue the discussion, and we can reopen if necessary. |
If not, then why? Just curious because it seems that Haste compiles down to a smaller JS size, which is important from a production perspective.
Has anyone tried it? Any benchmarks between Haste and GHCJS?
The text was updated successfully, but these errors were encountered: