3 ms·
I'm not convinced. The article found one situation where it makes more sense for the type to be on the right, but in most situations it makes more sense for the
by karlakush 8y ago
I'm not convinced. The article found one situation where it makes more sense for the type to be on the right, but in most situations it makes more sense for the type to be on the left. The reason being that it reads more naturally. It's the difference between saying "Golfer Tiger Woods adopted a cat" and "Tiger Woods, golfer, adopted a cat." Nobody speaks the latter.
- andolanra 8y ago'Naturally' is almost always a red herring in programming language design, because what is 'natural' tends to be 'whatever I was previously familiar with'. There are a lot of unstated assumptions here: · That what's best for natural language is also the best for programming languages. This is still a debated topic, but my personal feeling is that the two are different enough in both mechanism and purpose that what's good for one isn't necessarily good for the other. (For an illustrative example, look at how sigils worked in Perl 5, as they were explicitly designed to work like English demonstrative words like "that" or "these", and many programmers when first exposured to Perl feel like they were 'illogical'. They weren't, but in this case, mirroring a natural-language convention tended to obscure, rather than clarify, what was going on in the language!) · That phrase ordering in English is necessarily 'natural'. Lots of naturally-occurring spoken languages feature word order that differs tremendously from English! · That the English-language phrase you're describing as 'unnatural' is in fact unnatural: it's actually a common convention, especially when you're introducing a new fact to a conversation! "Tiger Woods, a famous golfer, adopted a cat."
- coldtea 8y ago>but in most situations it makes more sense for the type to be on the left. The reason being that it reads more naturally Not really. And the Tiger Woods example is a whole phrase with a verb and an noun (describing what he did to whom), so not representative of a type declaration (which is just just describing what thing something of a specific name is). So, it's more like: Tiger Woods: a golfer. vs: A golfer: Tiger Woods. Which of course is an argument for types on the right -- the first reads much better.
- Mirioron 8y agoIn my opinion the second reads better, because if you have multiple declarations (multiple rows) then they will all line up: Tiger Woods: a golfer. Jon Rahm: a golfer. Bryson DeChambeau: a golfer. vs A golfer: Tiger Woods. A golfer: Jon Rahm. A golfer: Bryson DeChambeau. This makes it easier to group up information when glancing at the code.
- makapuf 8y agoI don't understand the alignment argument. You can insert spaces (or your editor ) and align types on the right if needed.
- Mirioron 8y agoSo, will you go back and beautify code? When will you insert them? If there are 3 lines like that? 4? 5? It leaves so many questions that will have to be solved through "best practices" and everyone ends up doing it slightly differently.
- coldtea 8y agoThat's what TAB is for.
- int_19h 8y agoIt stops reading naturally as soon as you get composable type constructors, and people start actively using them. Even in English, once there's enough qualifiers, we move it to the right - e.g. "Tiger Woods, a famous but controversial golfer, adopted a cat".
- JadeNB 8y ago> "Tiger Woods, a famous but controversial golfer, adopted a cat". "Famous but controversial golfer Tiger Woods adopted a cat" might be awkward, but it's hard for me to buy an argument that it's either unnatural or even particularly hard to understand.