hestia (pronounced es-TI-ah or HES-ti-ah) is a small, functional, dynamically typed programming language designed for writing small scripts. It can be learned in an afternoon, but is not especially fast or especially general-purpose. hestia is written in Rust and is free and open source under the MIT license.
hestia exposes a small set of syntactic forms. All data structures are immutable. There are no user-defined types or loops (recursion only). There are also no macros.
As a result, hestia encourages simple programs that are easy to read and comprehend. A batteries-included standard library is in-progress.
To illustrate hestia, consider a small script that reads integers from a file (each separated by a newline), parses them, sums them, then writes the sum to a new file.
(def read-and-sum { |file-name|
(>> file-name [
read-file # reads String from file
(split "\n") # splits String into List by newlines
(lmap to-i) # converts each String element in List into Integer
(lreduce 0 add) # sums all Integers in List
])})
(def read-sum-write { |in-file-name out-file-name|
(let ([sum (read-and-sum in-file-name)])
(write-file out-file-name sum))})
(read-sum-write "in.txt" "out.txt")
The >>
function (not macro) takes a value and a list of functions. It calls the first function with the initial value, calls the next function with the result of the prior call, and so on.
One important feature of hestia is automatic currying: calling a function that requires N
arguments with fewer than N
arguments returns a new function that takes the remaining arguments. (split "\n")
is a curried function.
Below is a simple hestia REPL running in the browser via WebAssembly.
Try (add 1 2)
or (lmap (add 1) [1 2 3])
.
© semaj 2023