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
- 1Your first programThe entry point, running a program, printing output, exit codes, input, comments and the shape of a program
- 2Variables and constantsDeclaring with :=, mutable variables, scope, globals, constants and naming rules
- 3TypesWhole and decimal numbers, overflow, booleans, characters, mixing types and conversion
- 4OperatorsArithmetic, division and remainder, powers, comparison, logic, the ternary, compound assignment, bitwise flags and precedence
- 5Strings and textString literals and escapes, joining text, bytes and characters, the str package, comparing text and reading numbers from text
Control flow
- 6Conditionsif, else if and else, comparison words, and and or, early returns, comparing floats and the rules a condition follows
- 7Loopsrepeat with a count, a range and a step, the until loop and its traps, loops that end with break, each over arrays, vectors, maps and strings, nested loops, break N and continue
- 8match and switchChoosing between cases with match and switch: values, strings, enums, data and guards, struct patterns, fallthrough and switch inside loops
Functions
- 9FunctionsDeclaring and calling functions, early return, default values, several results with tuples, recursion, overloads, reference parameters and main's exit code
- 10Anonymous functionsFunctions as values: anonymous functions, the function type, sorting with a comparator, functions that return functions and what a lambda captures
- 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
- 12Arrays and slicesArrays, indexing, arrays of a given size, searching and totals, two dimensional arrays, copies and slices that write through
- 13Vector and HashMapGrowable lists with Vector, key and value pairs with HashMap, sorting, and Set, Stack and Queue
- 14StructsRelated data together, methods and this, pub and private, printing, copying, static members and embedding
- 15EnumsA closed set of cases, chosen values, enums in structs, enums that carry data, generic enums, and keeping a result as a value
- 16New types and operatorsType aliases, distinct types with their own methods and operators, operator overloading in structs, and or types
- 17Generics and interfacesGeneric functions and containers, interfaces, impl, bounds and dyn collections
Larger programs
- 18Packages and filesPackages, include and import, pub and privacy, folder packages and project layout
- 19What the compiler insists onThe strict rules of Salam, the error code for each, and how to fix them
- 20Values, references and memoryCopies and sharing, copy and deep_copy, freeing memory, who frees a string, pointers and memcheck
- 21Conditional compilationCode for each operating system and processor, build flags with -D, and debug-only checks, all decided while compiling
- 22Working with CCalling C functions with extern, printf and other variadic functions, pointers and buffers, linking libraries, and handing Salam functions to C
- 23ConcurrencyThreads with spawn and join, sharing data safely, channels and parallel loops
Layout language
- 24Layout language: common for web and nativeThe shared Salam layout DSL for web and native apps: elements, attributes, styles, components, parameterized layouts, and simpler value syntax, plus where web and desktop differ
- 25Layout on the webBuilding web output from the layout DSL: salam page build, HTML/CSS/JS, browser events/DOM, parameterized rendering, and serving pages
- 26Layout in native appsRunning the same layout DSL as a native desktop app with --ui=native and Salam's UI engine, and how it differs from web/WebView
Web pages
- 27Pages and textThe shape of a page, headings, paragraphs, line breaks and every text level element: emphasis, quotes, code, edits, dates, abbreviations and mixed direction text
- 28Page structure and listsLandmarks such as header, nav, main and footer, then lists, definition lists, details, dialogs, figures and addresses, and how to build a whole blog page from them
- 29Links, images and mediaLinks and anchors, images with alt text and responsive sources, image maps, audio and video with subtitles, frames, embeds, canvas, SVG and math
- 30TablesTables for data: caption, header, body and footer sections, heading cells with scope, spanning cells, column groups, and how to style and scroll a table
- 31FormsForms and every form control: labels, all the input types, validation, text areas, checkboxes, radio buttons, lists, buttons, output, progress and meters, files, and handling a submit in code
- 32Head, scripts and global attributesThe settings of the page, the head with meta and links, styles and scripts, templates and shadow trees, the attributes every element has, ARIA, data attributes and splitting a site into files
- 33Styles and the box modelCSS from zero: style properties as attributes, values, units and colors, the box model, sizes, margins, display, overflow, CSS functions, global rules and reusable components
- 34Fonts and text stylingFont families and sizes, weights, web fonts, variable fonts, alignment, decoration, spacing, wrapping, text direction, vertical text, ruby and Persian typography, with every font and text property
- 35Colors, backgrounds and effectsText and background colors, opacity, layered backgrounds, gradients, fitting images, filters, blend modes, masks, clip paths and text that wraps around a shape
- 36Borders, outlines and shadowsThe border shorthand and every side, logical sides, rounded corners, border images, outlines and focus rings, box shadows, broken boxes and the new corner shapes
- 37Layout: flow, flex and gridNormal flow, position and z index, float, flexbox, grid, alignment, multi-column text and right-to-left pages, with every layout property and an example for each
- 38Responsive pages and statesPages that fit every screen: fluid sizes, media and container queries, dark mode, hover, focus and generated content, pointer, scrolling and print properties
- 39Transitions and animationsMotion on a page: transitions, transforms and 3D, keyframe animations, motion paths, scroll driven animations, view transitions and respecting reduced motion
- 40The rest of CSSLists and counters, quotation marks, table settings, scroll snapping and scroll margins, anchor positioning, SVG fill and stroke, math, reading order and the other properties not covered before
- 41Mouse eventsMaking a page react to the mouse: handlers, click, double click, other buttons, the context menu, pointer position, drawing, enter and leave, bubbling and the wheel
- 42Keyboard and formsKeys, focus, typing, text selection, form submit, reset and validation, the clipboard, details, popovers and dialogs: the events of every part of a page that people type into
- 43Drag, touch, scroll and windowDrag and drop between lists, pointer and touch events, scroll and window events, and the load, error and abort events of images
- 44Media, animation and other eventsAudio and video events, a custom player, animation and transition events, slot changes, captions, canvas context loss and security policy violations
- 45State, the DOM and timersHow the pieces of an interactive page fit: state in variables, reading and changing elements, classes and styles, creating and removing elements, timers, storage, dialogs, components with handlers and how to debug
- 46Whole pages: six projectsSix complete pages that bring the lessons together: a landing page, a blog post with a sidebar, a sign up form with live checks, a dashboard with a CSS bar chart, a task list that remembers, and a photo gallery with a lightbox, plus how a Salam program serves a page
Reference
Server and deployment
This course is about the language itself. For the standard library (files, text, numbers, networking and the rest) see the library reference.