EMERALD

A friendly language you'll enjoy writing

Simple enough for a first program, expressive enough that you never feel boxed in, and checked before it runs. Made for classrooms, and for anyone who wants a small, pleasant language.

Get startedInstall

Say what you mean

No ceremony before the first line. Types are worked out for you, and written down when they help.

gems.em
struct Gem {
    const name: String
    const carats: Float
}

const gems = [Gem("Emerald", 2.5), Gem("Ruby", 1.25)]
for gem in gems {
    print("#{gem.name}: #{gem.carats} carats")
}
Output
Emerald: 2.5 carats
Ruby: 1.25 carats
The first program
print("Hello, world!")
Output
Hello, world!

That is the whole program. No class, no main, no semicolons.

Mistakes that explain themselves

Emerald checks your whole program before it runs anything. When something is wrong, it says what, where, and what to try, in words a beginner can act on.

A typo
game.em:2:7: [E1001] `scroe`
is not defined
  print(scroe + 1)
        ^^^^^
Check the spelling, or declare
it before this line.
A missing value
game.em:2:7: addition needs numbers,
but this is Int? and Int
  print(age + 1)
        ^^^^^^^
One of these may be absent. Give it
a fallback with `.or(0)`, or check
it against `nothing` first.
The wrong kind of value
game.em:2:9: this is String, but
`lives` holds Int
  lives = "three"
          ^^^^^^^
Assign a value of the declared
type, or convert it first.

Three things, none at the others' expense

Most languages ask you to pick two. Emerald is built to keep all three.

I

Simple

A one-line first program. Words instead of symbols: and, or, not. No null, no semicolons, no boilerplate.

II

Expressive

Blocks, interpolation, optionals, traits, enums, and tasks without async orawait. Say it in a few readable lines.

III

Typed

Types are inferred, so you rarely write them, and checked before the program runs. That is also what lets a language be fast: a native compiler is the long-term goal.

Where other languages trip students

Every language has rough edges. These are the ones that cost a beginner an afternoon, and that Emerald smooths away.

Input is a plain call

input("Name? ") asks and gives back what was typed, not a chain of method calls.

Calls have parentheses

Always, so greet and greet() can never be mistaken for each other.

Nothing rounds silently

7 / 2 is 3.5, and 7 // 2 is 3, when you ask for it.

No null

A value that might be missing says so with ?, and the checker will not let you forget.

True means true

A condition must be a real true or false, never something merely "truthy".

One style

The built-in formatter keeps every program tidy in the same way, so there is nothing to argue about.

Everything in the box

The tools you would otherwise have to find, install, and learn separately.

A formatter

emerald format tidies a program, or a whole project.

Tests

@test and assert, run with emerald test.

A REPL

Try a line of Emerald and see the answer at once.

Editor support

A language server with errors as you type, hover, go to definition, rename, and completion.

A standard library

Files, dates, JSON, CSV, regular expressions, HTTP, and more, with nothing to install.

Tasks and channels

Let work wait at the same time, with no threads, locks, async, or await.

Write your first programSee where it is going