start here / no experience needed

learn ember, step by step

From your first message to a small program of your own. No installation or account needed.

0 of 6 lessons finished

saved on this device

how it works

You write instructions in Ember. Its interpreter reads those instructions, works out their meaning, and executes them. In the playground this happens in your browser; on your computer the same language runs through the downloaded terminal command. Ember is a programming language, not an operating system.

  1. 01 / write — put your instructions in the editor.
  2. 02 / run — Ember checks the syntax and executes your code.
  3. 03 / read — print shows your results in output. If something is wrong, an error tells you where to look.

before your first lesson

  1. Open a lesson with its “try” link below. The example is loaded in the playground.
  2. Press “run →” and compare the output with the expected result.
  3. Change the code using the small challenge, then run it again.
  4. Return to this guide for the next step. Each lesson starts with its own complete program.

step 01 / 06

print your first message

A program is a set of instructions. print shows a result in the output. Text goes between double quotes; parentheses hold the value you want to print.

print("Hello, Ember!")

expected output

Hello, Ember!

your turn / Replace Hello, Ember! with your name, keeping the quotes, then run it again.

try step 1 →

step 02 / 06

remember a value

let gives a value a name so you can use it later. Numbers do not need quotes. += adds to the value already stored under that name.

let score = 10
score += 5
print(score)

expected output

15

your turn / Change the starting score to 20. Your result should be 25.

try step 2 →

step 03 / 06

make a choice

if checks a condition. >= means greater than or equal to. The code inside the first pair of braces runs when the condition is true; else handles the other case. In Ember, that choice can also become a value.

let score = 15
let message = if score >= 10 { "passed" } else { "try again" }
print(message)

expected output

passed

your turn / Change score to 5. The result should become try again.

try step 3 →

step 04 / 06

repeat with a list

A list holds several values inside square brackets. for visits each item in order. Here, name becomes each person’s name, and print runs once for each person. // starts a comment that Ember ignores.

// Greet each person
let names = ["Ada", "Sam", "Lee"]
for name in names {
  print("Hello", name)
}

expected output

Hello Ada
Hello Sam
Hello Lee

your turn / Add "Jo" to the end of the list, separated by a comma. You should get a fourth greeting.

try step 4 →

step 05 / 06

reuse an instruction

fn defines a function: a named piece of code you can call again. n is its input. Ember returns the last value in the braces automatically, so double gives back n * 2.

fn double(n) { n * 2 }
print(double(4))
print(double(7))

expected output

8
14

your turn / Try double(10). It should give you 20.

try step 5 →

step 06 / 06

connect the steps

The pipe |> sends the result on its left into the function on its right. This program orders the scores with sort, adds them with sum, then shows the total with print. Read the steps from left to right.

let scores = [3, 1, 2]
scores |> sort |> print
scores |> sum |> print

expected output

[1, 2, 3]
6

your turn / Add 4 to the list. The sorted result should be [1, 2, 3, 4], and the total should be 10.

try step 6 →

when something goes wrong

Read the error and its line number first. Check for missing quotes, closing parentheses or braces, and make sure a name is spelled the same everywhere. Fix one thing, then run again. A value will not appear in output unless you print it.

keep your work. keep learning.

The playground remembers your draft on this device. “save .lum” downloads a code file. “save program” stores a snapshot; “share link” gives you a lasting link to it. Anyone with that link can read the program, so leave out passwords and private information.