What is the advantage of using abstract classes instead of traits?

Ralf picture Ralf · Jan 2, 2010 · Viewed 96.3k times · Source

What is the advantage of using an abstract class instead of a trait (apart from performance)? It seems like abstract classes can be replaced by traits in most cases.

Answer

Mushtaq Ahmed picture Mushtaq Ahmed · Jan 2, 2010

I can think of two differences

  1. Abstract classes can have constructor parameters as well as type parameters. Traits can have only type parameters. There was some discussion that in future even traits can have constructor parameters
  2. Abstract classes are fully interoperable with Java. You can call them from Java code without any wrappers. Traits are fully interoperable only if they do not contain any implementation code