Rix is an expressive and efficient language for the C ecosystem. Rix uses C libraries natively and generates easy to understand C code.
There are five core principles behind Rix:
- Ease of programming, inspired by Python
- Fast, like C code
- Type safety, like Scala
- Ability to go lower level and write C code
- No reserved keywords, everything is redefinable
We ran the prime counting benchmark for Rix, C and Python. Here's what we got:
| Measure | Rix | C | Python |
|---|---|---|---|
| Runtime (ms) | 457 | 424 | 7836 |
| Characters of code | 413 | 542 | 474 |
The best way to introduce yourself to this language is to take a look at some of the examples and try running them. Rix is still in early development; many features have not yet been fully implemented or described. A list of major development tasks remaining can be found in the wiki.
- Rix uses type inferencing, so the boilerplate Java statement:
Point point = new Point (x,y)
becomes a short Rix statement:
#point = Point (x, y)
New identifiers have are marked as new with "#", and Rix will infer their type for you. Their types cannot be changed once set. In the above example, point gets category Point.
Rix provides exception-safe resource management using Resource Acquisition Is Initialization (RAII), so you don't have to worry about memory leaks and unclosed file handles.
Rix tries to follow English linguistic constructs wherever possible and practical, so, most of Rix language expressions take the form:
Subject Verb Object
The following statements:
hello = "Hello"
helloWorld.add(hello)
parse as:
| Subject | Verb | Object |
|---|---|---|
| hello | = | "Hello" |
| myset | add | hello |
Subjects and objects are collectively known as nouns, and are analogous to object (instances of a class) in object-oriented programming.
Methods and function are called verbs in ritchie. For example:
factorial -> int (int n)
#result = 1
#i.for (1,n+1)
result = result * i
-> result
print (factorial (5))
You can also write succinct one liner verbs like the one below which gives the nth Fibonacci number:
fib -> int(int n) = (n <= 1).tf (n, fib(n-1) + fib(n-2))
print (fib(5))
There's no assignment operator in Rix, but = is defined as an assignment verb for Identifier.
- A special category of verb is a control flow verb.
if, while and for in Rix are all such verbs. They are not keywords, as you can redefine them, although this is probably not a good idea.
Rix has no keywords. All operators in Rix can be overloaded.
Rix is whitespace sensitive
- Build the rix compiler
make clean;make - Write your rix program in your favourite text editor (let's call it program.rit)
- Set RIX_HOME
export RIX_HOME=/path/to/rix - Run
${RIX_HOME}/rix.sh program.ritand rix will build, execute and run the program
Rix Language is being developed by a group of efficiency obsessed programmers for demanding programmers who want both the conciseness of Python and the efficiency of C.
Concept: Rohana Rezel (Riolet Corporation)
Design and implementation: Joe Pelz, Phillip Hood and Dimitry Rakhlei (final year students at BCIT, Burnaby, BC, Canada)
