r/ProgrammingLanguages • u/Mean-Decision-3502 DQ • Sep 03 '26
Unambiguous Operator Specification for Programming Languages
https://nvitya.github.io/pluops/As I changed recently the operators in my programming language I've created this specification:
https://nvitya.github.io/pluops/
I did not wanted to overload the operators like the C does with the / or Pascal does with theand/or/not. Neither re-use the operator symbols for some very different purpose, like C does with * and & so the code becomes more readable. I was orienting for existing solutions so this is what I came up with. The specification contains the symbol usages and operator precedence too.
If you are developing a new programming language, it would be nice to follow some standard, so at least the expressions would be portable between the languages.
I'm open for debates or suggestions.
View all comments
Show parent comment
1
u/EggplantExtra4946 Sep 04 '26 edited Sep 04 '26
Both are easy read imo, everybody that those operators have a high precedence. They are also artificial, the 1st one would be rare, the 2nd one would be even more rare.
This is utter non sense. We're talking about operators here, hence parsing. Even if an operators directly maps to a native instruction, you need associativity information to correctly parse expressions and produce the correct AST and compiled code.
The subtraction operator is usually left associative, so
1 - 2 - 3 = (1 - 2) - 3 = - 4. If it were right associative you would have1 - 2 - 3 = 1 - (2 - 3) = 2.Again utter non sense. How the fuck are you making a programming language if you don't know that syntax has practically nothing to do with semantics?
1 <= 2 < 3would be tranformed into1 <= 2 && 2 < 3. Perl and Ruby have the=~operator and yet CPUs don't have an instruction to do a backtracking regex match.And you think is easier to mentally parse, using a non-standard operator precedence, than the
x = y * *valueandif ((a & 1) == 0 && &var1 > &var2)?This is the kind of shit that would annoy a beginner programmer for a few weeks and then would get over it. Programmer with a bit of experience have internalized that
*and/have the same precedence and very few have a problem with it, it's at same level than 0-based indexing. Your design completely fucks over experienced programmers but beginners too because one day they are going to switch to a real language and will have to unlearn the programming basics they thought they acqired. The sooner they discard the preconception that expressions in programming languages are similar to algebraic expressions, the better. It's a good thing that they fall into traps like these when they start, it's the kind of the thing that makes them realize how much mechanical programming and programming languages are in some ways.