Gopalan Suresh Raj's Web Cornucopia
An Oasis for the parched Enterprise Services Engineer/Developer

    Viewpoints-Microsoft Proposes a New Language C# (pronounced 'See Sharp')


    The Background

    On June 26 ‘00, Microsoft announced that it had submitted a new language called C# (pronounced ‘C Sharp’) to the Geneva-based standards committee “ECMA” (

    C# is intended to be packaged with the next version of Visual Studio (version 7) which will now be called Visual Studio.NET. According to Microsoft, C and VC++ provide the programmer with tremendous amount of fine-grained control and flexibility over their code while sacrificing ease of development. Visual Basic, raises productivity and sacrifices flexibility by omitting a mechanism for low-level code control. VB neither interoperated with pre-existing systems, nor did it always mesh well with current Web programming practices.

    Visual J++ occupies that middle-ground between Visual C++ and Visual Basic, offering both fine-grained control over low-level OS features, programming flexibility, and improving productivity multi-fold. It is the BEST environment to program in COM (Microsoft’s Component Object Model). The lawsuit with Sun has changed a lot of things. Microsoft seems to be contemplating on deprecating Visual J++!!

    C# from Microsoft may be a replacement for Visual J++ and an attempt to replace the void which will be left by its non-inclusion in VS.NET. According to Microsoft, C# would provide programmers with rapid development, combined with the power to access all the functionality of the underlying platform without sacrificing the power and control that have been the hallmark of C and C++. It will provide an environment that is completely in sync with emerging Web standards and one that provides easy integration with existing COM applications. Additionally, it would allow the ability to code at a low level if and when the need arises.

    The Reality

    In my opinion, C# will do extremely well within the Windows camp. Microsoft makes excellent tools for developers. C# will be integrated into Visual Studio.NET so it’s IDE will be top-notch. However, on other platforms, C# may just be another programming language. While C# is indeed being handed over for standardization, what is being standardized is nothing more than the core programming language. The true meat, the new Visual Studio COM libraries, are not described in the C# language specification. The COM library that ships with Visual Studio 7.0 is what is going to have all the punch in it. With this library you will be able to kick out killer Windows apps in VC++, C# and VB by using something called the “Common Language Subset” (CLS) interface. C# is a thin language core that sits somewhere between Visual C++ and Visual Basic. Visual J++ now has the spot but it is safe to assume that it is, in Java terms, being deprecated.

    There are some things about C# that sound neat:

    1. Automatic garbage collection
    2. Everything is an object (including the primitives! which means I can code 10.toString () !!!).
    3. Multi-dimensional array support (the [,] notation)
    4. Support for operator overloading
    5. structs are held and passed by value on the stack. These have the same properties as classes, except that they are accessed by value rather than by reference.
    6. C# allows XML data to be mapped directly into a struct data type, rather than a class, for greater efficiency.
    7. Supports conditional compilation
    8. true and false are both keyword and boolean literal
    9. a foreach statement
    10. “delegates” are a language feature.
    11. Will be better than VB
    12. With C#, every object is automatically a COM object
    13. C# supports methods with variable number of parameters.
    14. interfaces are part of the C# language. Interfaces are defined in C# as having methods and properties, and generating events; but there is a new twist in that C# interfaces can derive from more than one interface, which is not possible with MIDL. The actual interface implementation is in classes or structs which can implement one or more interfaces.

    Heated Good/Bad Debates Surround these features:

    1. It uses a preprocessor
    2. The preprocessor has no support for macros
    3. Compiles to platform native executable (without second step)
    4. Doesn’t compile to platform independent “.class”-like file
    5. Lots of attempts to remove ‘unnecessary’ brackets. Dangling else is solved by using the nearest corresponding if.
    6. There is no distinction between caught and uncaught exceptions
    7. goto
    8. switch statements follow the “no-fall-through” mechanism.
    9. switch statements can also be applied to strings (case-sensitive)
    10. Properties are supported, i.e., what looks like a variable assignment or access in client code can have get and set methods associated with it.
    11. The addition of all of the unsigned types doesn’t look like a win, but when you discover that the only implicit conversions are those which preserve information, it looks okay.
    12. You can turn on or off overflow checking for arithmetic operations in a code block. Not sure if this propagates to the methods that are called within that code block
    13. Inside a specially marked code block, developers are allowed to use pointers and traditional C/C++ features such as manually managed memory and pointer arithmetic (these blocks are qualified by the keyword unsafe)

    Some folks feel these things are sad:

    1. Far less dynamic than Java. (i.e. no dynamic class loading)
    2. Has C++ style namespaces
    3. break and continue can’t have a label.
    4. Event handlers are less general than anonymous classes and aren’t cleanly integrated.
    5. no covariant return types
    6. Provides large primitive data types and overflow checking constructs, but does not appear to convert to unbounded representations.
    7. The name resolution rules look too involved, although there are some interesting features with respect to interfaces.
    8. Methods are not virtual by default.
    9. C# doesn’t seem to have built in security
    10. No template-like mechanism available

    Other Features:

    1. Looks very similar to Java.
    2. The entry point into an application is the static Main() function of a class, and your code interacts with the operating system through instances of a standard class library.
    3. You can write your own classes, which supports single inheritance from other classes, but can be derived from several interfaces.
    4. The language supports value types (such as int and double) and reference types (e.g. instances of classes, arrays and strings). Just as with Java, C# reference types are ‘managed’ - in other words, the memory they consume is maintained by a garbage collector.
    5. It also allows you to define ‘indexers’, which are essentially like the C++ operator [], and it has C++-like destructors.
    6. All COM interfaces have to indicate the direction of data transfer and the meaning of all pointers that are passed. C# uses the parameter modifiers ref and out to indicate if a parameter is passed by reference, or is an ‘out’ parameter. However, since pointers do not exist in C# code, interface definitions are not concerned with them.
    7. C# has been designed with the ability to change the language through ‘attributes’.

    Far back in December 1997, Mary Kirtland wrote an article in the Microsoft Systems Journal (MSJ) called “The COM+ Programming Model Makes it Easy to Write Components in Any Language”. It makes me wonder if C# was what she was referring to then. Whatever be the case, I for one, and hordes of Java/COM developers like me, will miss Visual J++ for a long time to come…


    Author Bibliography

    Gopalan Suresh Raj is a Senior Analyst, Software Architect, and Developer with expertise in multi-tiered systems development, enterprise service architectures, and distributed computing. He is also an active author, including contributions to Professional JMS Programming, Wrox Press, 2001, Enterprise Java Computing-Applications and Architecture, Cambridge University Press, 1999, and The Awesome Power of JavaBeans, Manning Publications Co., 1998. He has submitted papers at international fora, and his work has been published in numerous technical journals. Visit him at his Web Cornucopia© site ( or mail him at