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

Meghan (she/her) - Nov 4 '17 - - Dev Community

I apologize in advance for this seeming like a rant, but there's one bit of syntax that I've been seeing a lot lately, and I can't seem to figure out why.

It's the : and -> syntax for type definitions. Consider the two snippets in TypeScript and Java.

function add(a: Number, b: Number): Number { ... }
Enter fullscreen mode Exit fullscreen mode
public static int add(int a, int b) { ... }
Enter fullscreen mode Exit fullscreen mode

I've noticed that the two above behaviors are very distinct between newer and "old" languages.

Java, C, C++, Objective-C, and C# define functions and variables the Java way.

Kotlin, Swift, Rust, TypeScript, and Go all put types on the Right.


Any ideas on why this shift has occurred? Which way do you prefer?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .