Nasper
Nasper is a small, native, linearly typed, performant functional programming language. I created this over my time in undergrad, as I was annoyed every time I used a programming language because the semantics in my head, learned from theory, were so much cleaner than what I was forced to write in imperative languages.
At the same time, I was dissatisfied by the lack of hardware awareness in functional languages, which prevented their use in serious engineering endeavors. So I used linear typing and stream and closure monomorphization to create hardware-aware primitives in a language with functional semantics: allowing for the speed of systems programming languages, the nice semantic properties of functional languages, combined together with the craft and simplicity of languages like C or Go (at least of old Go; nowadays Go has lost the Thompson and Pike touch and made some really overly complex decisions).
I was able to achieve some nice results with this language design. The self-hosted compiler bootstraps itself from its own 65,000 lines in 12 seconds, LLVM and clang included. An optimized build of the compiler bootstraps the same 65,000 lines in 11. One thread of the HTTP server on an M5 Pro MacBook handles 225k requests a second over HTTP/1.1 and 852k over HTTP/2, in 4 MB of memory. On the same machine and the same handler, Rust's hyper on one thread does 220k and 772k in 19 MB, Go's net/http 127k and 292k, and Node 132k and 213k. All of this in a language without mutation is pretty cool.
main (streams, print)
# A record, and a method that consumes it.
# The result type names the case that fails.
<account: owner str, balance int>
(a account) withdraw(amount int) account ? str
if amount > a.balance
"insufficient funds"
<*a, balance int: balance - amount>
# An infinite stream: only what is pulled is built.
fibs(a int, b int) |int|
|int: a, *fibs(b, a + b)|
evenSum(count int) int
first = streams.take(fibs(0, 1), count)
even = streams.filter(first, (x &int: x % 2 == 0))
streams.sum(even, 0)
main()
acc = <account: owner = "Ada", balance = 100>
total = evenSum(20)
when acc.withdraw(30) is
left print.line("{left.owner}: {left.balance}, {total}")
problem print.line("{problem}")Ada: 70, 3382I haven't released it publicly, but it is working: the server for this website is written in Nasper, for example. Email me if you want to use it: jacob@thecaminoapp.com.