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 { ... }
public static int add(int a, int b) { ... }
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?