Backwards compatibility is an important asset (for Java), but the downside of type erasure is (among others) that in case of primitive types autoboxing is used extensively which causes developers to favor non-generic classes over generic ones (for performance reasons; autoboxing is quite slow).
Now, Scala 2.8 has a solution for this, and that's a new annotation called @specialized.
class MyCollection [@specialized A]{ def simplyReturn(x: A): A = { x } }
What it does is it causes the compiler to generate specialized versions for primitives, so that autoboxing does not have to occur, which is faster. I should investigate the performance difference in future and share the results!
You can also specify which primitive classes should be specialized.
class MyCollection [@specialized("Int") A]{ def simplyReturn(x: A): A = { x } }
Read more about it in the official Scala document (PDF).
Scala 2.8 Showcase
- Scala 2.8 Showcase - Collections
- Scala 2.8 Showcase - Arrays
- Scala 2.8 Showcase - Type Specialization
Great Article android based projects
ReplyDeleteJava Training in Chennai
Project Center in Chennai
Java Training in Chennai
projects for cse
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Useful Information..!!! Best blog with effective information’s..!!
ReplyDeleteweb designing training in chennai
PHP Course in Chennai
Best Spoken English Classes in Chennai
German Language Course in Chennai
Salesforce Course in Chennai
IELTS Coaching centre in Chennai