The language at a glance
A walk through Amalgame's features, in commented code.
Hello, world
The skeleton of a program: a namespace, a class, an entry point. The syntax is familiar (C#/Kotlin-flavored), immediately accessible.
namespace App import Amalgame.IO public class Program { public static void Main(string[] args) { Console.WriteLine("Hello, Amalgame!") } }
Variables, types, null-safety
let for immutable values, var for mutable. Type inference or explicit annotation. The ? suffix makes a type nullable, and ?. enables safe access.
let name: string = "Amalgame" var count = 0 count = count + 1 // Null-safety let maybe: Greeter? = null let label = maybe?.Hello() // label is null if maybe is null
Pattern matching
match is an expression. It supports guards, ranges, binders, and algebraic enums with destructuring.
let n = 42 let bucket = match n { 0 => "zero" x if x < 0 => "negative" 1..9 => "small" 10..99 => "medium" _ => "large" } public enum Shape { Circle(int) Rect(int, int) } match shape { Circle(r) => Console.WriteLine("r={r}") Rect(w, h) => Console.WriteLine("rect") }
Lambdas and list comprehensions
Multi-param lambdas with capturing scope, higher-order list methods.
// List comprehension let squares = [i * i for i in 0..10 if i % 2 == 0] // Higher-order let total = numbers.Filter(n => n > 0) .Map(n => n * 2) .Reduce(0, (acc, n) => acc + n) // Pipeline operator let shouted = name |> String.ToUpper |> String.Trim
Generics and interfaces
Generics erase to void* at the C level, but checked statically by the compiler. Generic interfaces enforce contracts verified at compile time.
public class Box<T> implements IComparable<int> { public Value: T public int CompareTo(int other) { return 0 } }
Tuples and destructuring
public static (int, int) DivMod(int a, int b) { return (a / b, a % b) } let (q, r) = Program.DivMod(17, 5) Console.WriteLine("{q} rem {r}") // String interpolation
What's next
To dig deeper: the full guide on GitHub, or jump straight to installing Amalgame.