A programming language idea: no static code, explicit caller context (Kite)
Marconi
soldate at gmail.com
Tue May 5 12:20:10 UTC 2026
On Monday, 4 May 2026 at 18:40:59 UTC, Dejan Lekic wrote:
> On Sunday, 3 May 2026 at 18:46:08 UTC, Marconi wrote:
> PS. you do not need AI to speak to humans on this forum. Use
> your own brain to compose words into sentences and write them
> here. :)
No way! :-) just kidding
I change this language a lot since post one.
[Github](https://github.com/soldate/kite)
AI:
Kite is an experimental “pretty C” language: Java-like object
references, C-like control, no GC, and no hidden ownership model.
Its main idea is that dangerous choices are explicit: heap
allocation goes through program-owned hooks, stack storage uses
`stack`, nullable/raw access uses `pointer`, and cleanup uses
`delete`.
```c
// Kite code lives inside `type` or `special type` blocks.
//
// `special type memory` is the program-owned memory policy.
// Normal object and array heap allocations pass through
`on_heap`.
// This is not a GC: the program still decides when to release
memory.
special type memory {
list heap_objects;
pointer on_heap(int size, int type) {
pointer p = allocator.alloc(size);
// The compiler exposes stable type ids such as `node.id`,
// so the owner can track allocations by type if it wants.
if (type == node.id) {
heap_objects.add(p);
}
return p;
}
void on_delete(pointer p, int type) {
if (type == node.id) {
heap_objects.remove(p);
}
allocator.free(p);
}
void clean_heap() {
heap_objects.delete_all();
}
}
// A normal user-defined type.
// Object variables are references, not C-style stack structs.
type node {
int value;
pointer node next; // explicit nullable/raw pointer; can be 0
void init(int v) {
value = v;
next = 0;
}
}
special type main {
void main() {
// Heap object by default.
// This calls memory.on_heap(...), then node.init(10).
node a = node(10);
// References are non-null by default.
// `b` refers to the same object as `a`, like a Java
reference.
node b = a;
b.value = 20;
// Stack storage must be requested explicitly.
// This is still a non-null node reference, but backed by
local storage.
stack node local = node(30);
// Arrays follow the same rule:
// without `stack`, storage is heap storage and goes
through memory policy.
int[] dynamic_numbers = [1, 2, 3];
int[3] fixed_numbers;
fixed_numbers[0] = dynamic_numbers[0];
fixed_numbers[1] = dynamic_numbers[1];
fixed_numbers[2] = fixed_numbers[0] + fixed_numbers[1];
// C-style control flow, required semicolons, fixed-size
primitive types.
for (int i = 0; i < fixed_numbers.length; i = i + 1) {
console.write(fixed_numbers[i]);
}
// Manual lifetime.
// `delete` calls memory.on_delete(...) when the owner
defines it.
delete a;
// Owner-level cleanup can also be explicit.
memory.clean_heap();
}
}
```
Beautiful, isn't it?
More information about the Digitalmars-d
mailing list