Ritchie is an expressive and efficient language for the C ecosystem. Ritchie uses C libraries natively and generates easy to understand C code. It is named after the great computer scientist Dennis Ritchie, if not for whom we would all be programming in Visual Basic.
There are five core principles behind Ritchie:
- 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 Ritchie, C and Python. Here's what we got:
Ritchie | C | Python | |
---|---|---|---|
Runtime (ms) | 457 | 424 | 7836 |
Characters of code | 423 | 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. Ritchie 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.
- Ritchie uses type inferencing, so the boilerplate Java statement:
Point point = new Point (x,y)
becomes a short Ritchie statement:
point = Point x, y
Identifiers have their type inferred when they are first used and their type cannot be changed after that. In the above example, point
gets type Point
.
-
Ritchie tries to follow English linguistic constructs, so, most of Ritchie language expressions take the form:
Subject Verb Object
The following phrase:
hello = "Hello"
parses as:
Subject | Verb | Object |
---|---|---|
hello | = | "Hello" |
- Ritchie has no keywords. There are many symbols with predefined meanings, but the intention of Ritchie is to have all those symbols redefineable. Currently Ritchie has been developed with a standard dialect of Ritchie in mind, and to that effect many symbols work as keywords might otherwise have in other languages. For example to define a class in Ritchie, you would type
SomeClass :: SomeBaseClass
The ::
is simply a verb that reads "become a subclass of".
- We call verbs what the constructs called functions, methods or subroutines in other languages. For example:
Integer : factorial Integer n
result = 1
i for 1,n+1
result = result * i
-> result
print factorial 5
There's no assignment operator in Ritchie, but =
is defined as an assignment verb for Identifier
.
- A special type of verb is a control flow verb.
if
, while
and for
in Ritchie are all such verbs. They are not keywords, as you can redefine them, although this is probably not a good idea.
- Ritchie is whitespace sensitive
- Build the ritchie compiler
make clean;make
- Write your ritchie program in your favourite text editor (let's call it program.rit)
- Set RITCHIE_HOME
export RITCHIE_HOME=/path/to/ritchie
- Run
${RITCHIE_HOME}/ritchie.sh program.rit
and ritchie will build, execute and run the program
Ritchie 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)