All of the code in the left column is editable and is compiled by your browser as you type.
Here's an quick sample of sibilant code (inspired by the first example on coffeescript.org).
And here's the canonical node example from nodejs.org
Numbers and Strings
Numbers should look pretty familiar. Use commas to enhance readability.
Strings are surrounded by double quotes. Multi-line strings are supported! Use a backslash to escape a double-quote inside of a string.
Variable names may include letters, the period (.) and the hyphen (-). Lower case letters are idiomatic. They may end with a question mark (?) or with a bang (!). They may start with a sigil ($).
Sibilant supports single-word quoting with a leading single quote.
Objects and Arrays
Objects and Arrays are supported as a proper subset of JSON.
Idiomatic sibilant skips any unnecessary commas and colons that do not contribute to readability
Arrays and objects contents are accessed with the get and set macros
To modify an existing variable (assignment), use the assign macro.
Sibilant avoids hoisiting by defining functions as variable by default.
If your function name includes a dot, it will not be defined as a variable.
Lambdas and Thunks
Lambdas are how sibilant defines anonymous functions.
Thunks are zero-arity lambdas (anonymous functions that accept no arguments). A shortcut for this is the #> macro.
Sibilant provides two primary conditional macros: if and when. When is the simplest, only executing the subsequent block when the conditional evaluates to a truthy value. All conditionals in sibilant are expressions and evaluate to some value. This is done by introducing a scope with a self-executing function.
The `if` macro supports two branching paths. If either of the branching paths needs more than one expression, the `do` macro is used.
For more complex if/else branching, sibilant supports the `if-else` macro.
Some JS libraries heavily rely on chaining, such as jQuery. For those libraries, instead of having to repeatedly write:
Sibilant provides the `chainable` macro, which shadows the `$` function call with a macro that applies additional aruguments to chain.
Here's an example from angular. Because of the Angular dependency injection system, angular users have to write functions like this example from the angular docs :
In sibilant we can extract this pattern to a macro that is far more DRY. We just have to include this macro at the top of our files, and for the rest of the compiler pass we can use `ang-def` as if it were a native language feature. Don't worry about understanding the macro for now.