gleam-lang / playground

🥨 Write, run, and share Gleam code in your browser
https://playground.gleam.run/
20 stars 5 forks source link

Gleam playground #6

Open lpil opened 10 months ago

lpil commented 10 months ago

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

Prior art:

MVP features

Secondary features

isaacharrisholt commented 6 months ago

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

lpil commented 6 months ago

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

isaacharrisholt commented 6 months ago

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

lpil commented 6 months ago

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

isaacharrisholt commented 6 months ago

Thanks!

inoas commented 6 months ago

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?

isaacharrisholt commented 6 months ago

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

lpil commented 6 months ago

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.

isaacharrisholt commented 6 months ago

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.

lpil commented 6 months ago

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.

isaacharrisholt commented 6 months ago

Got it!

samifouad commented 6 months ago

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

isaacharrisholt commented 6 months ago

Thanks so much @samifouad!