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.
There are two main ways to use Desmoscript (the former of which is described below):
- RECOMMENDED: Through a VSCode extension which adds language support (syntax highlighting, errors, jump to definition, desmos-in-VSCode, etc.)
- Through releases, which I upload occasionally. This is just a standalone compiler executable you can run.
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
- Install the VSCode extension (linked above)
- 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.
- 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.
- 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;
- 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.
- Paste the URL into the URL box in the Desmos Loader.
- Hit "recompile" if it doesn't compile automatically!
- Try loading ./sample.desmo if you want to see more features in action.
Lines 1 to 33 in fae6b54
- Highly performant— doing things the idiomatic way should incur little-to-no performance overhead. If the idiomatic way is not performant, a performant alternative should be available.
- Easy to both write and read— C-like syntax is familiar to most programmers, and has an emphasis on compactness.
- Able to be effectively used in large projects— A proper scoping system, namespacing, and file-splitting capabilities are used to help manage complexity in large projects.
- Catch as many errors at compile-time as possible.
- Allow Desmos to interface with the outside world— An extensible macro system should allow Desmoscript to import external data— for instance, Desmoscript macros could be used to add 3D models, SVG paths, or CSV data to a Desmos graph, automatically formatted as Desmos data.
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 |
- arithmetic
- functions
- lists
- ranges
- points
- list comprehension
- namespaces
- piecewises
- multi-step expressions
- integrals and derivatives
- products and sums
- displayed expressions
- graph settings
Big thanks to the following people for helping with this project:
- @Lenny-the-burger on GitHub.