Code Monkey home page Code Monkey logo

janet-playground's Introduction

janet-playground

A WebAssembly based playground for Janet (https://janet-lang.org) like that of https://play.golang.org

Intended to enable sharing of "runnable" example code in the Janet community.

Currently the janet.wasm artifact produced here is used by the "playground" functionality in JanetDocs

Installation

You must ensure that you have installed emscripten (emsdk) > 2.0 and that it is in your path and executable. (Generally you have to do something like source ./emsdk_env.sh in the emsdk install directory.)

Then:

jpm install https://github.com/MikeBeller/janet-playground.git
./playground update-janet v1.16.0 # or whatever release version you want
./playground build
./playground install
./playground serve  # starts a server on localhost:8000

Then point your browser to http://localhost:8000/ to try it out.

To Update Janet Version In JanetDocs

After building as per above copy janet.wasm and janet.js from the public/js directory of this repository to the public/playground directory of the janetdocs repository.

FAQ

Q: How does this relate to the web repl on https://janet-lang.org?

A: The web repl on janet-lang.org, as currently constituted, can only be used for use case "A" above. And even there, because it doesn't allow multi-line editing, it's difficult to use for any larger examples. That said, the janet-lang.org web repl does permit sequential execution of Janet forms, with subsequent forms operating on the same running fiber as the previous forms. By contrast, janet-playground creates an interpreter, runs the example, and then de-inits janet.

Note of thanks to Go Playground

The playground UI is styled based on the go playground, and uses it's style sheet static/style.css . As such, portions of this code may be Copyright (C) 2014 The Go Authors. See: https://github.com/golang/playground

janet-playground's People

Contributors

mikebeller avatar ianthehenry avatar

Stargazers

 avatar Eric Loren avatar Jared Updike avatar Vincent Pomageot avatar Samuel Ludwig avatar Steve Phillips avatar Logan Linn avatar  avatar Josef Pospíšil avatar

Watchers

Josef Pospíšil avatar James Cloos avatar  avatar  avatar

Forkers

icodein sogaiu

janet-playground's Issues

Janet-playground does not print certain types?

Identified by @yumaikas

(string/find "foo" [1 2 3])

Should print:

error: bad slot #1, expected string|symbol|keyword|buffer, got <tuple 0x556FAE9A6FC0>
  in string/find
  in _thunk [repl] (tailcall) on line 1, column 1

But in janet-playground it prints:

error: bad slot #1, expected string|symbol|keyword|buffer, got
in string/find
in _thunk [playground] on line 1, column 1
"bad slot #1, expected string|symbol|keyword|buffer, got "
ERROREXIT: 1

In other words, the <tuple ...> doesn't print.

Formatting, syntax highlighting, and parenthesis checking

Janet-playground should support at least some level of syntax-aware editing. At a minimum it should be possible to click "format" to format the code, and when typing a ) the matching ( should become highlighted. At a maximum, full syntax-aware editing could be implemented.

Possible approaches that have been suggested:

  • https://ace.c9.io -- syntax aware editor. (Could try it with the clojure syntax module, or might have to write our own.)
  • using tree-sitter https://github.com/GrayJack/tree-sitter-janet/
  • maybe something very simple like using spork/fmt for formatting the code (would require including spork in the playground but I want to do that anyway, and using javascript to find the matching paren when you type a ).

Find a home for janet-playground

Consider integration into janetdocs website or janet-lang.org so that it is findable in a place where janet users congregate. This would include cleaning up the styles to match the appropriate site. It would be helpful if the "home" has a back end server which can store snippets of code, so playground users can "save", get a link, and send the link to someone else to try out. (Like the go playground does to great effect.) If integrated with janetdocs, could also make all examples on janetdocs be executable in the page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.