-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add javascript backend output support #31
Comments
What would you imagine the support to look like? Would the javascript be run in the client's browser, or on the server, and if the latter in what runtime? (Sorry, I'm not yet familiar with how the new backends work) |
While this would be possible, I'm not sure it would be terribly useful. Following this page, I compiled the quicksort example to JS and looked at the outputs. We have:
And some other files, description copied from the link above (ghc wiki):
Amusingly, So what would you like to see? Putting |
lol, yeah, that'd be the entire runtime ported to JS for us. yeah, clearly I've not thought trough all implications of this request, Maybe it'd be possible to offer the files for download? |
Perhaps we can do some explicit post-processing like stripping the RTS stuff and piping through the Closure Compiler ?
|
However, the closure compiler takes about 4.5 seconds to do so. And that's on a processor running at >5 GHz, which is more than your average VPS. However, stripping RTS stuff is clearly something we can do -- if anything, we can transfer it to the client once instead of on every compile. But
Depends on what we want the goal of this to be. If the goal is what @jappeace said, which is to just offer the files for download: this would be possible, but it's only tangentially related to the goal of the playground, and we only sort-of by accident have some infrastructure for that. (Though not all.) So I'm not terribly enthousiastic about this, while I would be happy to give some tips/pointers on how to set up a very simple sandboxed compilation server. If the goal is to run the code in the client's browser, we need all the code there, and it isn't very important how the code looks. But sending over multi-megabyte downloads for every run is a bit much -- and the closure compiler is apparently far too slow to be useful here. If the goal is to let the user look at the code: closure compiler wouldn't help, and honestly I have no clue where to look even in the 1.7 MiB that is So I'm not terribly optimistic currently. :D But if your opinion differs on any of these points, please speak up! My opinions here are weakly held. |
For the JS dump (which is thankfully not the same as executing in the browser, which is fairly dangerous anyway), we have to find a way to isolate the user code, prettify it a bit and display it. Which means that we remove RTS, base and such.
In my professional opinion, this is not a thing we should aim to do. |
Feature request
Recently I tried helping a someone on discord, however it's rather difficult to get a specific version of ghc compiler since I'm on nixos, I could only get ghc 9.7.1 but it didn't have the javascript backend. It'd be great if the playground would have the javascript backend supported as well so I can play around with FFI.
The text was updated successfully, but these errors were encountered: