News for hackers. Stuff that matters.
Re:Scala Traits by leothekim on Wednesday June 26, 2013 @09:19AM (#5945786)
Artima wrote an article describing how the use of traits (along with other scala features) can contribute to increased compile times.[1]

FTFA: "... the compile time cost of mixing in a trait compared to extending a superclass likely exists because the compiler must insert forwarding methods for all the methods declared in the trait into the body of the subclass when mixing in, but when extending a superclass it does not. Instead, the subclass simply inherits the superclass implementations of those methods. We did observe that the larger the number of methods to be mixed in the more the compile time was increased."

[1] http://www.artima.com/articles/compile_time.html

Re:Scala Traits by gtani on Wednesday June 26, 2013 @11:42AM (#5946749)
Good article, (need to work on colorizing REPL output tho)

Here's a Cake Pattern and type class followups:

Slides

https://speakerdeck.com/marakana/ne-scala-2012-the-typeclass...

https://dl.dropbox.com/u/1679797/NE%20Scala/Bakery%20from%20...

videos of above: http://marakana.com/s/post/1397/2013_northeast_scala_symposi...

[deleted]
Re:Scala Traits by x3ro on Wednesday June 26, 2013 @08:34AM (#5945584)
What did you expect it to print, and why, if I may ask?
Re:Scala Traits by lmm on Wednesday June 26, 2013 @08:38AM (#5945593)
I expected it to print "B", because D is visually closer to B so it would make more sense to me for it to be biased in that direction. (I was quite conscious that I was guessing, and wouldn't have written code depending on my assumption without testing it first)
Re:Scala Traits by harlock81 on Wednesday June 26, 2013 @08:42AM (#5945606)
The behavior you get is because of class linearization: this article explains it quite clearly: https://code.google.com/p/scala-discovery/wiki/Linearization
Re:Scala Traits by x3ro on Wednesday June 26, 2013 @08:43AM (#5945613)
I'm not quite sure what you mean by "visually" closer. Do you mean the actual distance in characters between "class D" and "with B"?

Intuitively, I expected the compiler to first add the "B" trait, and then the "C" trait, which overwrites what was previously added by the "B" trait. But this seems to be much more subjective that I would've thought, apparently ;)

Re:Scala Traits by lmm on Wednesday June 26, 2013 @09:48AM (#5945958)
>Do you mean the actual distance in characters between "class D" and "with B"?

Yes, exactly that.