GALA (Go Alternative LAnguage) is a modern programming language that transpiles to Go. It brings sealed types, pattern matching, immutability by default, and functional collections to the Go ecosystem -- without sacrificing Go's performance, tooling, or library compatibility.
sealed type Shape {
case Circle(Radius float64)
case Rectangle(Width float64, Height float64)
}
func area(s Shape) string = s match {
case Circle(r) => fmt.Sprintf("circle area: %.2f", 3.14159 * r * r)
case Rectangle(w, h) => fmt.Sprintf("rect area: %.2f", w * h)
}
GALA gives you Scala-like expressiveness -- sealed types, exhaustive pattern matching, Option[T]/Either[A,B]/Try[T] monads, immutable collections -- in a concise, readable syntax that compiles to a single native binary. GALA is fully Go-compatible: every Go library works out of the box.
Sealed types and exhaustive pattern matching -- Define closed type hierarchies. The compiler rejects incomplete matches.
sealed type Result[T any] {
case Ok(Value T)
case Err(Message string)
}
val msg = result match {
case Ok(v) => fmt.Sprintf("got %d", v)
case Err(msg) => "error: " + msg
}
Immutability by default -- val and := are immutable. Structs auto-generate Copy() and Equal().
struct Config(Host string, Port int)
val updated = config.Copy(Port = 8080)
Expression functions -- Single-expression functions skip braces and return.
func square(x int) int = x * x
func max(a int, b int) int = if (a > b) a else b
Lambda type inference -- Parameter types and method type parameters are inferred from context.
val list = ListOf(1, 2, 3)
val doubled = list.Map((x) => x * 2)
val sum = list.FoldLeft(0, (acc, x) => acc + x)
Monads -- Option[T], Either[A,B], Try[T], Future[T] with Map, FlatMap, Recover, and pattern matching.
val name = user.Name
.Map((n) => strings.ToUpper(n))
.GetOrElse("ANONYMOUS")
Functional collections -- Immutable List, Array, HashMap, HashSet, TreeSet, TreeMap with Map, Filter, FoldLeft, Collect, and more.
val nums = ArrayOf(1, 2, 3, 4, 5)
val evens = nums.Filter((x) => x % 2 == 0)
val evenDoubled = nums.Collect({ case n if n % 2 == 0 => n * 2 })
Tuples with destructuring -- Up to Tuple5, with pattern matching and concise syntax.
val pair = (1, "hello")
val (x, y) = pair
Read-only pointers -- ConstPtr[T] prevents accidental mutation through pointers.
val data = 42
val ptr = &data // ConstPtr[int], not *int
val value = *ptr // OK: read
// *ptr = 100 // compile error: cannot write through ConstPtr
Full Go interop -- Use any Go library.
Download a pre-built binary from Releases, or build from source:
git clone https://github.com/martianoff/gala.git && cd gala
bazel build //cmd/gala:galapackage main
import "fmt"
struct Person(Name string, Age int)
func greet(p Person) string = p match {
case Person(name, age) if age < 18 => "Hey, " + name + "!"
case Person(name, _) => "Hello, " + name
}
func main() {
fmt.Println(greet(Person("Alice", 25)))
}
gala run main.gala
# Or with Bazel (recommended for projects)
bazel run //myapp:myapp| GALA | Go |
|---|---|
|
var msg string
switch shape._variant {
case Shape_Circle:
msg = fmt.Sprintf("r=%.1f", shape.Radius.Get())
case Shape_Rectangle:
msg = fmt.Sprintf("%fx%f", shape.Width.Get(), shape.Height.Get())
case Shape_Point:
msg = "point"
} |
| GALA | Go |
|---|---|
|
name := "ANONYMOUS"
if user.Name != nil {
name = strings.ToUpper(*user.Name)
} |
| GALA | Go |
|---|---|
|
type Config struct {
Host string
Port int
}
updated := Config{Host: config.Host, Port: 8080} |
| GALA | Go |
|---|---|
|
result, err := divide(10, 2)
if err != nil {
result = 0
} else {
result = result * 2
result, err = divide(result, 3)
if err != nil {
result = 0
}
} |
| Type | Description |
|---|---|
Option[T] |
Optional values -- Some(value) / None() |
Either[A, B] |
Disjoint union -- Left(a) / Right(b) |
Try[T] |
Failable computation -- Success(value) / Failure(err) |
Future[T] |
Async computation with Map, FlatMap, Zip, Await |
Tuple[A, B] |
Pairs and triples with (a, b) syntax |
ConstPtr[T] |
Read-only pointer with auto-deref field access |
| Type | Kind | Key Operations | Best for |
|---|---|---|---|
List[T] |
Immutable | O(1) prepend, O(n) index | Recursive processing, prepend-heavy workloads |
Array[T] |
Immutable | O(1) random access | General-purpose indexed sequences |
HashMap[K,V] |
Immutable | O(1) lookup | Functional key-value storage |
HashSet[T] |
Immutable | O(1) membership | Unique element collections |
TreeSet[T] |
Immutable | O(log n) sorted ops | Ordered unique elements, range queries |
TreeMap[K,V] |
Immutable | O(log n) sorted ops | Sorted key-value storage, range queries |
All collections support Map, Filter, FoldLeft, ForEach, Exists, Find, Collect, MkString, Sorted, SortWith, SortBy, and more.
TreeMap[K,V] is a Red-Black tree that maintains entries in sorted key order. It provides MinKey, MaxKey, Range(from, to), RangeFrom, RangeTo, and conversion to HashMap, Go maps, or sorted arrays.
Mutable variants of all collection types are available in collection_mutable for performance-sensitive code.
gala mod init github.com/user/project
gala mod add github.com/example/utils@v1.2.3
gala mod add github.com/google/uuid@v1.6.0 --go
gala mod tidybazel build //ide/intellij:plugin
# Install bazel-bin/ide/intellij/gala-intellij-plugin.zip via Settings > PluginsFeatures: syntax highlighting, code completion, brace matching, code folding.
Download from Releases:
| Platform | Binary |
|---|---|
| Linux (x64) | gala-linux-amd64 |
| Linux (ARM64) | gala-linux-arm64 |
| macOS (x64) | gala-darwin-amd64 |
| macOS (Apple Silicon) | gala-darwin-arm64 |
| Windows (x64) | gala-windows-amd64.exe |
git clone https://github.com/martianoff/gala.git
cd gala
bazel build //cmd/gala:galaload("//:gala.bzl", "gala_binary", "gala_library")
gala_binary(
name = "myapp",
src = "main.gala",
)- Language Specification -- Complete language reference
- Why GALA? -- Feature deep-dive and honest trade-offs
- Examples -- Code examples for all features
- Type Inference -- How type inference works
- Concurrent -- Future, Promise, and ExecutionContext
- Stream -- Lazy, potentially infinite sequences
- Immutable Collections -- List, Array, HashMap, HashSet, TreeSet, TreeMap
- Mutable Collections -- Mutable variants for performance
- String Utils -- Rich string operations
- Time Utils -- Duration and Instant types
- Dependency Management -- Module system
Contributions are welcome. Please ensure:
bazel build //...passesbazel test //...passes- New features include examples in
examples/ - Documentation is updated for grammar/feature changes
Apache License 2.0. See LICENSE for details.