No longer in development
2. Hello world

2. Hello world

If you haven't read the introduction section, I highly recommend going back and reading it. Everything at this point assumes you've read it.

Now why don't we write our first Squiggle program? Save it in a file called main.sqg.

global.console.log("Hello, world!")

Now to compile it, run:

squiggle main.sqg main.js

Feel free to take a look at main.js generated by Squiggle. It's a little large, but that's mainly because Squiggle bundles the all of its necessary functions into the main.js rather than writing two separate files.

To run it, use node just like you normally would:

node main.js

You should see the program write out Hello, world! to the console.

Interactive mode

Using Squiggle to compile a JavaScript file is the primary use case, but it also features an interactive mode, also known as a REPL (historical reasons). In order to use the REPL, simply run Squiggle as follows:

squiggle -i

Squiggle explains everything you need to know from there. It's a great way to quickly try something on your mind, without having to save your work.


Squiggle does not invent its own world separate from JavaScript, Node.js, npm, and friends. It is meant to be used within the existing JavaScript ecosystem, calling JavaScript code, and being called from JavaScript.

The compiler transforms Squiggle files into JavaScript files, on a per-file basis. You can then handle these JavaScript files just like you would hand-written ones. Bundle them, require them, minify them, gzip them, whatever you want.