Friday, March 12, 2004

Re: C++ Generics

have you guys heard of a language called eiffel?

i have heard very little stuff on eiffel. something like its more pure oops. so i wanted to know if any of you knew any features of the language vs java/c++/c#.

So I was saying, they should have changed the bytecode and emited some more metadata to handle generics. This way, those casts would be eliminated. The metadata would hold the generic class template as well as info about the type the class was instantiated with at runtime.

i guess you are speaking from c# experiece.i cannot confirm but things in java are very different. take this definition of metadata from joshua bloch, a lead architect in java.

"Metadata - Lets you avoid writing boilerplate code, by enabling tools to generate it from annotations in the source code. This leads to a "declarative" programming style where the programmer says what should be done and tools emit the code to do it."

and an example..
import javax.xml.rpc.*;

public class CoffeeOrder {
@Remote public Coffee [] getPriceList() {
@Remote public String orderCoffee(String name, int quantity) {

so metadata in java is very different. the above example simply exposes the method getPriceList() as a remote method. it simply auto-generates byte-code compared to if you would actually expose the method as a remote method. unlike what mohn had posted on metadata in c# ages ago
"What exactly is the metadata? Basically, it is binary information that describes every type and member defined in your code."
metadata in java is just the compiler doing stuff for you. the basic structure of the class file, jvm remains same. i agree that generics and metadata seem more fake/pseudo in java, but they must have had some tough decisions to make.

also another question that just popped into my head is on metadata in c#. can't you do most of the stuff simply by using reflections? there must be more advantages.

No comments: