OxL Reference

Step-by-step tutorial

This tutorial leads from your first variable to a small service. Unlike the tour, where every page shows features in a condensed form, every step here is built the same way:

  1. Why - which problem the feature solves and why the language is designed this way;
  2. Example - a complete program you can paste into a file and run: oxl run file.oxl;
  3. Output - what the program prints (the "Output" box is verified together with the code on every site build);
  4. Walkthrough - line by line, what happened;
  5. Common mistake - a short program that does not compile, and the compiler diagnostic with a link to its description.

All you need is an installed oxl (installation). Every example is a single file; apart from step 9 (modules and packages) you do not need to create projects.

sh
oxl run step.oxl      # build and run
oxl check step.oxl    # type-check only, no run
oxl fmt step.oxl      # canonical formatting
StepTopicMain idea
1. Variables and typeslet, var, numbers, strings, T?everything is immutable by default
2. Functionsparameters, defaults, closuresthe last expression is the result
3. Data: data and enumrecords, variants, methods in impla type describes the allowed states
4. Pattern matchingmatch, if let, unions A | Bthe compiler checks you covered everything
5. Errors@error, fail, ?, chains ->an error is part of the signature
6. Collections and iteratorsList, Map, Set, iter, querieslazy pipelines
7. Ownership and borrowingmove, &, &var, clonememory safety without a garbage collector
8. Effectspure, io, time, net, dbthe signature tells what a function does
9. Modules and packagesuse, pub, oxl.tomlthe module is the visibility boundary
10. Teststest, assert_eq, tables, fuzzinga test is a language declaration
11. Concurrencyscope, tasks, channels, select, actorsstructured concurrency
12. A small serviceservice, rpc, actor, clusterone code base - in process and over the network

After the tutorial go to the cookbook of examples, the tour of the distributed features (cluster, sagas, deployment) and the Standard for the exact rules.

See also