radian628 / desmoscript

Desmos scripting language and successor to LISPsmos.
101 stars 8 forks source link

Desmoscript

Scroll down for setup instructions

Desmoscript is a programming language that compiles to Desmos graph state. It is designed to provide the features of Desmos with zero overhead and with a C-like syntax. The syntax is largely inspired by JavaScript, Rust, and Desmos itself.

Setup & Installation

There are two main ways to use Desmoscript (the former of which is described below):

Because of Desmoscript's... unorthodox... compile target, you can't just get it running normally. There is no built-in desmoscript runtime, and it can't output bytecode your machine nor any "real" VM can run. It outputs a Desmos graph, and it runs in Desmos. There are quite a few ways to get that Desmos graph from your file system into Desmos. The one I like to do is outlined below.

Warning: This extension is still in development and will likely have some bugs

  1. Install the VSCode extension (linked above)
  2. Install TamperMonkey or another similar browser extension. This extension easily lets you inject scripts into whatever pages you want. It's like an extension for letting you make your own extensions.
  3. Install the Desmoscript Loader userscript. Open or refresh Desmos. If you see a little box in the bottom right corner that looks like the image below, it's been properly loaded.

A light gray box with a text input containing the text "http://localhost:3000", followed by a button containing the text "Recompile", followed by a filled checkbox labeled "Auto-recompile."

  1. Type some desmoscript code into a file. This will do as a proof of concept. Make sure the file has the .desmo extension:
y = x ^ 2;
  1. Run the web server by right clicking the file and selecting "Run Desmoscript Web Server." Upon doing this, a new VSCode window should pop up containing some compiler output as well as a URL. If you open the URL in a browser, it should be full of Desmos graph state JSON.

A vscode window titled "DEsmoscript Server: sample.desmo". On separate lines, it contains the text "Annotate expressions with equivalent desmoscript" (with a text box), "Server is running at http://127.0.0.1:3000", "Close this window to shut down the server.", and "Status: Compilation was successful! (took 14ms)"

  1. Paste the URL into the URL box in the Desmos Loader.
  2. Hit "recompile" if it doesn't compile automatically!
  3. Try loading ./sample.desmo if you want to see more features in action.

Features

https://github.com/radian628/desmoscript/blob/fae6b541793c8e13f38313327a551d944e7529e7/sample.desmo#L1-L33

Goals of Desmoscript

Notable Desmoscript Projects

Want to see your project here? Send me a message or open an issue! Creator Description Source Graph
radian628 MONUMENT OF BERNARD (2022-2023 Art Contest Winner) (Note: uses old version) Link Link
Lenny-the-burger 3-space Engine (Note: uses old version) Link Link
radian628 3D Parametric Editor (Note: uses old version) Link Link

Features (non-exhaustive)

Additional Contributors

Big thanks to the following people for helping with this project: