4 ms·
Personally, I love Java syntax, or did before Java 8. It's still better than Kotlin though. At least it gets the type and name in the correct order.
by irunmyownemail 2y ago
Personally, I love Java syntax, or did before Java 8. It's still better than Kotlin though. At least it gets the type and name in the correct order.
- int_19h 2y agoWhat makes it the "correct" order?
- RedComet 2y agoIt is probably more that Kotlin's order breaks with the most common ordering, and at the cost of more characters. Not to mention the needless variation that has come along with it (e.g. : vs ->)
- wiseowise 2y agoArrow is a lambda, just like in Java.
- RedComet 2y agoI'm referring to the burden when changing languages. Swift and Rust use -> for the return type.
- int_19h 2y agoAnd C++, C#, and JS use arrow for lambdas, so there's precedent for both.
- RedComet 2y agoMy comment had nothing to do with lambdas. The point is that Kotlin uses fun and : instead of fn/func and ->, which is a needless and tedious break with other modern languages using Pascal-style function declaration. Using val instead of let is similarly off-putting.
- int_19h 2y agoHaving the identifier first makes it easier to parse unambiguously; the C syntax has been historically criticized for not being context-free because of stuff like "A * B" being impossible to parse correctly without knowing whether A is a type or not. While Java doesn't have the equivalent problem, Kotlin keeps its options open wrt future syntactic extensions for type names. Identifier-first can also be a lot more readable when gnarly (and thus lengthy) types are involved, since you don't have to scan the line to find it. It makes for neater-looking code with multiple declarations one after another, too. As far as commonality, both syntaxes are very common, and have been so historically as well (roughly speaking, C vs Pascal syntax families). It should also be noted that most new languages go for identifier-first, so if anything, it's more future-proof in this sense.
- RedComet 2y agoIt is common in term of frequency of new languages using it, perhaps, but not otherwise. And again, the point is that Kotlin brings along extra characters AND variation. What's next, `fnctn myFunction(x : Int)~ Int { /* code */ }`? Why? Just to be quirky? To avoid some hypothetical lawsuit?
- int_19h 2y agoThere are plenty of old languages using it. Pascal/Delphi, Ada etc. That's where the current crop of languages got that syntax from, it's not like it came out of the blue all of a sudden. And I already explained the reasoning. No, it's not to avoid the lawsuit, it's because many people genuinely find it more readable for various reasons. Which is why it keeps showing up in all kinds of languages that are otherwise wildly different syntactically.
- RedComet 2y agoYes, there are older languages using Pascal style declaration, but any of C,C++,Java dwarf it in terms of popularity and general exposure (thus my use of the term "common"). And again, in the latter part I'm talking about Kotlin's use of 'fun' and ':'.