|
Boost Users : |
Subject: Re: [Boost-users] [boost] [type_erasure] Review ends today July 27, 2012
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-08-01 08:06:18
on Fri Jul 27 2012, Hossein Haeri <powerprogman-AT-yahoo.com> wrote:
> Whilst, with my particular situation explained above, I only read the
> Boost list to keep up with the news, your post stroke me for a
> particular reason: Type Erasure has a specific meaning in the Java
> world that has several times bit me hard over my Scala
> development. (See my threads on the topic to see that I publicly
> announce that I believe "type erasure is by far the ugliest dwarf I
> have ever witnessed mankind creating in a programming language."
>
> Having said that, I opened your post thinking what a mistake it would
> be to bring nasty Java stuff to C++. To my big surprise, though, your
> stuff is nowhere close to what I understand is known in the JVM world
> as Type Erasure. So, I strongly recommend, as my first comment, to
> think about renaming the library because...
>
>> The Boost.TypeErasure library solves these problems allowing us to
>> mirror static generic programming at runtime.
>
> ... rather than this, JVM Type Erasure is about knowingly choosing to
> be completely oblivious against types from the early compilation
> stages onwards. Whereas your stuff simply postpones certain typing
> decisions. For that reason, you might for example want to call your
> library "Staged Typing" or "Deferred Typing". (Both of these are
> established research topics in programming languages. Please note that
> you're not doing "Gentle Typing" or "Gradual Typing".)
>
> On the other hand, JVM type erasure doesn't solve any of the problems
> your stuff does. As a matter of fact, in many occasions, it even makes
> the situation worse. For similar facilities to that of yours, your
> might want to take a look into the Scala Macro system.
Actually, from my understanding of Java type erasure, it's doing exactly
the same things. IIUC the idea is to implement a generic function with
a single piece of compiled code by erasing specifics of the type being
operated on inside the implementation of that function.
The problems IIUC with Java are twofold:
1. Type erasure is Java's only answer for genericity, which is bad for
performance.
2. Java does all its type erasure one object at a time, which leads to
the dreaded binary method problem.
Steven's library supports something a lot more like Haskell's
implementation of generics.
-- Dave Abrahams BoostPro Computing Software Development Training http://www.boostpro.com Clang/LLVM/EDG Compilers C++ Boost
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net