Koi is a language that seeks to make many traditional bugs impossible by preventing them at the language level. Each of these are discussed in more detail below.
- Prevent all runtime errors. Runtime errors are, by definition, unexpected and either have to be caught and emit and error under a sitution that can't be handled safely or cause the program to blow up.
- No garbage collector, but no manual memory management either. It's unsafe to manage memory manully, but we also don't want the overhead of a garbage collector.
- Interoperability with C. This is critical to making sure we can use existing libraries and also makes the lanaguage a lot easier if we can offload the lowest level logic to C.
- All objects are also interfaces. Any object can be provided for a type if it fits the receiving interface.
- First class testing. Language constructs for dealing with tests, assertions, mocks, etc.
- Sum types handle behaviors like errors.
There is a differnce between detecting and avoiding. We have to be careful avoiding doesn't become a burdon.
- Nil derefernecing.
- Divide by zero.
- Overflow and underflow.
- NaN and infinities.
- All matching must be exhaustive?
- Array and map out of bounds.
- Casting to an invalid type.
- Signals and other interupts.
- Explicit order of operations.
- Zero out memory.
- Explicit mutability.
- No jumps/gotos (including breaking).
- No operator overloading.
- No type overloading.
Memory cannot be shared between processes.
Launching a process returns a different type (ie. Process[MyObject]) that itself provides the API for syncronizing calls.
Any value that attempts to cross a process boundary must implement a Copy
interface.
Reference counting.
- Tests
- Assertions
- Mocks
type NumberOrString = number | string
type MultiValues = (number, bool) | None
type NamedTypes = @high (number, number) | @low (number, number) | number
func static[doStuff] :good number | :bad number | error {
}
func {
const result = match static[doStuff] {
:good n number {
n + 5
}
:bad number {
-1
}
error {
0
}
}
}
Erorrs are just a return type. Auto snapshotting?