Why Syntax is More Important Than Semantics
one common idiotic thought among elite coders is: “syntax is not important, semantics is more important”
it's something that's seemingly true. But if you look deeper, lots of problems.
let me give some concrete examples
- Python's indentation syntax, reduces Functional Programing construct, encourages procedural and Object Oriented Programing constructs.
- If lisp isn't nested paren, lisp macro would not have happened.
- If APL uses C syntax, it wouldn't develop the concept of array programing.
syntax here, played a crucial role. Not just in a language, but leads the direction of thought, into entire new branch of ideas.
syntax is so important it changes programer's mind, changes your behavior, changes how you write programs.
if a for loop syntax makes you type 100 characters, and if while loop is just 10 chars, everyone would write just while loop.
that's how important syntax is. It changes programer's behavior.
• if programing languages uses roman numerals instead of decimal numbering notation with arabic numerals. What do you think are the consequences?
• formal languages, which is the foundation of theoretical comp sci, is all about syntax alone definition.
• if one look at history of math notations, it's well known that, syntax/notations, leads the way to ideas and direction in a critical way. e.g. arabic number system vs Roman Numerals. symbolic algebra instead of english words. Matrix notation. Complex number notation.
here, you see, syntax/notation, leads the way, to even to suggest new theories and developed into entire new branch of math. While, the semantics, kinda remains same.
let's say, we are familiar in langs, the plus operator:
but suppose, in your lang, it's written as:
1 plus 1
where the keyword
plus is the operator.
in, or python
[see Python Syntax Soup: x in y]
now, suppose the assignment operator
=. Let's say in your fav lang it's written as:
where no space allowed between them.
this is a trivial example. But, you can see it's a major problem.
Now, let's say, your lang syntax is this:
assign 3 to x
that, is a lang syntax actually very close to AppleScript and some others who tried to use English.
if your lang's syntax is like that, let's say all our languages syntax are like that. To what degree, it hampers or progress computer science or the semantic part of language design?
the typical idiots who espouse that “semantic is more important than syntax” is that, they think of it this way: 「1 + 1」 , and 「1 plusssssss 1」, are really the same. They are thinking, the important thing is that maybe the lang should also have minus, such as 1 minusssss 1, so that here the semantics is richer. Therefore, they say, semantic is more important.
600 years ago, we don't have symbolic equations like today's x^2 + 3 = 5
we describe the problem, in words, often, with a story
like thus: john has a rice field, that's a square, each side is 2 unit. and, the area plus three, equals five. What's the side of John's field?
now, this is the history of math notation, am telling.
you see, so math back then, even the semantic is same as x^2 + 3 = 5, but, because we don't have that notation yet, it is extremely difficult to solve math problems, because we do not even clearly see the problem. We have to think a lot.
eventually, after 1k years later, we begin to write, x^2 + 3 = 5, and , it gave way to the branch of math we call modern algebra, or used to be known as symbolic algebra, or even before, called theory of equations.
where we have concepts like group, ring, field.
am talking about the history of math.
here's a book that spreads the bad idea that semantics is more important.
2020-07-12 this post began as argument with jagen on xahlee discord.