Fork me on GitHub

Vortex is a scripting language that compiles to Lua.

It aims to provide a comfortable, modern scripting language that follows both Lua and "batteries included" philosophies. Note: Vortex is not stable at this point and many of the features are incomplete/missing/undecided on.

The IRC channel: #vortex-lang @ irc.freenode.net

First, a small taste of the language.

/* sample output:
 * [ 82, 53, 62, 67, 47, 63, 47, 7, 49, 59, 74, 97, 32, 65, 8 ]
 * [ 7, 8, 32, 47, 47, 49, 53, 59, 62, 63, 65, 67, 74, 82, 97 ]
 */

math.randomseed(os.time())
fn filter(l, f) -> [ seq -> for i, v in ipairs(l) -> if f(v) -> yield v ]

fn rec qsort(l) ->
    | [] -> []
    | x :: xs -> qsort(filter(xs, fn v -> v <  x))
       ++ [x] ++ qsort(filter(xs, fn v -> v >= x))

let t1 = [ seq -> for i = 1 .. 15 -> yield math.random(1, 99) ]
print(e"[ $(tconc(t1, ', ')) ]\n[ $(tconc(qsort(t1), ', ')) ]")

Vortex is convenient.

It includes syntax inspired by languages such as Lua, Scheme, Rust, OCaml and F#. Staying true to its roots, it provides facilities for semantic extension and adds its own for the syntax as well. It's multi-paradigm, providing builtin support for several programming styles by default, primarily functional.

It's a fully expression based language, having no statements. There are multiple expressions that are, however, mostly used as statements and do not work like expressions in the traditional form (such as goto).

Vortex is powerful.

In addition to Lua, Vortex provides many additional features, including:

Vortex is fast.

It outputs nice, pretty-printed Lua code that is as fast as its handwritten equivalents, particularly with LuaJIT, which is also the primary environment Vortex is supposed to be used in.

Vortex is compatible.

The output is fully compatible with Lua 5.2 and LuaJIT. Lua 5.1 compatibility is not guaranteed and some code might not work (the output uses extensions such as goto and the bit library).

Want more?

Try it out! And feel free to look around for examples.


News

January 19 2013More updates
New features, new examples, updated website text. Check out git logs for more information.
November 8 2012Updates
Implemented lots of features, like pattern matching, objects, proper loops and so on. All examples on this page work now. Preparing online REPL. 0.1 coming soon.
October 28 2012Initial website launch
I launched this website. It's incomplete at this point, but eventually more content will appear.

About Vortex

Vortex was created by Daniel "q66" Kolesa as an attempt to create a language that uses Lua as an intermediate step. It tries to keep the best from Lua while eliminating the noise and verbosities and adding new useful features.

Instead of using a limited indent-based syntax, Vortex stays with a free form one where whitespace is insignificant, allowing for custom formatting of the source code, but at the same time attempts to make it as clean as possible. Here you can see some of the features Vortex has.

/* tail recursive, pattern matched factorial
   /* long comments can be nested */
 */
fn rec fact(n, acc = 1) ->
    | 0 -> acc
    | _ -> fact(n - 1, n * acc)

// sequences
let (a, b, c) = seq -> for k, v in pairs([ 5, 10, 15 ]) -> yield v
assert(a == 5 and b == 10 and c == 15)

// sequences as list comprehensions
fn fun(args...) ->
    [ seq -> for k, v in pairs(args) -> yield v * 2 ]
assert(fun(1, 2, 3)[3] == 6)

// hybrid prototype/class object system with multiple differential inheritance
// if you're inheriting from Object, you don't specify it
let Foo = clone ->
    fn __init(x) -> @x = x
    fn boo() -> print("boo!", @x)
end

let Bar = clone ->
   fn baa() -> print("baa!", @x)
end

let Baz = clone (Foo, Bar) ->
    fn boo() do
        print("new boo!")
        Foo.boo(self)
    end
end

let inst = new Baz(5)
inst:boo()
inst:baa()
/* A more realistic quicksort example
 * median of 3 pivot, insertion sort for small chunks
 */

fn partition(lst, l, r, p, fun) -> with pivot = lst[p] do
    set (lst[p], lst[r]) = (lst[r], lst[p])
    for i = l .. r - 1 -> if fun(lst[i], pivot) do
        set (lst[i], lst[l]) = (lst[l], lst[i])
        l += 1
    end
    set (lst[l], lst[r]) = (lst[r], lst[l])
    return l
end

fn insort(lst, l = 1, r = #lst, f = fn a, b -> a < b) -> for i = l .. r ->
    with (j, v) = (i, lst[i]) do
        loop while j > 1 and not f(lst[j - 1], v) do
            lst[j] = lst[j - 1]
            j -= 1
        end
        lst[j] = v
    end

fn rec qsort(lst, l = 1, r = #lst, f = fn a, b -> a < b) -> if (r - l) > 10 ->
    with pi = partition(lst, l, r, floor((l + r) / 2), f) do
        qsort(lst, l, pi - 1, f)
        qsort(lst, pi + 1, r, f)
    end
else insort(lst, l, r, f)

let t1 = [ 5, 10, 36, 24, 18, 7, 1, 3, 13, 27, 84 ]
print(e"[ $(tconc(t1, ', ')) ]")
qsort(t1)
print(e"[ $(tconc(t1, ', ')) ]")

Installation

At this point, you'll have to clone the Git repository and run things manually. You'll need LuaJIT or Lua 5.2. Regular Lua 5.1 will not work.

In the future, I might provide some automated system based on LuaRocks or something.


Vortex FAQ

Why Vortex?
Because the language is always in a whirl. :) The name will stay when the language is stable though.
How about editor support?
At this point, there is jEdit syntax file included in the repository. Vim support is coming soon and others possibly too.
Why a new language?
I worked with many languages and so far I haven't found any that shared all the goals with Vortex.
Where can I find more information, example code, list of differences etc.?
The wiki is the place you want.