gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Gleam playground

Open lpil opened this issue 5 months ago • 13 comments

Use the same tech as the language tour to make a little place one can edit and run Gleam in their browser.

Prior art:

  • https://play.golang.com/
  • https://play.rust-lang.org/

MVP features

  • Editing
  • Compilation
  • Execution via JavaScript
  • Syntax highlighting

Secondary features

  • Display compiled code https://github.com/gleam-lang/language-tour/issues/8
  • Save code for sharing (Rust does this by saving to gist.github.com
  • Run formatter

lpil avatar Jan 20 '24 10:01 lpil

I'd like to take a crack at this, if that's alright. Do you want it in the tour repo or a different one? I think having it in the same one makes sense since the functionality is going to be similar

isaacharrisholt avatar May 03 '24 16:05 isaacharrisholt

I'm not sure. Maybe a different one so we can use github actions and get play.gleam.run?

It'd be pretty much the same code but with a different UI and some code to compress the user's code and put it in the hash string like this one does: https://github.com/JohnDoneth/gleam-playground

lpil avatar May 04 '24 13:05 lpil

That seems reasonable. Would you mind setting up a repo then and I'll take a crack at it?

isaacharrisholt avatar May 04 '24 13:05 isaacharrisholt

Thank you. Here you go! https://github.com/gleam-lang/playground

lpil avatar May 04 '24 13:05 lpil

Thanks!

isaacharrisholt avatar May 04 '24 13:05 isaacharrisholt

I'm not sure. Maybe a different one so we can use github actions and get play.gleam.run?

It'd be pretty much the same code but with a different UI and some code to compress the user's code and put it in the hash string like this one does: https://github.com/JohnDoneth/gleam-playground

This is lovely, I also like that there is no server side storage but the compressed query string logic (that I once improved :D over there). Maybe we can get multiple module tabs and saving/loading as a file bundle in some fashion?

inoas avatar May 06 '24 13:05 inoas

It could be nice to have something like the Svelte playground. It allows for multiple files and shows the compiled output live. You can also download a zip bundle of your files. For the sharing, it would be reasonably simple to compress a JSON string of the form:

[
  {"file":"app.gleam","content":"import gleam/io\n..."},
  ...
]

I also like the example scripts the Go playground includes

isaacharrisholt avatar May 06 '24 14:05 isaacharrisholt

Let's start with one file and make that a good experience and then we can decide if it's worth the additional work at that time. We have to be efficient with our actions and having multiple files doesn't unlock anything in particular that I can think of.

lpil avatar May 06 '24 22:05 lpil

I agree, I'm just making sure we can support upgrades if we do decide to do them. It might not be multiple files, but maybe specifying the Gleam version, adding a name to the shared example, etc.

isaacharrisholt avatar May 06 '24 22:05 isaacharrisholt

I don't want to support anything but the latest Gleam version or any project related features such as files. We just want a simple playground with sharing to start as that's where the main value is. We are very time pressed so efficiency is the name of the game.

lpil avatar May 06 '24 22:05 lpil

Got it!

isaacharrisholt avatar May 06 '24 22:05 isaacharrisholt

would be glad to offer any assistance to this initative 😃

I am actively working on a playground based on the tour website code that has a different set of goals ( repo: https://github.com/samifouad/linkhash, web: https://linkha.sh ), but I'd love to see an official one

feel free to pluck anything out of there you might find useful

samifouad avatar May 08 '24 08:05 samifouad

Thanks so much @samifouad!

isaacharrisholt avatar May 08 '24 08:05 isaacharrisholt