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
Your 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
6
Conditionsif, else if and else, the short else form, 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
9
FunctionsDeclaring 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
12
Arrays 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
18
Packages 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
24
Layout 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 build --platform=web, HTML/CSS/JS, browser events/DOM, parameterized rendering, and serving pages
26Native appsRunning a page as a desktop program with --ui=native, and what only the web build has
Web pages
27
Pages 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, scripts, templates and shadow trees, the attributes every element has, ARIA, data attributes and splitting a site into files
33Values, units and the boxWriting values in the page language: numbers, percent, units, comma lists, colours, and the box with padding, border, margin, size and overflow
34Text and fontsText properties of the page language: font, size, weight, colour, alignment, line height, decoration, clipping and shadows
35Colours and backgroundsBackgrounds in the page language: colours, gradients, images, opacity, filters and transforms
36Borders, radius and shadowsBorders, rounded corners, outlines and shadows in the page language
37Layout: row, column, grid and stackPlacing children with layout, gap, align, justify, grow, wrap, grid columns and stack
38Fluid layoutsPages that adapt to the room they get: percent, fill, wrap, min and max sizes and grids that count their columns
39States and transitionsStyles for hover, focus, active and disabled, and smooth changes with transition
40State, lists and componentsMaking a page react: state with :=, events, if and each, components, and other properties for the pointer and scrolling
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
49
The salam serve web server: from one folder to many domainsA complete guide to salam serve: serving a folder, writing the config file, virtual hosts, several domains and subdomains, PHP through php-fpm, Python and Go, using it from Salam itself, HTTPS and deployment
50Server rendering and server functionsBuild a page project into a native server that answers every route with finished HTML, develop it with salam serve --render, see how hydration works, and call a backend safely with server func
Reference
Design system
52
Design systemsTurn on the shadcn look for a page or a whole project: light and dark themes, palettes, tokens, and how the setting is chosen
53Design: forms and buttonsButton, theme toggle, input, text area, label, checkbox, radio group, switch, slider, select, field, input group, button group, toggle, toggle group, keyboard and one time code in the shadcn design
54Display componentsCards, badges, alerts, separators, progress bars and meters, skeletons, spinners, avatars, aspect ratios, tables, typography, empty states, entries, breadcrumbs, pagination and scroll areas of the shadcn design
55Overlays and menusTabs, accordion, collapsible, dialog, alert dialog, sheet, drawer, popover, tooltip, hover card, dropdown menu, context menu, menubar and navigation menu, each with live examples
56Design system: toast, pickers, calendar, carousel and chartsThe rest of the design system components: toast, command palette, combobox, select box, calendar and date picker (with the Jalali calendar), carousel, resizable panels, sidebar and charts, each with a live example of every variant
This course is about the language itself. For the standard library (files, text, numbers, networking and the rest) see the library reference.
Library