DEV Community

Discussion on: What ever happened to putting the object type on the left?

Collapse
 
bgadrian profile image
Adrian B.G. • Edited

I think it has more sense like "here is X, a type Y variable" but anywayI think it all started with Fortran (type on the left) but there were exceptions like Basic

ASTRING$ = "Hello World"
ANUMBER% = 10

There are also "neutral" ones, in which you do not have to specify the type (including Go), Lips or everything is a word (BCPL).

To answer your question I think this stackoverflow answer got it right

All of the languages you mentioned support type inference, which means the type is an optional part of the declaration in those languages because they're smart enough to fill it in themselves when you provide an initialization expression that has an easily-determined type.

That matters because putting the optional parts of an expression farther to the right reduces parsing ambiguity, and increases consistency between the expressions that do use that part and the ones that don't.

And New vs Old is relative to our age :))

Having the type after the identifier is not a new phenomenon, it goes back to at least Pascal (designed 1968โ€“1969, released in 1970), but actually was used in mathematical type theory, which starts ~1902. It was also used in ML (1973), CLU (1974), Hope (1970s), Modula-2 (1977โ€“1985), Ada (1980), Miranda (1985), Caml (1985), Eiffel (1985), Oberon (1986), Modula-3 (1986โ€“1988), and Haskell (1989).

Collapse
 
bertilmuth profile image
Bertil Muth

Very good. Just as a side note, the type in UML goes to the right as well, I guess for similar reasons.

Collapse
 
jeffreymfarley profile image
Jeff Farley

I came in here to add this