The browser playground

Don't want to install anything just to try a snippet? Open exemples/playground.html in any browser (no server needed) for a live code editor with a "Run" button and example snippets to load.

The playground runs ton618-lite.js, a JavaScript re-implementation of the language, entirely client-side — nothing is sent anywhere, and no installation is required. It mirrors the real interpreter closely: the full grammar (including switch/case), and the ton.random, ton.time, ton.json, ton.mathutils, and ton.strings built-in modules, since none of those need anything a browser can't already do.

Since beta-2.0.0 it supports the whole 2.0 language (classes, method syntax, arrow functions, f-strings, ranges, slices, destructuring, |>, ?....) and the new standard functions — CI runs the tests/ suite through both the real interpreter and ton618-lite.js and checks they print exactly the same thing. On the documentation website, the Run button on a code example opens it in the playground.

What it can't do, because a browser sandbox has no filesystem, sockets, or CLI arguments to back them with:

  • ton.sys, ton.os, ton.requests — real process/filesystem/network access; importing any of these gives a clear error explaining why, instead of silently behaving differently from the real interpreter
  • ton.encoding, ton.regex, ton.path — not reimplemented in JavaScript yet (they exist in the real interpreter)
  • IMPORT://<file> for your own module files (no filesystem to read them from)
  • get/post/serve (no HTTP server), readfile/writefile (no disk access)

One cosmetic difference: printing a float can show more decimal digits in the playground than in the real interpreter (JavaScript's and C++'s default number-to-string conversions round differently) — the value is identical either way, only its printed form differs.

For anything beyond quick experiments — and for the full standard library — install the real interpreter (see Installing & building above).

Edit this page on GitHub