Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kinderjosh/ki

Ki is a programming language that aims to be extremely permissive and minimal. It's perfect for people who like having full control of their program and like writing software from scratch.
https://github.com/kinderjosh/ki

compiler compiler-backend compiler-frontend intermediate-representation nasm programming-language x86-64

Last synced: 5 days ago
JSON representation

Ki is a programming language that aims to be extremely permissive and minimal. It's perfect for people who like having full control of their program and like writing software from scratch.

Awesome Lists containing this project

README

        

# Ki

Ki is a programming language written from scratch that aims to be like C, but more geared towards general-purpose programming. It is perfect for people who like having full control of their program and like writing software from scratch.

> [!WARNING]
> This language is still in development and is riddled with bugs and issues.

> [!IMPORTANT]
> This language targets Linux x86-64 and I don't plan on adding any other architectures.

## Examples

Hello world:

```c
void main() {
putln("Hello world!");
}
```

Run length encoding algorithm:

```cpp
#include "core/string.ki"

String *rle_encode(String *src) {
String *code = String::new();

for u32 i = 0; i < String::len(src); i += 1 {
u32 count = 1;

while i + 1 < String::len(src) && String::at(src, i) == String::at(src, i + 1) {
count += 1;
i += 1;
}

if count > 1 {
u8 buf[32];
itostr(buf, count, 10);
String::concat_chars(code, buf);
}

String::append(code, String::at(src, i));
}

return code;
}

void main(i32 argc, u8 **argv) {
if argc < 2 {
fputstr(stderr, "error: missing argument \n");
exit(1);
}

String *data = String::from(argv[1]);
String *code = rle_encode(data);

putln("before: ");
putln(String::get(data));
putln("after: ");
putln(String::get(code));

String::delete(code);
String::delete(data);
}
```

You can find more examples in the [examples](./examples/) directory.

## Installation

Firstly make sure you have the following dependencies installed.

- gcc
- nasm
- make

Then run the makefile:

```
sudo make install
```

This installs the compiler as ```ki``` into ```/usr/local/bin/``` and its libraries into ```/usr/local/share/ki/```.

## Usage

```console
$ ki --help
usage: ki [options...] [flags...] [...]
options:
-build follow rules defined in build.ki to compile
-c compile to an object file
-g compile to an executable file with debugging information
-l link with a library (linking mode must be enabled)
-ld link object files using gcc
-o place the output into
-S compile to an assembly file
flags:
-freestanding don't include the standard library or initialize the heap by default
-nomain don't require a main function
```

## Editor Highlighting

> Neovim with Ki syntax highlighting and the Azeret Mono font.

See the [doc](./doc/editor-highlighting.md) for instructions.

## Documentation

See the [doc](./doc/) directory for documentation.

## License

Ki is distributed under the [MIT](./LICENSE) license.