Researcher question – what's the point of semicolons and curly braces?
Joe Duarte via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 2 20:48:09 PDT 2016
Hi all,
I'm a social scientist and I'm preparing some studies on the
effects of programming language syntax on learning, motivation to
pursue programming, as well as any disproportionate effects that
PL syntax has on the appeal of programming to women (more on the
latter in a separate post).
So I want to get a better idea of the rationale for various
syntactical design decisions, and I'm going to ask you the same
question I'll ask the Rust community:
Why are curly braces and semicolons necessary? What information
do they carry that a compiler could not otherwise reliably obtain?
Here's an example from the D Overview page:
class Foo
{
int foo(Bar c) { return c.bar; }
}
class Bar
{
int bar() { return 3; }
}
Okay, if we remove the curly braces and semicolons, we have:
class Foo
int foo(Bar c) return c.bar
class Bar
int bar() return 3
Would it be difficult to compile the clean version? Would there
be issues with the design of the lexer/parser? I assume the
compiler would recognize keywords like return (and a clean syntax
could drive different rules for what statements and expressions
could appear on the same line and so forth).
In reality, a compiler would see the above with line ending
characters terminating every line (e.g. U+000A), so it would be
as line-aware as a human. I've never built lexers or parsers,
much less compilers, so maybe I'm missing a major implementation
hurdle. I'm just thinking that Facebook has built software that
recognizes my face in other people's pictures, so it seems like
building software that understands structured text would be a
solved problem. It puzzles me to see so much apparent punctuation
noise in a 21st-century language (and, to be fair, Rust puzzles
me for the same reasons).
JD
More information about the Digitalmars-d
mailing list