4 ms·
It's crazy that in these slides he says "I wanted a hipster language" -- most languages use [] for arrays so I used (). WHY!!!!? Just to be different?
by frowaway001 12y ago
It's crazy that in these slides he says "I wanted a
hipster language" -- most languages use [] for arrays so I
used (). WHY!!!!? Just to be different? No actual real
advantage? That's a terrible reason and a great way to
make it hard for new people to adopt your language.
You might not get it, but the slide makes fun of knee-jerk reactions like those shown in your comment.
Scala does things for a good reason. Not caring to figure out the reason doesn't mean the language is wrong.
- azinman2 12y agoCare to point out the reason then? Not sure why you assumed I don't care to find out, especially given I've stated that I've been using Scala since 2009 and love the language.
- ArturSoler 12y agoIt's () instead of [] because it's a regular function call. It's related to the scalability thing that Odersky also mentions (as much functionality in libraries as possible, rather than in the language).
- azth 12y agoI'm assuming it's to unify the `apply()` operation between collections (maps, sequences, arrays, etc). The collection library derives from a trait hierarchy, and an array is one of these collection types.
- acjohnson55 12y agoNot just between collections, but functions as a whole. An indexed sequenced is essentially a mapping (read: function) from the integers to whatever the element type is. Scala makes that explicit, rather than creating another mapping operator, as though they failed to notice the symmetry. I would characterize this sort of thinking as one of the core principles of the language design. The designers search for underlying generality and bring it to the surface of the language. This can be a little frustrating at times, since humans aren't necessarily geared toward abstraction. But investment in understanding the abstractions pays off again and again.
- sixbrx 12y agoThe square brackets are used already for type parameters on types. I do think they are easier to read than angle brackets are, for some reason. There was some discussion on this point in the Rust community as well recently where it was noted several people found square brackets easier to read and wanted to emulate Scala here (and another group wanting emulate D, using () for both!). Another reason is that an IndexedSeq is really itself a function (extends Function1), so the parens are literally function application, not some specially interpreted syntax for indexing.
- shogun21 12y agoWhen it comes to arrays, they use () to emphasize the fact that this is a function- arr(1) is arr.apply(1)- instead of directly accessing an element like other languages. Scala makes sense and has a logic behind all its reasons, but sometimes it seems to go against convention for the sake of its own philosophy.
- azinman2 12y agoI love how this is the only thing that people seemed to comment on. And I appreciate everyone's suggestion of unifying function calls being a good thing plus other aesthetics. But does that mean everyone agrees with the rest?