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.
No ceremony before the first line. Types are worked out for you, and written down when they help.
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") }
Emerald: 2.5 carats Ruby: 1.25 carats
print("Hello, world!")
Hello, world!
That is the whole program. No class, no main, no semicolons.
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.
game.em:2:7: [E1001] `scroe` is not defined print(scroe + 1) ^^^^^ Check the spelling, or declare it before this line.
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.
game.em:2:9: this is String, but `lives` holds Int lives = "three" ^^^^^^^ Assign a value of the declared type, or convert it first.
Most languages ask you to pick two. Emerald is built to keep all three.
A one-line first program. Words instead of symbols: and, or, not. No null, no semicolons, no boilerplate.
Blocks, interpolation, optionals, traits, enums, and tasks without async orawait. Say it in a few readable lines.
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.
Every language has rough edges. These are the ones that cost a beginner an afternoon, and that Emerald smooths away.
input("Name? ") asks and gives back what was typed, not a chain of method calls.
Always, so greet and greet() can never be mistaken for each other.
7 / 2 is 3.5, and 7 // 2 is 3, when you ask for it.
A value that might be missing says so with ?, and the checker will not let you forget.
A condition must be a real true or false, never something merely "truthy".
The built-in formatter keeps every program tidy in the same way, so there is nothing to argue about.
The tools you would otherwise have to find, install, and learn separately.
emerald format tidies a program, or a whole project.
@test and assert, run with emerald test.
Try a line of Emerald and see the answer at once.
A language server with errors as you type, hover, go to definition, rename, and completion.
Files, dates, JSON, CSV, regular expressions, HTTP, and more, with nothing to install.
Let work wait at the same time, with no threads, locks, async, or await.