The complete, free course

Learn Salam

This course covers the whole language, from your first program to the advanced parts, in short lessons that build on each other. Every lesson has complete programs with the output they actually produce; copy them and run them in the online editor.

Getting started

  1. 1Your first programThe entry point, running a program, printing output, exit codes, input, comments and the shape of a program
  2. 2Variables and constantsDeclaring with :=, mutable variables, scope, globals, constants and naming rules
  3. 3TypesWhole and decimal numbers, overflow, booleans, characters, mixing types and conversion
  4. 4OperatorsArithmetic, division and remainder, powers, comparison, logic, the ternary, compound assignment, bitwise flags and precedence
  5. 5Strings and textString literals and escapes, joining text, bytes and characters, the str package, comparing text and reading numbers from text

Control flow

  1. 6Conditionsif, else if and else, comparison words, and and or, early returns, comparing floats and the rules a condition follows
  2. 7Loopsrepeat with a count, a range and a step, the until loop and its traps, loops that end with break, each over arrays, vectors and maps, nested loops, break N and continue
  3. 8match and switchChoosing between cases with match and switch: values, strings, enums, data and guards, struct patterns, fallthrough and switch inside loops

Functions

  1. 9FunctionsDeclaring and calling functions, early return, default values, several results, recursion, overloads, reference parameters and main's exit code
  2. 10Anonymous functionsFunctions as values: anonymous functions, the function type, sorting with a comparator, functions that return functions and what a lambda captures
  3. 11defer and function modifiersRunning cleanup at the end of a block with defer, in what order and when, plus the pure, inline, noinline, noret and deprecated modifiers

Data and types

  1. 12Arrays and slicesArrays, indexing, arrays of a given size, searching and totals, two dimensional arrays, copies and slices that write through
  2. 13Vector and HashMapGrowable lists with Vector, key and value pairs with HashMap, sorting, and Set, Stack and Queue
  3. 14StructsRelated data together, methods and this, pub and private, printing, copying, static members and embedding
  4. 15EnumsA closed set of cases, chosen values, enums in structs, enums that carry data, and Result with ?
  5. 16New types and operatorsType aliases, distinct types with their own methods and operators, operator overloading in structs, and Variant
  6. 17Generics and interfacesGeneric functions and containers, interfaces, impl, bounds and dyn collections

Larger programs

  1. 18Packages and filesPackages, include and import, pub and privacy, folder packages and project layout
  2. 19What the compiler insists onThe strict rules of Salam, the error code for each, and how to fix them
  3. 20Values, references and memoryCopies and sharing, copy and deep_copy, freeing memory, who frees a string, pointers and memcheck
  4. 21Conditional compilationCode for each operating system and processor, build flags with -D, and debug-only checks, all decided while compiling
  5. 22Working with CCalling C functions with extern, printf and other variadic functions, pointers and buffers, linking libraries, and handing Salam functions to C
  6. 23ConcurrencyThreads with spawn and join, sharing data safely, channels and parallel loops
  7. 24The layout languageBuilding web pages with layout: elements, attributes, styles, click handlers, components, layouts with parameters, and serving them from a Salam program
  8. 25The English and Persian glossaryEvery Salam keyword, type, built-in function, built-in method and compile-time constant in both languages

This course is about the language itself. For the standard library (files, text, numbers, networking and the rest) see the library reference.