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?

  • This notation goes back at least to 1902. You have a strange definition of "new trend". Oct 7, 2018 at 14:31

1 Answer 1


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.

  • With the old style, the name is always on the right and type is on the left, making it easier to separate the two parts ;)
    – Fabio
    Oct 5, 2018 at 19:30
  • @Fabio. Nope. Take a look at arrays of pointers, or, worse, arrays of function pointers. Oct 5, 2018 at 19:40
  • 4
    I think Fabio is saying your point is better made when more then name and type are involved. When it's just two words it's a coin flip. Oct 5, 2018 at 20:10
  • @candied_orange: The problem is that the cases where you NEED to be able to see the name quickly and easily are almost never the easy ones, that involve JUST a name and a typename. Oct 8, 2018 at 14:56
  • 1
    @JohnR.Strohm we're not saying you're wrong. We're saying with an edit you could make the point clearer. More comments aren't going to help. Oct 8, 2018 at 15:37