Answer the question
In order to leave comments, you need to log in
Why did the fashion for a new syntax appear?
Why have new languages moved away from the established variable declaration syntax?
So varName : TypeName instead of TypeName varName ?
Answer the question
In order to leave comments, you need to log in
So varName : TypeName instead of TypeName varName ?
In general, the fashion for automatic type inference.
val valName = Value
var varName = Value
let valName = Value
auto varName = Value
etc.
Indeed, it's not that new. Pascal has already been remembered, so I’ll add more: https://en.wikipedia.org/wiki/Standard_ML
Variable
syntax : type has become more popular because languages NOT from the C family (C/C++/C#/Java) have become more popular, in which it differs not only semantics, but also syntax.
By the way, I'm not even sure which syntax came first)
Here's an example from the Go documentation:
blog.golang.org/gos-declaration-syntax
They have two main reasons:
1. Readability
Not "Type T variable A", but "Variable A type T"
2. Convenient description of function
pointers "int (*T)(int)" versus new "T func(int)int"
Personally, for my taste, this has nothing to do with real programming problems, and 90% of the explanation why "it's better" is sucked from the finger. In what order - without a difference.
The only reasonable argument is that some aspects of code parsing by the compiler can be made easier by this approach.
This is a well-established mathematical notation from type theory. At least 60 years older than the "established" Xi. There is more on this in the English wiki .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question