Skip to content

Latest commit

 

History

History
110 lines (82 loc) · 2.77 KB

README.md

File metadata and controls

110 lines (82 loc) · 2.77 KB

Väja

Väja is a dynamic interpreted language inspired by Elixir, Lua, Python, Nim and Monkey.

Features:

  • First class/higher order functions
  • Pattern matching for functions
  • Closures
  • Integers, floats, strings, bools, regex
  • A repl
  • let statements
  • Arithmetic expressions
  • Pipe operator
  • Immutable data
  • Uses a tree walking, top to bottom, interpreter
  • A pratt parser
  • A (work in process) compiler and virtual machine

Example syntax

let myList = [1, 2, 3]
let myLongerList = myList ++ [4, 5, 6]
Array.map(fn (x) -> x*2, myLongerList)
let isTrue = if (2 > 1) true else false end
print(String.len("my string"))
1.1 |> type()
let trimAndCapitalize = capitalize << trim
trimAndCapitalize("   helllo world")

This is how you would spin up the built in web server

Http.createServer() \
|> Http.addHandler(fn (req)
  {
    "status": 200,
    "body": "{\"message\": \"Hello world\"}",
    "headers": [
      ["Content-Type", "application/json"],
    ]
  }
end) \
|> Http.listen(8080)

Compiling from source

  • First install nim
  • Compile vaja: nim --run c -o:bin/vaja src/vaja.nim

Running

Using the repl

./bin/vaja
Väja
>>> 1+1
2

Executing a file

./bin/vaja examples/hello.vaja
2

Language syntax

See the language specification

Editor integration

You can find a vim plugin here.

Like the Väja syntax?

Awesome, since Väja is a "hobby" language I recommend that you use Elixir, a great Lua/Ruby functional language built around the BEAM.

Väja?

The name comes from a lumber mill in the northen of Sweden.

Running tests

  • nimble test

Credits

References/links

License

This project is released under the MIT License.