Targets · JavaScript · Project setup
Project setup
Everything around the rendered code that makes a working, runnable project.
Contents
How a Program becomes JavaScript, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.
- Introduction — what the JavaScript target is, and how to read the rest of this section.
- Capabilities — which high-level features are possible, built in or through a library.
- Coding standards — the Frenzi coding standards the generated code follows, global and JavaScript-specific.
- Example — a full program using every keyword, and the JavaScript it renders to.
- Naming considerations — how Program's dotted names are carried into JavaScript.
- Entry point — the generated
main()that wires up the drivers and starts the reactive cycle. - Drivers — the native drivers that provide capabilities like the user interface and animation, draining each cycle's emissions.
- Runtime — the Reactive and Context machinery the rendered code links against.
- Native modules — the hand-written, per-platform JavaScript behind
NATIVEfunctions. - Keywords — how each of Program's keywords renders to JavaScript.
- Project setup — the files and commands to build and run the rendered program.
- Reserved words — the words JavaScript keeps for itself, and how a Program name that collides with one is escaped.
The files
The browser target is the lightest of all: no manifest, no package manager, no build step. A working project is one HTML page that loads the runtime bundle and the rendered program.
my-app/
index.html <!-- loads the two scripts and holds the root element -->
program-runtime.js // the bundled runtime (Reactive + Context + drivers)
app.js // the rendered program
<!doctype html>
<html>
<body>
<div id="app"></div>
<script src="program-runtime.js"></script>
<script src="app.js"></script>
<script>Program.Application(() => Main(), [ Ui.Dom.Driver('app') ]);</script>
</body>
</html>
Build and run
There is nothing to compile: the renderer already emits JavaScript. To run it, open
index.html in a browser, or serve the folder over any static host:
# any static server works
python3 -m http.server 8000
# then open http://localhost:8000
For a single-file drop-in, the renderer can emit a bundle — runtime, native
modules, and the program concatenated into one .js with no imports — so the page
needs just one <script>. That single artifact is also what an embedded example on
this site uses. A typed build instead goes through TypeScript.