News for hackers. Stuff that matters.
Re:Java.next() - Scala: The Revenge of the Static Typing by rit on Wednesday May 11, 2011 @01:38PM (#2537346)
While this is a statement in some ways of preference it is a reasonable comment; not sure why it's getting downvoted.

However, can you clarify why you would argue for type classes over duck/structural typing? You indicate that 'type classes are the way to go' but don't explain why.

Scala of course does have a form of Type Classes and while they tend to be what I reach for more often than Structural Types in Scala, it doesn't obviate Structural Types completely and I'd be interested in analysis of the diffs.

Re:Java.next() - Scala: The Revenge of the Static Typing by kscaldef on Wednesday May 11, 2011 @03:41PM (#2538055)
With dynamic duck typing you just have to hope the object actually quacks. With type classes, the compiler proves it quacks.
Re:Java.next() - Scala: The Revenge of the Static Typing by dan00 on Thursday May 12, 2011 @04:30AM (#2539827)
"However, can you clarify why you would argue for type classes over duck/structural typing? You indicate that 'type classes are the way to go' but don't explain why."

Like kscaldef said, you know at compiletime if something can quack, and the overhead for doing this is quite small.

Haskell: instance Quacker MySpecialDuck where quack = "qqquuuuuuaaaaaakkkkk"

"Scala of course does have a form of Type Classes and while they tend to be what I reach for more often than Structural Types in Scala, it doesn't obviate Structural Types completely and I'd be interested in analysis of the diffs."

In which cases do you need duck typing? Adding dynamically a method to a class?