D
D
Daniil Demidko2016-03-25 08:17:38
go
Daniil Demidko, 2016-03-25 08:17:38

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

7 answer(s)
S
Sergey, 2016-03-25
Protko @Fesor

So varName : TypeName instead of TypeName varName ?

Readability. "varName identifier containing TypeName" is much more logical to write in that order. Well, yes, this syntax is not new, far from new.

M
Maxim Moseychuk, 2016-03-25
@fshp

In general, the fashion for automatic type inference.
val valName = Value
var varName = Value
let valName = Value
auto varName = Value
etc.

S
Stanislav Makarov, 2016-03-31
@Nipheris

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)

D
Dmitry, 2016-03-25
@dnovikoff

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.

S
sulnedinfind, 2016-04-04
@sulnedinfind

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 .

S
spotifi, 2016-05-23
@spotifi

New?
Pascal. 46 years ago

P
pujonehoc, 2016-10-31
@pujonehoc

Eh... small.
Quite the contrary - what you call "new" is just the old one, from the late 60s. It is called Pascal, Algolovsky.
And what you call old appeared already in the 70s. It's called blue.
20th century, of course.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question