View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Discussion 1 - Ryan Nigro

We'll review these questions regarding Java and C++ from the perspective of the attached paper.
This paper looks specifically at the implementations of generics in Java and C++. In Java JDK 1.5, Generics is accomplished through implementing interfaces. In C++, it is done by parametric polymorphism through templates.

Ghosh compares generics in Java and C++ through three models: translation, type, and security. The translation model looks at the differences in how code is translated downstream. The type model explores type inference, type aliasing, and associated types. The security model highlites any security loopholes.

Translation Model


C++ doesn't do static type checking on generic code; therefore, C++ loses no type information at runtime but can have misleading error messages. Java relies on type erasure.

Type Model


Subtyping models concepts in Java, but Java has no type aliasing or associated types. C++ uses both: type aliasing through typedef and associated types through traits.

Security Model


Java has a security loophole: it doesn't dynamically track collection types. C++ doesn't have this loophole.

Conclusions


Java Generics guarantees complete backward compatability, but the lack of run-time information and checking has created a need for restrictive programming. C++ has no loss of run-time information, but it does have a slow compilation process that leads to misleading error messages and bloated code.

Comparative Parallel


Luis F Cruz looks at how the variety of programming languages helps programmers do their job more effectively. In generics, Java offers a sloppy but quick implementation, whereas C++ uses a more involved and safer one. Each approach may be appropriate in different applications.

References


Generics in Java and C++ - A Comparative Model
Luis F Cruz on Variety in Programming Languages

Link to this Page