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.
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.
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.
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.
But does that mean everyone agrees with the rest?
func<Future<List<Option<String>>>> vs func[Future[List[Option[String]]]]
Which one is easier on your eyes?
>Which one is easier on your eyes?
i don't get the joke here. Or are you seriously implying that one is in someway better than the other? (i'm curious as i've been in the industry for more than two decades, so my eyes just filter that crap automatically anyway)
func<Future<List<Option<String>>>>
func[Future[List[Option[String]]]]func(Future(List(Option(String))))
Func (Future (List (Option String)))compare that to Java - landing and learning how to do it in 16th century somewhere like Spain - engaging in that sinful activity in the most vanilla and least sensual way with only purpose of procreation and only when. Thanks God progress can't be stopped :)
Parentheses for array and map access really bugged me until I grokked functors. They're really all doing the same thing, and the mathematical symmetry of using the same syntax for all of them is very pleasing.
Prepend and append are very different. And you do need to know, because for many scala collections one is O(N) and the other is O(1) [1], plus the importance of knowing order.
The difference between x :: y and x ::: y could mean List(List(1), 2, 3) versus List(1, 2, 3).
[1] http://docs.scala-lang.org/overviews/collections/performance...
You know the order, at least in idiomatic code; "x :+ y" x comes before y, "x +: y" x comes before y. (There's a misfeature where you can sometimes write x +: y as y +: x, but don't do that; use brackets if you need to (x +: y))
O(N) versus O(1) is sometimes important but it is a detail IMO; anyone who cared about the distinction would already be reading the code very carefully, it's precisely the sort of thing that a casual reader should be able to gloss over.
> The difference between x :: y and x ::: y could mean List(List(1), 2, 3) versus List(1, 2, 3).
Exactly. Which the type system will catch; if you're using wartremover that will be an immediate error (inferred type containing Any), if not then you'll see an error as soon as you try to actually use the result.
As far as :: versus :::, depending on type inference it can be a much more later error that is confusing. The type error messages are cryptic compared to what it could say. Worse, if you then take it and serialized it to JSON or something then you won't even get a compile error, so it may not be for a while that you even realize there's and error and that can be hard to trace down depending on your code.
I really am failing to see why you're defending this. It's like trying to defend programming without a debugger because you have printf. Why not make things clearer, always? Why can't error messages be easier to understand and more human friendly? Shouldn't that be the goal?
> As far as :: versus :::, depending on type inference it can be a much more later error that is confusing. The type error messages are cryptic compared to what it could say. Worse, if you then take it and serialized it to JSON or something then you won't even get a compile error
Which is why you should use wartremover and strict compile flags ( https://tpolecat.github.io/2014/04/11/scalac-flags.html ), so that won't happen. (It would be nice to make these things completely illegal by default, but not nice enough to break backward compatibility over)
> I really am failing to see why you're defending this. It's like trying to defend programming without a debugger because you have printf. Why not make things clearer, always? Why can't error messages be easier to understand and more human friendly? Shouldn't that be the goal?
I think people really underestimate the value of conciseness. The difference between a function or class that fits on one screen and one that doesn't is really huge. For commonly-used operations, I'd rather pay the upfront cost of learning the symbols and be able to read shorter code forever.
Of course there's a tradeoff, and I do think certain scala libraries lean too far to the symbolic side. Sometimes I like to think about a programming language that didn't allow any symbols (e.g. you'd write arithmetic like "(1 plus 2) times 3"). But the extra characters aren't free.
My perspective of dev'ing in scala since 2009 (and I love scala):
"Scala isn't that complicated, just takes some time to learn."
Scala is complicated. Like really potentially super complicated, and the compiler error messages can be hyper-cryptic. It was written by academics (versus "developers") and it shows.
New developers will end up asking someone else a basic language question about every 10 minutes, mostly because they don't even know what to google for.
I've been using it for years and I still have to lookup prepending versus appending to lists because I can't remember if it's x :+= y or x +:= y, let alone ::: versus :: versus ++ or ++=. Really? Why not #!:@## while we're at it?
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.
It doesn't help that there are 50 ways to do the same thing and the language is totally agnostic as to what you should do. It's almost like being an alien, coming to Earth, and trying to learn to have sex with humans from someone who is bi-sexual and into every fetish there is.
---
It would be really great if they could canonicalize the language in the way that python has, and once having done so further simplify their syntax so mere mortals can use it effectively. Programming is hard enough without the language being difficult, too.