Microsoft has released a preliminary version of the C# ("C Sharp") language
reference. It's at:
http://msdn.microsoft.com/vstudio/nextgen/technology/csharpintro.asp
The language reference is a .exe file but can be unpacked using 'unzip'
under Linux. The MS Word .doc file inside can be read by StarOffice - no
Microsoft products required :-)
C# is VERY similar to Java. Here's my summary of some of its interesting
features (as they differ from Java):
* The language is definitely targeted at static compilation and invoking
dynamically loaded classes must be done through a DLL mechanism --
there's no dynamic class loading as in Java.
* Cross-platform portability does not appear to be a goal.
* Interestingly, C# does *not* have its own runtime library - instead
they intend to bind everything to Win32 and COM libraries it seems
(or perhaps to the ".NET" runtime we have heard a bit about).
* Memory is garbage collected, but some code segments can "fix" memory
so it can't be moved by the GC, allowing you to use pointers on it.
Such code must be tagged with the "unsafe" keyword.
* Events are built into the language -- although this appears mainly to
be syntactic sugar. A class can declare fields with the keyword "event"
which means they represent event handlers. Using the "+=" and "-="
operators you can add or remove function pointers from the list of
event handlers associated with that class instance. It's not clear what
happens when an event handler is invoked.
* Versioning is part of the language - albeit in a primitive form. If
a new version of a base class declares a method which conflicts with
an old version of a subclass's method, then when the subclass is
recompiled the author must explicitly state whether the method
overrides or hides the base method.
* It uses 'cpp' style preprocessing
* Multidimensional arrays are supported
* Type-checking can be disabled for code blocks by labelling that block
with the 'unchecked' keyword
* Operator overloading is supported
* Supports Java-style exceptions with try ... catch ... finally
* Thread synchronization is supported with the 'lock' keyword (similar
to Java's 'synchronized')
* Supports single-inheritance and interfaces (just like Java)
* Virtual methods are supported but you have to use the 'virtual' and
'override' keywords - a bit ugly. Otherwise methods are treated as
non-virtual. My guess is that they are trying to avoid the problem
that Java has with nearly everything being a virtual method, and the
resulting performance issues. However, a static C# compiler should be
able to devirtualize everything since there's no dynamic class loading.
* 'struct' and 'enum' are supported (they seem unnecessary since 'class'
and 'interface' can be used)
* Special keywords allowing direct bindings to COM are supplied
Overall it's a nice language -- some of the syntax might be a bit
superfluous but otherwise no major problems with it. The language spec
is very preliminary and leaves out a lot of details, such as what threads
and locks actually do, what the memory model is, etc. As we all learned
from Java, these seemingly minor details end up being very important down
the line...
Matt Welsh, [EMAIL PROTECTED]
http://www.cs.berkeley.edu/~mdw
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]