Saturday, March 13, 2004

Re: C++ Generics

something like its more pure oops.

Right... same thing I've also heard. I know that it is a system similar to Java and .NET with unified type system, garbage collection and totally OOP. It also supports multiple inheritance, which neither Java nor C# does. Actually, they have an implementation of Eiffel that runs atop the CLR. Even though the CLR (CLS - Common Language Specification), doesn't support MI, they have managed to do it somehow.

Eiffel is quite old. It was created in the mid/late 80's. So it had all those capabilites quite a few years before Java came out. I guess maybe the reason it's not so popular is cause it doesn't have the C/C++ syntax.

"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."

That is actually also the definition of attributes. Attributes allow you to inject "custom" metadata. In your example, the attribute (Remote), is something that the Java guys have provided as part of the platform, but you can write your own stuff. When you run the code, the compiler will see the attributes/metadata and inject RPC code in for you. That's how it is declarative. You don't have to do anything.

so metadata in java is very different.

"What exactly is the metadata? Basically, it is binary information that describes every type and member defined in your code."

I don't think it will be too different. If you don't involve attributes in anyway, then the metadata just consists of type/member info. But if you declare attributes (like Remote), then that info will be added to the metadata.

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.

This is another reason why I think the metadata will not be too different between Java and .NET. Java also has Reflection capability. So the runtime has to have access to all the type/member info. The slight differences will probably be with Generics data. Apparently you can't tell what type a generic class was instantiated with in Java Generics.

i agree that generics and metadata seem more fake/pseudo in java, but they must have had some tough decisions to make.

I agree. Those guys are Einstien's. I'm sure they have proper reasons for their choice. Software is all about tradeoffs. I was just stating my opinion.

No comments: