Skip to content

Getting started

Learn is for writing Dendrite programs. If you are embedding the language in an application of your own, start at Installation instead.

There is nothing to install. The playground runs the whole language in your browser: the parser, the type checker and the evaluator, with no server behind it.

A Dendrite program is a list of named things. Two words do all the declaring:

let names a value. output names a value and hands it to whoever is running the program. $n is an input: a number that arrives from outside, from the field above the code here, from your application when you embed the language.

That is the whole program. Change $n and watch result follow.

Nothing ran when you stopped typing. Nothing ran when you changed the input, either, except the parts that needed to.

  • doubled reads $n, so a new $n makes it stale and it recomputes.
  • result reads doubled, so it recomputes too.
  • Anything that read neither would have been left alone.

That is the whole idea of the language: you declare what depends on what, and the evaluator works out what has to happen. You never say when.

Dendrite has no statements, no sequence, no assignment. A program is not a list of steps to perform in order, it is a set of names and what each one is. So:

  • The order things run in is not yours to manage. The analyser reads what depends on what and evaluates in that order, whatever order the lines are in.
  • The text still reads top to bottom. A name is declared on a line above the one that uses it. That is lexical order (the order of the text, as opposed to the order things are evaluated in), and it is a rule for whoever reads the program, not for how it runs. Bindings and outputs says more.
  • Nothing changes under you. Within one evaluation a name has one value, computed at most once.
  • There is no loop. Iteration is what the list ops are for, and you will meet them shortly.

Take a wrong turn and you hear about it before anything runs. Write $n && true and the type checker says so, with the line and column, because && wants booleans and $n is a number.

Two paths from here, depending on what you are doing.

Writing programs. Carry on to Examples for two worked programs you can take apart, then Writing programs for each piece of the language in turn.

Embedding the language in an app of your own, so its programs read your data and produce values you act on: go to Installation. Come back here when you want to know what your users can write.