Hiss
My WIP hobby programming language implemented in Haskell.
Hiss is my WIP hobby programming language implemented in Haskell and Zig. It is named in honor of a copperhead snake discovered in the basement of my parents’ house, which was then serving as my bedroom.
I’m building Hiss to learn more about compilers, interpreters, and functional programming. (So here’s your disclaimer: it’s neither well-tested nor stable and will almost certainly never be recommended for production use.)
Here’s a sample Hiss program that computes the Collatz stopping time of 27:
// computes k mod n
mod(n, k) = if k < n
then k
else mod(n, k-n)
mod2 = mod(2) // partial application of mod
// returns stopping time of n
collatz(n, steps) = if n == 1
then steps
else if mod2(n) == 0
then collatz(n/2, steps + 1)
else collatz(3*n + 1, steps + 1)
main() = collatz(27, 0) // should output 111
Try running this program on the playground!
Hiss is:
- Purely functional
- Strictly evaluated
- Strongly typed using the Hindley-Milner type system
- Essentially a proper superset of the lambda calculus
It supports some cool features from functional programming:
Hiss is open-sourced on GitHub. It has two main components:
hissc
– Hiss bytecode compiler, written in Haskellhissvm
- Hiss bytecode interpreter, written in Zig
hissc
and hissvm
are still in progress, but they already include:
- Hiss lexer and parser
- Semantic passes
- A name-checking pass that rejects undeclared identifiers
- A dependency-checking pass that rejects value cycles (code like
a = b, b = c, c = a
) - A type inference and type-checking pass
- (Incomplete) code generation
- Bytecode interpreter
- An online playground where you can try Hiss yourself!
Planned work includes
- Completion of code generation
- Optimization passes
- User-defined types and pattern matching
- Side effects for I/O? Who knows!