/hymn-lang

Small scripting language.

Primary LanguageCMozilla Public License 2.0MPL-2.0

Hymn Scripting Language

A small byte-code interpreted language with a focus on simplicity. Visit the website!

# import additional scripts
use "math"

# tables hold key value pairs
func new-node(value) {
  return { value: value, next: none }
}

func node-add(list, value) {
  set node = list
  while true {
    if node.next == none { break }
    node = node.next
  }
  node.next = new-node(value)
}

# objects are passed by reference
set list = new-node("hello")
node-add(list, "world")

# print statements will show all nested values in an object
echo list

Why use Hymn

  1. You want reference counting memory management. Memory is released deterministically, as soon as possible. There are no random garbage collection pauses in Hymn.
  2. You feel programming paradigms like classes and interfaces add unnecessary complexity. Hymn only has strings, arrays, and tables.
  3. You don't need namespaces. The Hymn use statement imports all variables and functions globally.
  4. You want a scripting language with C like conventions: Brackets indicate scope, indices start at 0, and the not equals operator is !=
  5. You're weary keeping up with evolving programming languages. Hymn is small and will stay small. There will not be significant changes to the core language and built-in functions.

Development

Principles

  1. Portable C11 code that passes with -Wall -Wextra -Werror -pedantic flags
  2. Small implementation under 10,000 total lines of C code
  3. Reference counting memory management
  4. Easy to learn syntax
  5. No closures
  6. No namespaces
  7. No classes
  8. No breaking changes after version 1.0

Performance

AMD Ryzen 5 1600 6 core 3.2 GHz - Windows 10 using Ubuntu WSL

Test Factors Fib List Loop Objects Primes Tail
Hymn 1.92s 2.15s 2.25s 1.17s 3.64s 1.21s 4.28s
Lua 1.14s 1.16s 1.98s 0.72s 4.66s 0.81s 1.81s
Python 3.98s 2.27s 2.63s 1.28s 4.68s 2.59s -
Node 0.69s 0.10s 0.68s 0.45s 1.77s 0.19s -
Lua JIT 0.08s 0.11s 0.56s 0.28s 1.20s 0.06s 0.03s