0

Modern languages like Rust, Kotlin, and TypeScript, define their syntax to declare variables as:

myVariableName: VariableType

As opposed to the C-like approach not so old languages like JavaScript, C#, and Java take:

VariableType myVariableName

My question is, why the new trend? What was wrong with the old syntax and what makes the new syntax better?

1 Answers1

2

It isn't a new trend.

To the best of my knowledge, this convention first appeared in Nicklaus Wirth's PASCAL language, which was designed (according to Wikipedia) in 1968-1969 and first published in 1970.

The other form dates back to at least ALGOL60, from 1960.

The issue is that, when the language follows C declaration syntax, the syntax gets muddy if the declaration is at all complicated: the name of the entity being declared gets buried somewhere in the middle. With the PASCAL style, the name is always on the left of the colon and the type is on the right, making it easier to separate the two parts.