Awesome Open Source
Awesome Open Source

Corium Programming Language

Corium is a modern scripting language for all platforms.
The goal is to have a safe, clean and easy to write scripting language,
which is still very fast, so it can be used for AI, HPC or game development.
The final features of the language are:

  • Easy to learn
  • Clean syntax
  • Safe, statically typed
  • Test driven development
  • Fast prototyping
  • Parallel keyword for automatic parallelism
  • Offload keyword for automatic GPGPU
  • Cross-platform development
  • Builtin formatter
  • Builtin package installer
  • Fast

The source code for the language parser is in the Corium directory.

Why another language?

As you might know,
there are already plenty of programming languages out there.
Many programming can be divided into two groups (the so called two language problem):
There are very high level languages such as Python or Java and
many performance critical code is written in a more lower level language
such as C, C++ or Rust. This is highly inefficient as it requires more knowledge,
testing and time. Of course it is also more error prone.
Corium allows for code which is clean, portable, easy to write and still very fast.
With semicolons and an easy to read C-like syntax, Corium is easy to learn.
The core language features are enough for all kinds of projects, but not too much to become bloated.
It has a great and easy to use debugger, package manager and linter.
Just get your favourite editor like VisualStudioCode, IntelliJ or something else,
and start coding!
It's also fairly easy to embed Corium into an existing C++ application.
Corium also is used as a game scripting language in one of my custom engines.

What's the current state of Corium?

Corium is currently under heavy development.
Nominax (the runtime system) is ready for simple Corium programs.
The primary focus lies on the frontend language lexer and code generator.
In some weeks, it is expected to have a first working version,
which can be used to write simple code in Corium.
This is a big step, from that point on features will come in quickly.
That's why we need you!
Consider to contribute or sponsor the project!
Let's make Corium a widely used, beginner friendly and fast language!

Nominax Runtime

Nominax is the runtime environment for Corium.
It supports heavy parallelism, JIT compiling and garbage collection out of the box.

The source code is in the Nominax directory. For more technical information, check out the Nominax ReadMe.

Sponsors

A special thanks to all of my sponsors!
Thank you for supporting my work, this gives me a lot of motivation.
Sponsors in chronological order:

Roadmap

Discord Server
Trello Board

Corium To-Go ☕️

Short cheat sheet for the basics

Primitive Data Types

There are 4 primitive data types in Corium:
  • int
  • float
  • bool
  • char

The number types int and float
are 64 bits wide and provide enough range and precision for all tasks.
Corium empowers static typing for safety and explicit code,
and choosing the type is very simple.
Every of the 4 primitive type is perfect for
some specific type of data.

int

  • A 64-bit signed integer.
  • Can hold values from -9223372036854775808 to 9223372036854775807.
  • Because it it signed, it can also hold negative values.
  • This type is used as the default type for natural number calculations.
  • The equivalent in other C style languages is “long”.

float

  • 64-bit double precision float.
  • Can hold values from -2.22507•10−308 to approximately 1.79769•10308.
  • This type is used as the default type for real number calculations.
  • The equivalent in other C style languages is "double".

bool

  • A boolean type.
  • Can either be true (1) or false (0).

char

  • A 32-bit UTF-32 character.
  • Can hold any unicode codepoint.

Comments

Comments in Corium begin with a #, like in Python:

let x = 10 # This is a comment, x is of type int!

Multiline comments are written using two ## for the begin and the end:

##
    This is a
    long long,
    long
    multiline comment.
##
let x = 10

Local Variables

We've just learned the primitive data types. In Corium, local variables are declared by the follow scheme:
let <VariableName> <Type?> = <Literal?>

Let's create some local variables using the let keyword. No semicolons required!

let a int = 3
let b float = 2.5
let c char = 'O'
let d bool = true

If you look at the above scheme again,
the Type and the Literal are optional (indicated by the ?).
That means that we can elide them:

let a = 3
let b = 2.5
let c = 'O'
let d = true

That's better right?
Corium knows the type from the literal, so types can be deduced: | Literal | Deduced Type | | ------------- | ------------- | | 3 | int | | 2.5 | float | | 'O' | char | | true | bool |

Functions And Methods

Like in many other languages, every program starts in within the

main function. So let's follow the tradition and start with hello world:

fun main () {
    print("Hello, World")
}

Methods and functions are declared by the following scheme:

fun <FunctionName> ( <Parameters> ) <ReturnType> {

}

As you can see above, functions are declared using the fun keyword. Let's write a function which takes no parameters and returns nothing:

fun sayHello () {
    print("Say hello to my little friend!")
}

in C we would write this function like this:

void sayHello () {
    printf("Say hello to my little friend!\n");
}

this also applies to many other languages deriving from C such as C++, Java or C#,
but of course the priting mechanism is different.
Lets write another functions which returns a number:

fun getNumber () int {
    return 5
}

Let's write it again in C:

int getNumber() {
    return 5;
}

As you can see, the return type is just at a different position and there are no semicolons.
If your functions returns nothing, the return type is just elided.
There is no need to write void like we know it from C style languages.

Parameters are written in the following scheme:

<ParameterType> <ParameterName>

A simple square function could look like:

fun square (float x) float {
    return x * x
}

This function has a parameter x of type float
and has a return value of type float too.

To invoke a function the () call operator is used.
Arguments are submitted inside the parenthesis:

let y = square(2.0)
# Now y is 4.0

Conditionals

In Corium, the classic if statement which executes code
if the expression is true, is written using the following scheme:

if <Expression> {
    <Body?>
}

The same applies to else if.
A big difference to C is that there are no parenthesis () around the if-expression.
But the curly braces { } are always enforced.

Corium provides following comparison operators:

Operator Meaning
== equal to
!= not equal to
< less than
> greater than
<= less or equal to
>= greater or equal to

A simple if-statements which checks if the variable x of type int equals 10 could look like:

let x = 10
if x == 10 {  # Will be true
    print("x is 10!")
}

To execute code when the expression in the if-statement is false,
a simple else block can be used:

let x = 5
if x == 10 { # Will be false
    print("x is 10!")
} else {
    # Instead this code will be executed, because ```5 == 10``` is false!
    print("x is not 2!")
}

Using the final combination of if and else,
else if statements can be used.
These executed if the previous if statement did not execute,
because the condition was false:

let x = 2

if x == 0 {
   print("x is 0!")
} else if x == 1 {
   print("x is 1!")
} else if x == 2 { 
    print("x is 2!")
} else {
    print("x is something else!")
}

The most powerful statement is the compare statement.
The following scheme is used:

compare <Expression> { 
    <Body?>
}

It is somewhat similar to the switch statement in C, but much more powerful.
A compare statement is made out of multiple arms. For each arm the scheme is:

<Expression> | else => <Body?>

A simple example:

let x = 3
compare x {
    0 => print("x is 0!")
    1 => print("x is 1!")
    2 => print("x is 2!")
    3 => print("x is 3!")
    else => print("x is something else!")
}

Each "arm" act's like a if statements:
The first arm ``0 => print("x is 0!")``` is the same as:

if x == 0 {
    print("x is 0!")
}

If x is zero, print x is 0!. The following arms are like else if statements
and the final arm else => print("x is something else!") acts exactly like a normal else statement:
if none of the above conditions occured, print x is something else!! In fact, it's possible to write the whole compare statement
using linked if else statements, but that's ugly and far less clean.

Loops

Comming soon...

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
C Plus Plus (371,190
Language (3,530
Cross Platform (3,287
Interpreter (2,203
Emulator (1,955
Multithreading (1,466
Concurrency (1,296
Fast (1,163
Native (1,082
Virtual Machine (1,066
Parallel (890
Assembler (755
Parallel Computing (690
High Performance (616
Runtime (578
Virtualization (459
Bytecode (400
Related Projects