New Language on the BEAM
Elixir is a enjoyable, productive language. OTP provides wonderful libraries, and BEAM is a kick-ass virtual machine. What else would you want as an Elixir/Erlang/OTP developer?
Static type system? Gleam and Alpaca have that.
More parentheses? Lisp Flavoured Erlang has plenty of those.
Great Erlang/OTP interop? Elixir is already very good at that.
What I want is something that combines all of the above. I’ve been inspired by Racket and Clojure, but love working with OTP, so I’m going to write a new language. Because it’s for me, I’m going to name it after myself and call it Erie.
I think it might look something like this. Pardon the lack of syntax highlighting. That will come later.
(defmodule MyNs.MyModule
[use: MyNs.MacroModule
import: Ecto.Query
alias: MyNs.Other.Long.ModuleName])
(deftype (Result e a)
{'ok a}
{'error e})
(deftype (Optional a)
a
nil)
(def to_string [result: (Result String Integer)] String
(case result
[{'ok int} (Integer.to_string int)]
[{'error str} str]))
(def join_with_oxford_comma [list: (List String)] String
"""
Combines `list` into a grammatically correct string.
"one" or "one and two" or "one, two, and three".
"""
(case list
[[] ""]
[[one] one]
[[one two] (string-append one " and " two)]
[list
(let
[last (Enum.at list -1)
all-but (Enum.take list (range 0..-1))]
(string-append (Enum.join all-but ",") " and " last))]))
A few features to note.
- Polymorphic type system.
- Basic types are more similar to Elixir’s (lists, tuples, maps, and strings as binaries).
- Pattern matching will be front and center.
Everything is subject to change as it gets built, but after “writing” a few dozen lines of Erie, this seems like a good place to start.