Bern
An interpreted, dynamically typed programming language focused on clarity and expressiveness, blending functional ideas from Haskell with a lightweight syntax inspired by Lua and Odin. Made in Haskell.
About
Bern is a small, interpreted, dynamically typed programming language focused on clarity and expressiveness. It blends ideas from functional programming, inspired by Haskell, with a lightweight imperative syntax influenced by Lua and Odin, so that experimentation, scripting and learning feel natural without sacrificing structure.
- Everything is an expression.
- Literals and expressions are evaluated and printed automatically.
- Syntax stays minimal and readable.
- Control flow is explicit and uniform.
Bern 2.0
The 2.0 major release turned the interpreter into a configurable language. Auto-currying, lazy ranges, exhaustive match checking, short-circuit operators and negative indexing became defaults, and file-level pragmas such as {--! strict-types !--}, {--! immutable !--} and {--! errors-as-values !--} let each file opt into stricter or looser behaviour. It also added written-word operators, the )| pipe, when guards, a JSON library and a much-improved REPL.
FizzBuzz in Bern
numbers = [1..100]
loop n : numbers do
if n % 15 == 0 then
"FizzBuzz"
else if n % 3 == 0 then
"Fizz"
else if n % 5 == 0 then
"Buzz"
else
n
end
end
Pattern matching and pipes
def classify(n) when n > 0 -> "positive"
def classify(0) -> "zero"
def classify(n) -> "negative"
[1, 2, 3, 4] )| filter(\x -> x % 2 == 0) )| map(\x -> x * 10)
-- [20, 40]
Tooling
bern, an interactive REPL.bern build app.brn, which bundles a script and its imports into a standalone executable.- A VSCode extension with syntax highlighting, snippets and REPL integration, published on the Visual Studio Marketplace.
- Install scripts for PowerShell and Bash on the Bern website.
Bern is open source and community driven, released under the BSD-3-Clause license, and contributions are welcome.