Friday, July 02, 2004

Return of the template

The good old templates are now available both in Java and C# by the name Generics. C++ programmers have long used templates to provide compile time safety for data structures which are collections of objects. Templates or Generics, as they will be now known, save the burden of casting the object back to the appropriate type for the programmer and avoid the penalty of runtime type checking for the virtual machine.

There is a brief introduction of the Generics implementation in the new features in the J2SE 1.5 release, code named Tiger on java.sun.com. This tutorial offers a more complete explanation of the Generics feature. With features like boxing, metadata, foreach loop and typesafe enumerations, it is now even more closer to C#.

Microsoft has announced the beta release of Visual Studio 2005, code named Whidbey which implements the C# 2.0 specification. This document on C# 2.0 features on informit.com explains the Generics implementation. C# 2.0 now also provides a template like syntax for implementing nullable types which has been a requirement for long and even has an open source project dedicated to implementing nullable types.

0 Comments:

Post a Comment

<< Home