Git Product home page Git Product logo

mariosieg / corium Goto Github PK

View Code? Open in Web Editor NEW
18.0 5.0 4.0 253.93 MB

Corium is a modern scripting language which combines simple, safe and efficient programming.

License: Apache License 2.0

CMake 1.03% C++ 83.76% Shell 0.09% Starlark 0.27% HTML 0.10% SCSS 0.02% C 0.28% Python 3.37% Assembly 0.98% Less 0.01% Makefile 0.01% Cuda 0.01% Dockerfile 0.01% Rust 10.08% Batchfile 0.01%
virtual-machine emulator runtime interpreter bytecode jit-compiler assembler native runtime-system virtualization

corium's Introduction

The Corium programming language

image

Corium is a modern, fast and simple scripting language,
empowering easy but powerful programming with high performance.
A language for everyone for everything.

The goal is to create a new programming language,
which is easy to learn for new developers and
for developers comming from other languages. The language is also very flexible and fast
thus a good choise for many different projects.


Core features

  • Simple
  • Safe and test driven
  • Statically typed with type inference
  • Builtin parallelism using the parallel keyword
  • Builtin GPU computing using the compute keyword
  • Fast scripting and prototyping
  • Cross-platform
  • Workspace system for complex projects
  • Simple but powerful types
  • Builtin package manager

The project

The project was started around February in 2021,
to create a new programming language for the world.
A language for beginners and experts, for desktop and mobile.
Trying to unite different tech-stacks.
This year (2021/2022) I will participate with Corium as my project in Jugend Forscht,
a German science competition.

I was always bugged by the two language problem:
If you write your code in a simple and high level language,
the productivity will be high but not the performance.
Of course the performance in enough in most cases,
but many performance critical parts are often implemented in a fast language such as C, C++ or Rust.
This is very error prone and requires much more effort from the development team.
There are existing approaches for a simple and fast programming language,
but they are all komplex languages themselves.
Corium aims to just be simple and fast,
using a clean and consistent syntax and a "friendly" compiler.
In my opinion, many languages are too bloated in features,
having multiple ways to do the same thing.


Development state

Corium is in an early development stage.
The compiler is currently prepared for an alpha release,
with basic but solid features.
The Alpha will be available in the next Months for testing and feedback purposes.

Support

If you want to support the project,
feel free to contribute or suggest any idea you would like.
You can also support the project without development, by sponsoring!


Infrastructure

Corium IntelliJ IDEA Plugin Also works with CLion, WebStorm, Rider and any other IDEA based IDE.
Discord Server Join our small and friendly community. Everyone is welcome!


Implementation

The two primary components are:


Sponsors

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


Corium preview

"Talk is cheap. Show me the code." ― Linus Torvalds
Code snippets in Corium to get a quick overview.

Idiomatic conventions

  • No semicolons - new line per statement
  • Keywords are lowercase
  • Mutable variables are lowerCamelCase
  • Immutable variables are SCREAMING_CASE
  • Types and classes are UpperCamelCase
  • Functions and methods are lowerCamelCase
  • Interfaces are IUpperCamelCase with an I as prefix
  • Modules are lowercase
  • Source file names are lowercase with the .cor file extension

Primitive Data Types

There are 4 primitive data types in Corium.
Choosing a type is easy, each primitive type has exactly one purpose.

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 unsigned UTF-32 encoded character.
  • Can hold any unicode codepoint.

Advanced Data Types

Corium contains multiple advanced data types and structures.
These are implemented in the standard library, but the most important ones are
auto-imported into each file.
  • String
  • List
  • Option
  • Result
  • BigInt
  • BigFloat
  • Object

Comments

# This is a single line comment
#! This
is
a multi line
comment
!#
#@ This is a doc-comment which will appear in the generated documentation.

Hello, world!

The Corium hello world is a one-liner:

print("Hello, world")

The print() function is used to print text to the console.
A new line is appended by default.


Variables

In general, the identifier is written before the type.
For most cases, the type is inferenced from the expression:
Expression Inferred type
10 int
0.5 float
true bool
'C' char
"Muffins" String
new MyClass() MyClass

Of course the type can be explicitly specified.
So
A:

let x = 10

is seen by the compiler as
B:

let x int = 10

In most cases, letting the compiler infer the types is the way to go. (A)
But sometimes, extra type information can be beneficial. (B)

Mutable variables are defined using the let keyword.
They also use lowerCamelCase as naming convention.

let num = 10
let time = 23.45
let food = "Burger"

Immutable variables are defined using the const keyword:
They also use SCREAMING_CASE as naming convention.

const IS_DEBUG = true
const PI = Math.atan2(1.0, 1.0) * 4.0
const FAVOURITE_FOOD = "Lasagne"

Functions

Functions are defined using the function keyword.

A simple function without a parameter or return type:

function simple() {

}

A function with a float x as parameter but no return type:

function simple(x float) {

}

A function with a float x as parameter, return type of type float and a return statement:

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

Conditionals

A simple if-statement:

let isSunshine = true

if isShunshine {
    print("Let's go to the beach")
}

For chained conditions the and, or and not operators are used.

An if-statement with a chained condition:

let isSunshine = true
let isSummer = true
let temperate = 20

if isShunshine or isSummer and not temperature < 18 {
    print("Let's go to the beach")
}

if-statements can also be chained using else and else if

A chained if-statement with an else block:

let isSunshine = true

if isShunshine {
    print("Let's go to the beach")
} else {
    print("It's raining, let's play some games instead")
}

A chained if-statement with an else if and else block:

let isSunshine = true
let temperate = 20

if isShunshine {
    print("Let's go to the beach")
} else if not temperate < 15  {
    print("Let's go for a walk")
} else {
    print("It's raining, let's play some games instead")
}

For long and complex comparisons,
the compare statement can be used.
It resembles a switch-statement from C-like languages,
but is much more powerful.

let grade = 'C'

compare grade {
    'A' => print("Easy"),
    'B' => print("Very good!"),
    'C' => print("It's okay"),
    'D' => print("I'll do better next time"),
    'E' or 'F' => print("Let's try that again"),
    else => print("Grades must be from A to F!")
}

corium's People

Contributors

4ndre4s avatar mariosieg avatar noel2003 avatar raphaelschnick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

corium's Issues

Does this system support the x87 FPU?

Is it possible to run this system on old hardware using x87 FPU for floating point calculations only (no MMX, SSE)?
Is there support for 32-bit too?

Fix interpreter tests

Interpreter tests won't suceed because we still need a proper way to parse intrinsic proc ids.
Marked with "TODO"!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.