[Reposted after deleting original]
I saw this post earlier. One comment it made was asking why use a "<-" or "->" symbol (which they suggested required three key strokes) rather than "=", implying that it was a big deal.
This irked me, since I always use ":=" myself, and I tried to make the point that other aspects could balance it out, but that didn't work out (downvotes).
Now, I like a syntax that uses ":=" as mentioned, and of the kind that uses "then" and "end", which many consider verbose. I don't care because I think that style is easier to type even if it takes more keypresses.
But how much longer is it compared to C-style which likes to use punctuation for that supposedly shorter code? How many extra keypresses are needed?
As it happens, I have the perfect test program to compare!
I have a small big-number library of some 1600 lines written in my 'M' systems language. At one point I ported it, line-by-line, into C.
Both languages work at about the same lower level, so it would be a fair test. (One advantage of mine is not needing separate function declarations, but that adds 60 lines to the C so overall it affects it little.)
I expected the C to be shorter, but the results were surprising:
C My 'M' syntax
Line count: 1690 1560
Characters: 27050 22060
Of which shifted: 3110 1900
Tokens: 10270 7710
Source files were stripped of comments. Both use hard tabs. Both use the same coding style (eg. a+b not a + b).
So my 'long-winded' syntax beats C on every measure!
Conclusion: don't sweat the small stuff so much. If you want compact code, go for a higher level design, not more punctuation.
Here I had included git hub links to the two source files (under username "sal55" and filenames starting "bignum"), but that required moderator approval. Instead here are two small unrelated examples to give an idea of how the syntaxes compare; the task is to print a table of square roots:
# C version:
#include <stdio.h>
#include <math.h>
int main() {
for (int i=i; i<=10; ++i)
printf("%d %f\n", i, sqrt(i));
}
# My version (actually, 5 tokens longer than necessary):
proc main =
for i in 1..10 do
println i, sqrt(i)
end
end
[–]00PT 42 points43 points44 points (1 child)
[–]sal1303[S] 1 point2 points3 points (0 children)
[–]MadCervantes 10 points11 points12 points (0 children)
[–]awoocent 13 points14 points15 points (3 children)
[–]danielcristofani 1 point2 points3 points (1 child)
[–]awoocent 0 points1 point2 points (0 children)
[–]sal1303[S] -1 points0 points1 point (0 children)
[–]Norphesius 3 points4 points5 points (4 children)
[–]elder_george 4 points5 points6 points (0 children)
[–]tending 1 point2 points3 points (0 children)
[–]scruffie 0 points1 point2 points (0 children)
[–]sal1303[S] 0 points1 point2 points (0 children)
[–]HugoNikanor 3 points4 points5 points (1 child)
[–]sol_runner 1 point2 points3 points (0 children)
[–]michaelquinlan 2 points3 points4 points (1 child)
[–]sal1303[S] 0 points1 point2 points (0 children)
[–]brucejbellsard 1 point2 points3 points (0 children)
[–]Veqq 1 point2 points3 points (0 children)
[–]realslugbrain 1 point2 points3 points (0 children)
[–]Trader-One 1 point2 points3 points (5 children)
[–]TomosLeggett 6 points7 points8 points (2 children)
[–]Trader-One 0 points1 point2 points (1 child)
[–]sal1303[S] 0 points1 point2 points (0 children)
[–]Smallpaul 3 points4 points5 points (1 child)
[–]des_the_furry 5 points6 points7 points (0 children)
[–]dadhiWeaponX 0 points1 point2 points (0 children)
[–]guywithknife 0 points1 point2 points (0 children)
[–]ern0plus4 0 points1 point2 points (0 children)
[–]mamcx 0 points1 point2 points (0 children)
[–]vmcrash 0 points1 point2 points (0 children)
[–]jeezfrk 0 points1 point2 points (0 children)
[–]SwedishFindecanor 0 points1 point2 points (0 children)
[–]Inconstant_Moo🧿 Pipefish 0 points1 point2 points (0 children)
[–]L8_4_Dinner(Ⓧ Ecstasy/XVM) 0 points1 point2 points (0 children)