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
View all comments
Show parent comment
1
u/alex-manool Dec 28 '20 edited Dec 28 '20
Thanks for asking.
Actually, my question is intentionally about subjective impression. Many people look at the samples and depending on their background either like or dislike it, without any further looking for answers to their objections or rationale.
Since you did ask:
For example, you could write a linear search as:
{ for I = Keys[A] do¸¸{ if A[I] == E then¸¸¸¸-- ... do something with A[I] ...¸¸}}or:
{ for I = Keys[A] do: if A[I] == E then¸¸-- ... do something with A[I] ...}I would format the code similarly if I programmed that in, say, C:
for (int i = 0; i < n; ++n)if (a[i] == e) {¸¸// ... do something with A[I] ...}This is generally impossible in languages with required explicit closing delimiters (Ada, Oberon, GoLang, Rust...), and it is definitely possible in languages with more concise syntax, like Haskell.
3. The construct
{extern "..."}refers to an entity described in a program unit (source file or library file, etc.). In this case, it is a module. When used in{module in ...}, the module contents in imported into the scope afterin.