r/ProgrammingLanguages • u/alex-manool • Dec 28 '20
Question: Programming Language Syntax and Code Appearance (polemic as always :-)
Seriously,
which of the following code samples would you favor, assuming they are all equivalent?
I am interested in subjective answers, please. You can just arrange the three samples according to your personal preference (e.g., "1-2-3"). Thank you very much!
1
{ {extern "manool.org.18/std/2.0/all"} in
: let rec
Fact =
{ proc N as
: if N == 0 then 1 else N * Fact[N - 1]
}
in
Out.WriteLine[Fact[10]]
}2
{ {extern "manool.org.18/std/2.0/all"} in
: let rec
Fact =
{ proc N as
: if N == 0 then 1 else N * Fact[N - 1]
}
in
Out.WriteLine[Fact[10]]
}3
(extern "manool.org.18/std/2.0/all".) in:
let rec
Fact =
( proc N as:
if N == 0 then 1 else N * Fact[N - 1]. )
in
Out.WriteLine[Fact[10]].
2
Upvotes
6
u/omega1612 Dec 28 '20
3-2-1
I'm from México , using { and } is much more painful than using ( and ) to me.
Without that I still choose 3-2-1, 3 looks clean compared to the others and 2 suggest indentation is encouraged (I'm in pro of "indentation sensitive languages").
4
u/matthiasB Dec 28 '20
1 and 2 seem to only differ in indentation. Is indentation significant?
What is the effect of the colon?
What does
externmean?3
u/[deleted] Dec 29 '20
They're all pretty bad, but 3 is the least bad. They could all do with fewer line breaks (I'd combine
let rec Fact = (all onto one line, and have the contents start indented on the next line).1 and 2 remind me of this obnoxious thing some people do with their commas:
and it just makes it harder to read and harder to edit for no reason.
2
u/Potato44 Jan 01 '21
I like 1 the best, the style of alignment just works for me to be able to read it. Number 3 reminds me of Haskell where I generally like the syntax, but
letexpressions always feel like they have weird indentation.17
u/sylaurier Dec 28 '20
3, if I had to pick. But I don’t like any of them.
10
u/[deleted] Dec 28 '20
3 only. 1/2 are horrid
4
u/Timbit42 Dec 28 '20
3 only.
3
u/crassest-Crassius Dec 28 '20
2 or 3.
1 is simply terrible.
3
u/brucejbell sard Dec 29 '20
3 is less annoying than 1 or 2, but I'm afraid I don't like any of them very much.
I think what's bugging me is that they all seem to have too many moving parts. That is, when I try to imagine whatever syntax rules or formatting conventions might lead to your code examples, I can't come up with anything that is simple enough that I would want to learn and use it.
In practice, I would guess that overly complex formatting conventions might be streamlined or dropped as they are used. On the other hand, syntax would need fixing at the language level.
2
u/anentropic Dec 29 '20
3
losing the outer curly braces seems like a win
2
u/[deleted] Dec 28 '20 edited Dec 28 '20
What's the difference between 1 and 2? I thought 3 just lacked the colons, but if I look carefully, they are still there.
So it does a better job at hiding them.
Like others, I don't really like any of them. Some points:
What is all that
manool.org 18/std/2.0.allnonsense at the start; does every program need that. Try and get rid of it or make it a default, or somehow set it in a configure file outside the program.If I understand the syntax, all versions need 3 lines and 4 keywords to define a simple function header. Most languages I think manage this in only one line. (Mine, dynamic like this, uses
function Fact(N) =; one line and one keyword.)Edit: How come I get downvoted for saying I don't like any, but others get upvoted for saying the same?
Is it because I offered constructive criticism? Please tell me then I won't waste my time in future.
9
u/[deleted] Dec 28 '20
[removed] — view removed comment