4 ms·
Haskell WebAssembly in the Browser
- miga 3y agoIt is nice to live in the future "when browsers do not include JS any more". I do not want to steal your greatness when you port basic JS APIs to Haskell WASM. Or that of WASI work, when we no longer need to use raw JS API.
- bradrn 3y agoGHC’s WASM backend is already really useful! I also used it to port one of my own programs to the browser [0], albeit not using the DOM as this person did. Documentation is still sparse, but it’s a very similar process to creating a shared foreign library. (At the very least, I tried to document what I could.) [0] https://github.com/bradrn/brassica https://github.com/bradrn/brassica
- whateveracct 3y agohaskell and raylib work together in WebAssembly too! https://github.com/Anut-py/ghc-web-test https://github.com/Anut-py/ghc-web-test
- evmar 3y agoIt think you might not need to go via CString to get to the browser, given that the browser side doesn't care about NUL termination either. I think you could use Data.ByteString.Internal to grab the ForeignPtr/length out of the BS constructor directly.
- agentultra 3y agoFinally! Nice!! I tried getting it going on my stream a couple times but failed to get the shim going! Can’t wait to dive into this! Well done!
- forgetbook 3y agoDoes this unlock something re: postgrest? I'm way out of my depth; the level of detail I can bring is the factoid 'postgrest runs on haskell'
- chatmasta 3y agoMaybe, but probably not. Postgrest still needs to talk to Postgres over the Postgres wire protocol, which isn't possible with wasm in the browser because there is no raw socket API. However, I'm sure there are some cool hacks you could do like running postgres-wasm "locally" (also within the browser) and having postgres talk to it. You'd still need to modify Postgrest to change how it speaks to Postgres, though. This is also assuming you're running the WebAssembly in the browser. If you're running it in something like WASI, you might have access to a raw socket API and then maybe it's a different story.
- kreetx 3y agoMaybe: if you have a postgres (no "t") service provider and you can't install postgrest on it, then you can now possibly run it in the browser. Though, it adds the problem of how do you connect one with the other. Even if there existed a workaround to make this connection, it might just not be worth it.
- fbn79 3y agoLooks cool, I'm not much into webassembly... but I see just fews lines of Haskell code produced a gzipped wasm of 448K. How does this compares to other languages?
- kwertzzz 3y agoThe uncompressed wasm binary for a simple fluid simulation in julia is 5k (or 2.7k compressed): https://alexander-barth.github.io/FluidSimDemo-WebAssembly/ https://alexander-barth.github.io/FluidSimDemo-WebAssembly/ But here the wasm code does only the number crunching. The visualization (and memory allocation) is all done in javascript.
- 3836293648 3y agoRemember that this includes the runtime. It'll hopefully shrink a bit once the wasm gc is stabilised
- markdog12 3y agoIt's already in Phase 4, so close: https://github.com/WebAssembly/proposals#phase-4---standardize-the-feature-wg https://github.com/WebAssembly/proposals#phase-4---standardi...
- whateveracct 3y agoThe RTS is a bit more than the GC though.
- 3836293648 3y agoI said a bit, not go away entirely
- samus 3y agoDoes it really need a GC or is JavaScript engine's GC such a bad fit for Haskell?
- 3y ago
- deleted 3y ago[deleted]