Dawn is a compiled language with major similarities to ECMAScript.
Dawn alleviates type-errors with a complicated and an in-depth typing system.
import { fraction, string } from "std::types";
import { print, scan } from "std::io";
import { toFrac } from "std::string";
class Point {
x: fraction;
y: fraction;
constructor(point: string) {
// check if point is (a/b, c/d)
let arr = point.replace(['(', ')'], '').split(',');
// array size is fixed
if (arr.length() == 2) {
// zero-cost spreading
print("({s}, {s})", arr[0], arr[1]);
// fraction-ize
this.x = toFrac(arr[0]);
this.y = toFrac(arr[1]);
};
}
};
Dawn also has support for structs:
struct MyDawn {
a: int;
b: string;
};
Pointers:
const arr = &myVar;
// dereference
*arr;
Node.js-style STL:
import { readFile, FileData } from "std::fs"; // with fs-extra features, too.
import { print } from "std::io";
import { Error } from "std::error";
readFile("./someFile.js", (err: Error, dat: FileData) => {
if (err) {
yeet err; // or: "throw err"
} else {
print("{}", dat.toString());
}
})
Passes are different steps which modify the source code. Dawn follows an expand-resolve scheme. This means that Dawn will first desugar your source code and then compile it.
Dawn will explicitly type all your source code. Example
const x = 10;
Becomes:
const x: int = 10;
const x = (a: int, b: int) => {
return a*b;
}
x(2,10);
Becomes:
// namespace
const x = {
function call(a: int, b: int) {
return a*b;
};
};
x::call(2,10);
Self-explanatory. Imports code and tree-shakes it.
When passing an anonymous function as an argument, it needs to be resolved.
Generate LLVM-IR.
Optimize the IR code.
Compile the code