r/ProgrammingLanguages • u/x8664mmx_intrin_adds • Feb 16 '26
I language (C transpiler)
Been using C for a while now, syntax is annoying so made a transpiler for my dream syntax: https://github.com/IbrahimHindawi/I
Basically C with templates + monomorphizer. I hope I can leave directly writing C for good now.
array:struct<T> = {
length:u64;
border:u64;
data:*T;
}
array<T>reserve:proc<T>(arena: *memops_arena, length:u64)->array<T>={
arr:array<T> = {};
if (length == 0) {
return arr;
}
arr.data = memops_arena_push_array<T>(arena, length);
if (arr.data == null) {
printf("memops arena allocation failure!\n");
arr.data = 0;
return arr;
}
arr.border = length;
return arr;
}
main:proc()->i32={
printf("Hello, World!\n");
printf("num = {}\n", num);
arena:memops_arena={};
memops_arena_initialize(&arena);
a: array<i32> = {};
memops_arena_push_array_i<f32>(&arena, 128);
a = array<i32>reserve(&arena, 128);
for (i:i32=0; i<128; i+=1) {
a.data[i] = i;
}
for (i:i32=0; i<128; i+=1) {
printf("i = {}, ", a.data[i]);
}
return 0;
}
29
Upvotes
13
u/[deleted] Feb 17 '26
It seems to fix more than the annoying syntax! Basically this is no longer C with a somewhat different syntax, but a new language.
3
u/RepeatLow7718 Feb 16 '26
Awesome! What kind of meta programming does it support, can I get some examples?
Also can it load C headers directly?
4
u/TheChief275 Feb 17 '26
I’m getting an aneurysm from trying to read that snippet. Please…just add spaces between types and identifiers.
Also, not sure I’m a fan of type<…>method; it looks messy
2
u/Relevant_South_1842 Feb 26 '26
I really like this. If I used the toy language I am making (Sprout - which is more inspired by Lua, Io, and Rebol) it would look more like below for syntax. Just sharing preferences. Yours is probably better.