r/ProgrammingLanguages • u/MackThax • May 20 '26
Discussion How would programming languages look if English used "," as the decimal separator?
https://www.reddit.com/r/MapPorn/comments/1tesrye/decimal_separators_used_in_europe/
Only English (including USA) uses a dot as a decimal separator. Imagine it used comma (,) instead. Pick a popular programming language and imagine how it would look, taking into account all of its historical influences.
I'd guess C would just insist on whitespace when listing stuff. That, or it would use ";" to list stuff, with I guess "." becoming a statement separator, and "\" to reach into structs, why not. š
13
Upvotes
27
u/csharpboy97 May 20 '26
In German we use the , as decimal seperator. The excel/powerfx is translatet so ; is used as seperator for arguments
7
u/00PT May 20 '26
They would end up using a different character for tuple and list item separation to disambiguate two integers and a decimal literal.
7
u/tiajuanat May 20 '26
Is C's
,operator not enough for you?? You want a language that's gasping for air??/j
7
u/s0litar1us May 20 '26 edited May 20 '26
Maybe it would have ended up like this?
; is already used in english to separate a list of things containing commas.
I don't think other stuff would be affected as the . notation to access stuff isn't linked to the . used for decimal numbers afaik. Though if it had to change then maybe -> would have been used for everything?
7
u/sadesaapuu May 20 '26
In an alternative universe they use dots ā.ā to end programming āsentencesā. Most programming languages use the semicolon ā;ā for that purpose for random reasons.
So, already the world of prgramming is using very different symbols than natural languages. In that sense the comma as a decimal separator would work fine. Just make it unambiguous enough by replacing other things with different symbols, like semicolon.
5
u/dontthinktoohard89 May 20 '26
No one here seems to have pointed out that COBOL, the language designed to be most English-like, actually has a
DECIMAL POINT IS COMMAconfiguration switch that can be enabled on a per-function basis.3
u/Purinto May 20 '26
In python, there is a file with all the syntax words and their AST token equivalent. You can just fork python and replace the dot which is used in floats for the comma, compile your project and here you got your god awful aberration of a programming language.
Be careful with changinf the tuple, array etc. separators, or else you'll have a potential ambiguous syntax
Also Be careful of not changing the attribution ., as in class.attribute or else you'll have an even worse programming language.
3
u/amarao_san May 20 '26
Haskell style argument passing.
(equivalent of
diada(1.5, 3.14))3
u/L8_4_Dinner (ā Ecstasy/XVM) May 20 '26
What a silly question! It's time for the entire world to learn English so we don't have problems like this any longer. And we'll all switch to PHP as our one programming language to avoid confusion on computers.
2
u/Arakela May 20 '26
declarations declaration, declarations sp declaration.
declaration name sp productions sp ".".
sp , sp space_char.
name alfa, name alfa.
productions production, productions sp "," sp production.
space_char " ", "\t", "\n".
alfa "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z".
production member, production sp member.
member primary_member quantifier, .
primary_member name, "\"" alfa "\"", "(" sp productions sp ")".
quantifier , "?", "+", "*".
2
u/DonnPT May 20 '26
I would expect period and comma would be swapped, as they are in numerals ( 1,008.90 -> 1.008,90 ), so
{ point.x, point.y } = { 35.6, 90.4 }->{ point,x. point,y } = { 35,6. 90,4 }Not my favorite.
2
u/GOKOP May 20 '26
The choice of comma for lists was almost certainly made because that's how we enumerate things in normal language: item1, item2, item3... That's regardless of what is the decimal separator, and there'd be no reason to change something in programming languages. It's not a problem to interpret a comma differently in different context
1
u/fl_needs_to_restart May 20 '26
If you think about it we already have a similar situation, since the dot character is used both as a digit separator and for member access. So using a comma instead of a dot with similar consequences. Though you would always need spaces in lists of numbers.
1
u/Prestigious_Boat_386 May 20 '26
Same as now, we already have languages eith comma as decimal separator. As soon as you start writing vectors you turn the decimal separator into a dot
1
u/Key_River7180 Nain. May 20 '26
Here proposing the best decimal separator ever: the '
1
u/johnyeldry May 20 '26
simple:
in other langauges they use , as ., ; as , so something needs to fill the role of , which . is unused
so . replaces ,
[1.2.3.4.5.6]
, replaces semicolon
int main(int argc.char** argv){
return 0,
}
and , replaces .
1,259
1
u/Smalltalker-80 May 20 '26
In Smalltalk, this could be implemented in a few hours.
Just change the (float) number parser method from period to comma,
and change the (operator) methods named "," (comma) to something else.
(I don't think it's a good idea, though... One standard please. And I'm European)
1
u/lassehp May 23 '26
I think programming languages should follow the ISO 80000 standards to the letter as much as possible (and other ISO standards when applicable.)
ISO 80000-1 says that the decimal separator is either a comma on the line or a point on the line, and usage should be consistent in a document. So a PL should support both. For thousands separator, a half-space or narrow space would be ideal, but underscore would be a good alternative with usage precedents in for example Ada. If the syntax does not allow adjacent numeric literals, even a plain space could be used.
21
u/[deleted] May 20 '26 edited May 20 '26
[removed] ā view removed comment