Do everything in Java…

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 6 07:45:23 PST 2014


On Fri, 2014-12-05 at 22:19 -0800, H. S. Teoh via Digitalmars-d wrote:
> 
[…]
> It's enterprise code. 'Nuff said. Even though "enterprise code" 
> sounds so glamorous, in reality it has a high likelihood of being a 
> rats' nest of spaghetti code with lasagna code layered on top, an 
> accumulation of patches upon hacks to bandaids over bugs resulting 
> from earlier pathces, with messy sauce leaking everywhere. I've seen 
> enough examples of actual "enterprise code" to know better than the 
> idealistic image they pretend to convey.

Most "enterprise software" is written by "average programmers", and to 
be honest, the average programmer really is not that good. Which means 
I am always surprised anything works, and never surprised at the crap I
see/use.

> But anyway, that's beside the point. :-P  Type erasure does have its 
> value -- for example, if you have a template class that represents a 
> linked-list or tree or something like that, most of the code 
> actually doesn't care about the type of the data at all. Code that 
> swaps pointers to link / unlink nodes, or code that rebalances a 
> tree, those pieces of code are mostly type-independent and can 
> operate generically on lists or trees containing any type. Under D's 
> template system, unless you manually factor it out, all of this code 
> will be instantiated over and over again, once for every data type 
> you might put into the list / tree. For non-trivial containers, the 
> template bloat can be quite horrendous. Type erasure allows you to 
> reuse a *single* copy of the code that handles every type of data 
> contained.

Type erasure is a total waste, reify the type parameter. If you 
actually want type erasure then just use Object as the type, job done. 
As the Java Platform API and Scala have proven you have to do a lot of 
work to manage type parameter under type erasure. With type 
reification, erasure is just one model of use.

> 
[…]
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



More information about the Digitalmars-d mailing list