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
It is really a great work and the way in which u r sharing the knowledge is excellent
ReplyDeleteTally Course in Tambaram
Tally Course in Anna Nagar
Tally Course in Velachery
Tally Course in T Nagar
Tally Course in Porur
Tally Course in OMR
Tally course in Chennai
ReplyDeleteAwesome Blog!!! Thanks for it, it is more useful for us.
IELTS Coaching in Tambaram
IELTS Coaching in anna nagar
IELTS Coaching in Velachery
IELTS Coaching in OMR
IELTS Coaching in Chennai
Thanks for providing wonderful information with us. Thank you so much.
ReplyDeleteGerman Coaching
Python Coaching
Software Testing Training in OMR
Excellent Blog to read. You have shared useful information. Thank you.
ReplyDeleteDOT NET Training in Chennai
.Net Coaching Centre in Chennai
When I was little, I always imagined and dreamed that I would be able to write a resume perfectly, but it didn’t work out, although I found this site https://paulbender.gumroad.com/p/what-did-you-forget-to-add-to-your-resume, it is about writing a resume and other services
ReplyDelete