Zig: Proposal: Playground for Zig

Created on 9 Aug 2019  路  5Comments  路  Source: ziglang/zig

It would be nice to have something like play.ziglang.org that is used to try out the zig programming language right in the browser.

Some examples of playgrounds implemented for other programming languages are

I would like to propose and participate in building this. Feedback and ideas on making this proposal happen would be very helpful :slightly_smiling_face:

Why?

I have tried to pick up zig multiple times, but never ended up writing code during the learning process, as I was busy reading the entire document of https://ziglang.org/documentation/master/ , not knowing where to stop :sweat_smile:

A solution to making the learning experience nicer for beginners is building an online tour of the programming language (where user could interactively type code in browser and learn the language). This leads me to propose building tour.ziglang.org (but not yet, please read below). Some good examples for a tour of programming languages are

Before building a tour, we need to build a playground service. Because the API from this service will facilitate building tour sites, that teach the language.

Mock up

2019-08-09-040311_806x497_scrot
(sorry for the misalignment of line number and code :sweat_smile:)

Features

  • Run: User will be able to type zig code and run it against the desired version of Zig.
  • Format: User will be able to run zig fmt on the code typed in the playground.
  • Share: User will be able to get a link for sharing the playground (which will contain the code, version and optionally output)

Further

I intend to type in the design and prototype once this proposal is marked with "accepted" tag.

Most helpful comment

There are a couple things available now:

I briefly looked into trying to build zig with emscripten so that the playground could be directly in the user's browser (who needs a sandbox if the code is all client-side :wink: ) and ran into this issue: https://github.com/emscripten-core/emscripten/issues/6432

Personally that's the direction I would want to explore before trying to set up a security sandbox or whatnot.

But if you're motivated to set something up and you can provide your own server, and it stays up to date with master branch builds (or can select versions like godbolt does), I'd be happy to point play.ziglang.org to your server.

All 5 comments

There are a couple things available now:

I briefly looked into trying to build zig with emscripten so that the playground could be directly in the user's browser (who needs a sandbox if the code is all client-side :wink: ) and ran into this issue: https://github.com/emscripten-core/emscripten/issues/6432

Personally that's the direction I would want to explore before trying to set up a security sandbox or whatnot.

But if you're motivated to set something up and you can provide your own server, and it stays up to date with master branch builds (or can select versions like godbolt does), I'd be happy to point play.ziglang.org to your server.

I started writing a little something for this a while back for my own personal use, but never got round to finishing it. I keep meaning to go back to it - maybe I will some day soon.

godbolt now also allows code to be run!

I still think a wasm solution would be cool in the long-term.

I still think a wasm solution would be cool in the long-term.

Me too.

Was this page helpful?
0 / 5 - 0 ratings