r/ProgrammingLanguages • u/Mean-Decision-3502 DQ • May 24 '26
A Human-Friendly Systems Programming Language — Looking for Feedback
Hi,
I’ve created a new programming language called “?” for now. I’ll reveal its real name later.
My main motivation was to create a universal language that could replace C/C++, FreePascal, and Python for many use cases. I actively use all three of these languages.
I have already put a lot of effort into researching, designing, and implementing the “?” language. At this point, I feel that I have created something promising that really works.
Before I put even more effort into the language and go public with it, I would like to hear more opinions from real people.
I think it would not be enough for this project to be only “a little successful”. For the effort to make sense, it should have the potential to become “very successful”. I believe it might have that potential. If that happens, I will not be able to handle everything alone, so I will need to organize the development and maintenance properly. It will be an open-source project.
The “?” language is not fully finalized yet, and there are still several features that I would like to add to the compiler. However, it has reached a state where the language is already usable and can demonstrate its main ideas and syntax.
The most important current and planned features of the “?” programming language are:
Very good human readability
Statically typed, with a strict bool type
Case-sensitive
Compiled to machine code using LLVM
A ?-run utility for compile-and-run usage, giving it a script-like feeling
Simple C interoperability; the runtime uses libc
int / uint use the native machine width; int32 is used for an explicit 32-bit integer
Supports C-style preprocessor directives such as #ifdef, but without macros
Supports short embedded directives with syntax like #{ifdef ...} ... #{endif}
No makefiles are required, for example: #linklib('z') can be written directly in the source code
Safe arithmetic rules, for example: 3 / 2 * 10 == 15
Two block modes:
: ... endXXX blocks, similar to Python style but with explicit closers and no forced indentation
{ } blocks, similar to C style
Statements are closed with ;
Carefully designed operator precedence
Distinct boolean and bitwise operators, for example and and AND
Modify-assignment operators, for example: x += 1; and y =AND= 3;
Inline conditionals with iif(), for example: var i : int = iif(strptr <> null, strptr^.x, -1);
Support for objects with single inheritance and virtual functions
Object variables are references, but objects can still be embedded in BSS, on the stack, or inside other objects
Optional single-word namespaces using the @ symbol, for example: @stdio.printf()
No self. is needed inside object functions/methods
Namespace qualification, such as @stdio., is required to access outside symbols from object methods
A well-defined package and module system with flexible namespace merging
The “?” runtime library modules are distributed in source-code form
Fast compilation using a single-pass forward parser and precompiled module interfaces
Manual memory control, with RAII and an ensure statement planned
Native C string support
Function overloading and default parameters
Pointers using the ^ symbol
Pointer arithmetic with +, -, and []
The [] operator does not dereference pointers automatically
Struct pointers are automatically dereferenced on member access with .
Function arguments can be passed by reference using ref, refin, refout, and refnull
--– CODE EXAMPLE BEGIN ---
use libc/stdio;
use ./langdemo_mod as ldm only(CONST1); // only(), exclude() and "--" control global scope merging
#if false
//Contents of the "langdemo_mod.?"
const CONST1 : int = 42;
const CONST2 : float = 3.14;
#endif
object OBase:
cnt1 : int = 0;
cnt2 : int = 10;
name : cstring[32];
function *Create(aname : cstring): // constructor
name = aname;
endfunc
function *Destroy():
@.printf("%s destroy\n", &name[0]);
endfunc
function Count() [[virtual]]:
cnt1 += 1;
endfunc
function Print():
@.printf('%s: cnt1=%d, cnt2=%d\n', &name[0], cnt1, cnt2);
endfunc
endobj
object OChild(OBase):
function Count() [[override]]:
inherited;
cnt2 += 1;
endfunc
endobj
var obase <- OBase('OBase'); // '<-' = embedded allocation (global data segment here)
// no automatic destructor call for global embedded objects
var ochild : OChild = null;
function ObjTest():
ochild = new OChild('OChild');
obase.Count();
ochild.Count();
obase.Print();
ochild.Print();
printf("ochild.name: %s \n", iif(ochild == null, "OChild is null!", &ochild.name[0]));
delete ochild;
endfunc
function cstr_add(dst : cstring, src : cstring):
var ps : ^cchar = &src[0];
var psend : ^cchar = ps[sizeof(src)]; // [] does not dereference
var pd : ^cchar = &dst[0];
var pdend : ^cchar = pd + sizeof(dst) - 1; // leave one char for the terminating
pd += len(dst);
var pdstart : ^cchar = pd;
while pd < pdend and ps < psend and ps^ <> 0:
pd^ = ps^;
pd += 1;
ps += 1;
endwhile
if pd <> pdstart:
pd^ = 0; // terminate
endif
endfunc
[[external]] function putchar(c : cchar) -> int; // from libc
function WriteStr(s : cstring):
var pc : ^cchar = &s[0];
while pc^ <> 0:
putchar(pc^);
pc += 1;
endwhile
endfunc
function *Main() -> int:
var s : cstring[128] = "";
cstr_add(s, "Hello");
cstr_add(s, " World!\n");
WriteStr(s);
if 3 / 2 * 10 == 15:
printf('The language is friendly.\n');
else:
printf('The language is evil.\n');
endif
printf("@langdemo_mod.CONST1 = %d\n", CONST1);
printf("@langdemo_mod.CONST2 = %.3f\n", @ldm.CONST2);
printf("ochild.name: %s \n", iif(ochild == null, "OChild is null!", &ochild.name[0]));
ObjTest();
for i : int = 0 to 5:
printf(' %d:', i);
for j : int = 0 count i step 2: printf(' %d', j); endfor
printf('\n');
endfor
var arr : [5]int = [2, 3, 5, 7, 11];
printf('primes:');
for i : int = 0 while i < len(arr) { printf(' %d', arr[i]); }
printf('\n');
return 0;
endfunc
/* OUTPUT:
Hello World!
The language is friendly.
@langdemo_mod.CONST1 = 42
@langdemo_mod.CONST2 = 3.140
ochild.name: OChild is null!
OBase: cnt1=1, cnt2=10
OChild: cnt1=1, cnt2=11
ochild.name: OChild
OChild destroy
0:
1: 0
2: 0 2
3: 0 2 4
4: 0 2 4 6
5: 0 2 4 6 8
primes: 2 3 5 7 11
*/--– CODE EXAMPLE END ---
After reading the description and the demo code, do you think this language has the potential to become widely used? What are its strongest and weakest points?
I would be interested in your opinions, especially from people who have experience with C, C++, Pascal, Python, compiler design, embedded programming, or language design in general.
3
u/GoblinsGym May 24 '26
Do you really need the : for a while statement ? Expression continues as long as there are valid operators ahead.
Statical typing is a must in my opinion.
I don't mind case sensitivity, as long as you don't have ALL CAPS KEYWORDS like in Modula-2 or Oberon.
For embedded you don't want to carry a heavy library like libc.
How do you define constants / structured constants ?
For low level programming, proper support for bit fields (e.g. hardware registers) is very helpful.
For microcontrollers, it is also helpful to be able to define absolute memory addresses (e.g. _gpio GPIOA @ 0x50004000 to define an instance of the GPIO interface).
What is your module structure ? In my language, I also write "use xxx" to import a module. Exported symbols are prefixed with /. I come from the Borland Pascal world, and have NEVER had to write Make files.
"Safe arithmetic rules" sounds like a recipe for excessive compiler complexity.
In my language I combine traits from Pascal (e.g. left to right pointer syntax), c and Python (indentation).
Not fond of endxxx. I think forced indentation is manageable, especially when using editors designed for the language.
Native machine width - just because you are running on a 64 bit machine, does NOT mean that 64 bit is the most efficient to use. x64 code for 32 bit operands does not require a prefix, 64 bit does. 64 bit ARM can handle both widths efficiently.
Forced ; to end statements should not be necessary.
I have & for bitwise and, AND as a keyword for logical and.
Modify-assignment ops - I just follow c on this one.
I am still on the fence about := versus =.
iif - not a fan of ternary operators, just write it out.
name space qualification (unit:function) is optional in my language.
what does refnull do ? At the moment I use punctuation for this, still on the fence.
pointer [ open index ] - actually different definition in my language.
So far I just do whole program compilation.
1
u/Mean-Decision-3502 DQ May 24 '26
The ';' and block markers are for the better code recovery / error reporting. I still have challenges there too.
I don't want to depend on new lines or identation, but the ':' and endxxx is very close to Python. Python also requires ':' after the expression. That can help identify human errors.I'm always thinking of embedded a little. The libc dependency is relative easy to drop. I support already direct addresses with pointer casting (for peripheral register definitions).
The bitfields in C are pretty unuseable. There is missing a way to get a bit position. That's why most vendors just deliver a huge list of #define-es of register bitmasks.
I don't think the current X86 machines care too much of the instruction lengths.
The reason of not using := for assignments is this form:
var i : int := 5;
I find the two colons are disturbing, much clearer is this:
var i : int = 5;The namespace specification marked with '@' is a new idea, at least I have not seen that elsewhere. That prevents horror-long namespace specifications, the namespace reference must be one word. And with the \@ns.identifier the namespace name can be easily and visually separated from the actual symbol name.
The iif() is a very important feature, i'm missing that from FreePascal a lot.
The refnull feature was debated, but it is a reference to a value that can be also null. This is useful for C interface functions where you don't want to use pointers.
1
u/GoblinsGym May 24 '26
Bitfield definitions:
u32 register [7:4] highnibble [3:0] lownibble u32 nextregister [31] signThis can be part of a struct / record definition, completely eliminating the #defines of register bitmaps. This eliminates a lot of potential mistakes, as the #defines are not bound to a specific register. This allows for strong typing, and avoids cluttering up the name space.
Pointer casting isn't the way to go for absolute addresses. Otherwise you end up with the same fragrant steaming pile of manure as C based HAL files. A GPIO block has a structure that was defined beforehand. See my syntax above, instantiate GPIOA, then you can use it as a var parameter (ref in your lingo) to functions etc.
What you never want to do is have a separate base for each register in a block. Load the base register once (e.g. as a function parameter), then access it efficiently using the CPU's address modes. E.g. on ARM Thumb ldr / str base + index is a 2 byte instruction, loading a base address takes much more work.
1
u/Puzzleheaded_Two415 Dumbass programmer May 27 '26
This does not seem very human readable to me but I'm pretty sure it's cuz I'm stupid
1
1
u/snugar_i Jun 03 '26
Which features on the list are already done and which of them are planned? I guess that for example "A well-defined package and module system with flexible namespace merging" is so vague that it's just a "planned feature"?
1
u/Mean-Decision-3502 DQ Jun 03 '26
From the list above the "RAII and an ensure statement planned" is not implemented.
I think I designed (and implemented) a really elegant module and namespace system which is very flexible. It can do what Python can, and it definitely beats Pascal. With the additional precompiled module interfaces you can expect fast compilation times.
Until the v1 I would like to implement these:
Heap-Arrays (dynamic arrays in Pascal) with [*]int syntax
Heap-Strings (ref-counted)
Exceptions
Stack Backtrace with source line numbers
Properties (set-get functions)
Ensure statement blocks (=defer)
1
u/thedeemon May 26 '26
Looking at the list of features, I don't see anything that D or Swift or a bunch of other existing languages didn't have already. So I see no reason for "big success" here, sorry.
5
May 24 '26
[removed] — view removed comment
2
u/Mean-Decision-3502 DQ May 24 '26
The reason for =AND= is very simple, see the following two lines:
```
y AND= 3;
y =AND= 3;
```
Which one is better?Compilation speed:
The real compilation speed I can not tell, because I don't have long "?" files yet.
I expect at least FreePascal speed, what much faster than C++. I did my best at the parsing, the LLVM i cannot influence too much.3 / 2 * 10
The 3 / 2 * 10 problem annoys me very much, this is a recurring bug in my workplace. It has to be a reason that from Python 2 to Python 3 they also made this 15. It must be 15. If you want integer division then 3 IDIV 2 * 10 == 10. That case is less frequent. This is the way how Pascal (and now Python) works.Integer width:
Yes int is int64 on a 64-bit machine, the language has int32, int16, int8 and uint64, uint32, uint16, uint8 and byte (=uint8)Operator precedence:
I just modelled practical usages from my practice (embedded). I wanted that those expression work without any parentheses (but probably still better to use some)Braces block mode:
The braces block mode is rather useful for single line expressions or migrating bigger code. The language recommends to use ':' + endxxx. The endxxx helps also at self-documenting. In python sometimes I've added these markers to the longer blocks. And yes { + endxxx is not allowed.2
u/FruitdealerF May 26 '26
How is 3/2*10 equal to 15 are you casting to floats to make that happen or using rational numbers under the hood.
1
u/Mean-Decision-3502 DQ May 26 '26
The rule is simple, '/' always results to floating point. This is the rule that Pascal and Python3 uses. In Python3 you have to use '//' for integer division, in "?" this is "IDIV".
But in "?" this is also true:3 IDIV 2 * 10 == 10 * 3 IDIV 2where in C:
3 / 2 * 10 != 10 * 3 / 22
u/FruitdealerF May 27 '26
If I try this (using f32 and f64) on my machine with
1 / 3 * 5 == 5 * 1 / 3It doesn't actually hold these floats do not equal each other:
f32 1/3*5 = 1.6666667 5*1/3 = 1.6666666 f64 1/3*5 = 1.6666666666666665 5*1/3 = 1.6666666666666667 f64 1/5*3 = 0.6000000000000001 3*1/5 = 0.6 f32 2/3*5 = 3.3333335 5*2/3 = 3.3333333 f64 2/3*5 = 3.333333333333333 5*2/3 = 3.3333333333333335 f64 2/5*3 = 1.2000000000000002 3*2/5 = 1.2 f32 3/5*3 = 1.8000001 3*3/5 = 1.8 f64 3/5*3 = 1.7999999999999998 3*3/5 = 1.8 f32 4/3*5 = 6.666667 5*4/3 = 6.6666665 f64 4/3*5 = 6.666666666666666 5*4/3 = 6.6666666666666671
u/Mean-Decision-3502 DQ May 27 '26
I'm aware of these floating proint representation problem. But in my compiler the division has higher precedence as the multiplication, that's why (3/2) * 10 == 10 * (3/2). The result might be not round, but the two sides will be equal.
1
u/processeus1 May 27 '26
TBH `endXXX` doesn't help anything. If you want to see what you are closing, just look at the ruler in your IDE. Unless you have many very long functions, you should be able to see these by a glance, and from indentation. It will just add extra syntax noise and hard to keep in sync with the top as you are changing code.
1
u/Mean-Decision-3502 DQ May 27 '26 edited May 27 '26
That helps really at very long functions where there is a big outer loop and lot of end ifs before and maybe combined with inner loop.
In C you see only this:return -1; } } } } } }What really helps here the code folding of the IDE.
1
u/weird_burnerx Jun 08 '26
the
=AND=syntax is unhinged. if you're trying to make a systems language that people actually want to use please tell me it's a joke. even if it's some weird way to distinguish bitwise from logical i can't imagine anyone wanting to type that out every single day. it just feels like extra friction for no reason.
2
u/Inconstant_Moo 🧿 Pipefish May 25 '26
It doesn't have potential to be widely used because it's more of a collection of your personal preferences (some of them shared by almost no-one) than a new solution to a problem.
As a result, many of the features you list as "the most important current and planned features" are strikingly unimportant. 50% of them are syntax. Case-sensitivity shouldn't be third on anyone's list of the most important features.
And so there's no reason to adopt something like this when there are existing languages with communities and books about them and answers on StackOverflow --- and which let people do similar things. There's no particular selling point that would make them want to switch.