Git Product home page Git Product logo

maverick's Introduction

Ink playground, "Maverick" ๐Ÿฆ…

Maverick is a simple web IDE and REPL for the Ink programming language, written in pure Ink and built on a self-hosted September compiler toolchain that runs entirely in the browser. It compiles Ink code to JavaScript to run it locally without requiring a backend or a native execution environment, which is possible because the September compiler is used to compile the compiler itself to JavaScript bundled in the web app.

You can try the demo at play.dotink.co by running some included example programs.

Screenshot of Ink playground running a prime sieve program

Architecture

Maverick's primary goal is to enable anyone to write and experiment with Ink programs without installing anything on their system. I had developed a version of the playground before that was backed by a sever-side evaluation service, but I didn't feel very secure publishing a remote code execution service to the open Internet, for obvious reasons.

Maverick gets around this problem by compiling and running Ink programs entirely in the browser. This is possible because September, the Ink-to-JavaScript compiler, is compiled to JavaScript using itself. September then runs in the browser, and can compile other Ink programs to JavaScript programs and run them immediately in the browser using JavaScript's eval(). This has the unfortunate side-effect of Ink programs being able to introspect and modify the surrounding web application, but this isn't too much of an issue, because if anything breaks, you can just reload the page!

Outside of the compiler, Maverick is a simple single-page web application built using Torus.

REPL environment

Currently, Ink's module system does not work within September-compiled JavaScript bundles. So instead, these standard libraries are globally available in the REPL environment:

  • std
  • str
  • quicksort

For example, we can type in sort!(map([1, 2, 3], n => n * n)) to the REPL and execute it without importing std.

Development

Because Maverick depends significantly on the September compiler, the repository is designed to be cloned side-by-side to the thesephist/september repository. Maverick, during the build step, will reach inside the September repository next to it to compile it into JavaScript.

Maverick uses a Makefile for development and build tasks. Simply running make will re-compile all dependencies and the application, including the September compiler itself. it produces a static JavaScript bundle into static/ink/bundle.js. Other commands are as follows.

  • make watch
  • make fmt or make f formats all non-vendored source code, including tests.
  • make check or make t runs all tests.
  • There are several different build tasks, depending on what portion of the app you want to compile:
    • make build-libs compiles the common dependencies between September and Maverick into ink/lib.js
    • make build-september compiles the September compiler source from the directory ../september into ink/september.js
    • make build compiles the Maverick application itself into the final bundle, assuming that the dependencies and September itself have been compiled.
    • make watch or make w watches Maverick's source code for changes and recompiles them when they are changed. This is useful for iterating during development, and depends on entr.

Maverick is continuously deployed as a static site on Vercel, on every push to git branch main.

maverick's People

Contributors

thesephist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

maverick's Issues

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.