The Felix Programming Language

Felix the cat

Examples

// herein lies an RPN calculator, written in Felix
var prog = "1 1 + 3 * 2 /";
var acc = 0;
var st = list[int]();

for tok in split(prog, ' ') do
    match tok.str with
    | "+" => st = st.tail.head + st.head + st.tail.tail;
    | "-" => st = st.tail.head - st.head + st.tail.tail;
    | "*" => st = st.tail.head * st.head + st.tail.tail;
    | "/" => st = st.tail.head / st.head + st.tail.tail;
    | ?d => st = d.atoi + st;
    endmatch;
done;

st.head.println;
// same as println st.head;
// ...which is the same as print $ head st;

More About Felix

Felix is a highly performant, scalable, and safe scripting language suitable for rapid development of software systems.

It gets its speed from its C++ code generator which also provides compatibility and easy interopability with existing C and C++ code bases. The native C++ compiler does the hard work of low level optimisation whilst Felix does high level optimisations and type-checking. The resulting code is very fast, sometimes "faster than the speed of light (C)", but can be platform independent and is simple to deploy—just distribute the source files and run them, like a scripting language or distribute the statically linked binary.

Felix's type system is based on a combination of OCaml and Haskell. Like OCaml, it provides strong support for functional programming, whilst also supporting imperative programming. The type system is strict and includes first-order polymorphism at its core; not bolted-on like Java generics or C++ templates. Felix supports open overloading like C++, but only allows exact matches. It also provides Haskell style type classes as an alternative way to obtain genericity.

Felix supports user defined macros and syntactic improvements. This extensibility allows a developer to easily write domain specific sub-languages (DSLs) with ease. The parser is GLR and the user actions are written in R5RS Scheme.

A rich set of shortcuts makes programming a breeze. B regular expression support and other features provide string handling on par with Perl. Web programming is enabled by built-in asyn socket I/O combined with cooperatively multi-tasked fibres that would support millions of HTTP clients if only the server could supply enough sockets. Context switching is achieved by a pointer swap, and state is maintained by a spaghetti stack.