Table of contents

The course moves through numbered sections; every example runs — and can be edited — right in the page.

  1. 1First steps

    What Archon is, and a first program that runs right here.

    1. 1.1Introduction

      A compiled language, also interpretable, built around a single concept.

    2. 1.2My first Archon program

      The smallest complete program, line by line, to run and to change.

      1. 1.2.1Naming the arguments

        The same program, except that the argument is passed by its name.

      2. 1.2.2Comments and documentation

        What the compiler throws away, what it keeps — and who benefits.

  2. 2Values

    Holding something, naming it, showing it — enough to finally compute.

    1. 2.1Declaring a value

      Naming a value with var, freezing it with const, and the := arrow that sets them.

    2. 2.2Showing a value

      Interpolation — sliding an expression into a text, with nothing assembled by hand.

    3. 2.3Numbers

      Integers and floats, size as a suffix, sign as a prefix — and division, which does not do what you expect.

  3. 3Deciding

    Comparing values, and making what the program runs depend on them.

    1. 3.1Comparing

      The six comparisons, and the answer to the question left hanging about the = sign.

    2. 3.2if and else

      Running one thing or another — and why a condition has to be a bool.

    3. 3.3Combining conditions

      and, or, not, xor — written out in full, and only on bool values.

  4. 4Control structures

    Repeating, traversing, choosing among many — everything that decides the order of statements.

    1. 4.1While loop

      while, do/while, and the one thing that keeps a loop from running forever.

    2. 4.2For loop

      The three clauses of for, the scope of its variable, and the two words that cut it short.

    3. 4.3For in loop

      A sequence of values, and the loop that takes them one at a time, with no index or counter.

    4. 4.4Switch case

      One value, some cases, a default — and what it works on.

  5. 5Functions

    A method that returns a value, and the rules that keep you from forgetting one.

    1. 5.1Returning a value

      An arrow, a return, and a call stops being a mere action to become a value.

    2. 5.2Every path must return

      A method that announces a return type must honour it everywhere, and the three ways to forget a path.

    3. 5.3Only a call stands alone

      A statement that computes a value and throws it away is refused — and that refusal closes the last shape of the = trap.

    4. 5.4Default values

      A parameter that may be left out, and the value it takes when nothing is said.

  6. 6Arrays

    Taking an element by its index, changing one, counting, and passing an array to a method.

    1. 6.1Taking and changing an element

      The index in brackets, .length to count, and the first error of this course that only happens at run time.

    2. 6.2Traversing by index

      The counted for loop finally earns its keep — and the one-step-too-far shows up at run time.

    3. 6.3An array parameter

      The array type written out, and the absence of a variadic symbol — a lone value wraps itself.

  7. 7Archetypes

    The shape you make instances of — the concept the language is named after.

    1. 7.1The philosophy

      What an archetype is, and why the whole language carries its name.

    2. 7.2A shape, and its instances

      archetype declares the shape; the program makes as many instances of it as it wants.

    3. 7.3State, and self

      An archetype's methods work on the instance that calls them — self is that one.

    4. 7.4The constructor

      When building is more than copying fields — code that runs at birth.

  8. 8Errors

    throw, try, catch, finally — raising an error, catching it, and moving on.

    1. 8.1Throwing and catching

      throw raises an instance of an archetype; catch takes it by its exact type.

    2. 8.2The language's errors, and finally

      Catching what the language throws — and guaranteeing a cleanup, whatever happens.

  9. 9Text

    Importing the vocabulary of a value, searching a string, crossing from text to number.

    1. 9.1The vocabulary is imported

      What the language hands over unasked stops at Console, System, File and its errors. The rest of the vocabulary is written in Archon, and is imported.

    2. 9.2Searching a text

      Cleaning, questioning, locating — and the −1 convention, which is not the zero of absences.

    3. 9.3From text to number, and back

      toInt raises a ParseError when the text is not a number, toText returns a str you can still work on.