Introducing Kraken
30 Jul 2014Kraken is a new systems programming language in developement.
Checkout Kraken on Github
It strives to be clean, elegent, expressive, and grounded in theory. We'll get there, eventually. Some of Kraken's design goals:
- Compiled
- Clean
- Statically typed
- Fast (Writing, Compiling, and Running)
- Minimal to no "magic" code. That is, anything the language or standard library can do, you should be able to do.
It is inspired by C/C++, Python, and Rust, and already supports some powerful features such as:
- Mutually Recursive Definiitons (types and functions without need for forward declaration)
- Class and Function templates
- Type Traits that can overload templates
Hello World
import io;
|int| main() {
io::println("Hello World!");
return 0;
}
or
import io: *;
|int| main() {
println("Hello World!");
return 0;
}
Mutually Recursive Definitions
import io;
typedef AType {
|BType| member;
|void| print() {
member.print();
}
}
typedef BType {
|int| data;
|AType*| next;
|void| print() {
io::println(data);
}
}
|int| main() {
|AType| a;
|BType| b;
b.data = 1337;
a.member = b;
a.print();
return 0;
}
Dynamic Memory
import io: *;
import mem: *;
typedef ClassWithConstructor {
|int| data;
|ClassWithConstructor*| construct(|int| inData) {
data = inData;
return this;
}
|void| printData() {
println(data);
}
};
|int| main() {
// Stack allocated
|ClassWithConstructor| object.construct(4);
object.printData();
// Heap Allocated
|ClassWithConstructor*| objPtr = new<ClassWithConstructor>()->construct(11);
objPtr->printData();
// For now, templates always have to be explicitly instantiated.
// However, this will be changed soon.
delete<ClassWithConstructor>(objPtr);
return 0;
}
Design
The Kraken Programming Language is in its infancy. Currently, it consists of a RNGLALR parser written in C++, an experimental grammer that is evolving, and a C code generator. When compiled, the kraken compiler will take in a text file to be parsed, the grammer file to use, and an output file name. Kraken will then generate the RN parsing tables from the grammer OR load them from a binary file if Kraken has been run with this exact version of the grammer before. Then it will parse the input and export DOT files for every .krak file in the project (these can be renderd into a graph using Graphviz), a C file for every file in the project, and a .sh script containing the compiler command to compile the C files together into a binary.
About
Kraken is developed as a personal project by Nathan Braswell.
This site was generated by Jekyll and is based on Poole