<2004 December>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

On this page...

Search

Links

Member of...


ASP Insiders

MVP Visual Developer ASP/ASP.NET

Enter CodeZone

Blog Categories

Microsoft

Blogroll

Deutsche Resourcen

Management

Sign In
 

#  Friday, 10 December 2004

I’m one of those next-cool-thing addicts that can’t resist to play with the latest most unstable Whidbey CTP coming out of Redmond. One of the red-hot things is generics that will be included with C#^H^H the CLR v2.0. This intentional blunder is the central point of this editorial - clearing up misconceptions about generics.

When reading postings or talking to fellow early .NET 2.0 adopters you come to categorize those into the following distinct groups:

  • The C++ developers
  • The Non-C#, Non-VB.NET, Non-Managed C++ developer
  • The Java developer (yes, I know…)
  • Generics, huh?

Let’s start out with the die-hard C++ programmer, a guy who really is in love with the templating system in C++ (when referring to C++ I really mean the unmanaged C++ world). This is the most vocal among the four groups, and they’ll be very forthcoming in telling you how much better C++ templates are than generics in C#. I hate to break the news to them, but generics are intentionally different: firstly, and most importantly, C++ templates are compile time only, whereas generics are compile as well as runtime. Anders Hejlsberg did a great job of explaining that in [1], and the C# team has a FAQ online on this topic too [2].

Secondly, the being different goal also extends to simplicity of use. Do you remember yourself screaming bloody murder when C# came along with single inheritance? Right. How many people did and do care in real life? See. Same here in generics-land: certain power has been stripped from you because it would tip the balance from easy to use to intimidating and overly complicated. That’s why constraints don’t cover the whole complexity spectrum and don’t allow operator constraining and the like, such as non-default constructor constraints. Oh, you can fake operator constraints if you really, really care with the approach detailed in [1] and [3], but admittedly this won’t solve the problems for intrinsic types.

Speaking of operator constraints constraints (couldn’t resist), a general misconception in the C++ camp is that everything they are used to should be just as dangerous – pardon me, powerful – in other implementations. C++ templates allow you to do what you damn well please, but generics don’t – that very type checking is the one thing to single out that rid us of AVs, remember?

The Non-C#, Non-VB.NET, Non-Managed C++ developer. So who are they? Try one of 30+ (don’t quote me on the actual figure) other programming languages that follow the CLS (Common Language Specification) and produce code that can run on the CLR. It is rather similar if not exactly the same as with Edit and Continue support – “me too!” is heard all around the globe. So, do they get generics? Depends. Because of the many programming languages that exist for .NET, Microsoft decided to not put generics in the CLS. So it is entirely up to the language vendor in 2.0 to support generics or not.

Has the C#/VB.NET developer any beef with that? You bet. If you write a framework that has to be used in other programming languages, that framework has to be CLS compliant (“should be” is too soft in my view). And this means you cannot use generics on the public interfaces if you want to mark your assembly with the CLSCompliant attribute. The Non-CLS compliance of generics is pointed out in [4] and [5], with hints that generics will find their way into the Common Language Specification in the Orcas / Longhorn timeframe.

The Java developer. Now, how do they fit into the picture of the early adopter of .NET 2.0? I’m sure one thing .NET developers will hear a lot is that “Java had generics long before .NET.” Not so fast, Scotty. Just like there are differences between C++ templates and .NET generics, there are differences between Java generics and their counterparts in .NET. Once again, Anders Hejlsberg did a great job in [1] of explaining what is different: for one, .NET generics are actually typed, which means no boxing for value types (a very good thing!). Secondly, .NET generics are runtime too, not just compile time – you can reflect on generics in .NET, you can’t do that in Java. The lowdown: generics in Java spare you the task of casting, but that’s about it.

Finally, the group “Generics, huh?” Those are developers who for example still have the misconception that generics are a C#-only feature, like many programmers using 1.0 initially thought that features offered by the CLR were actually C# features. Let’s chalk that one up to miscommunication, but a repeated one.

You know that generics (will) exist, but have no clear idea what they are intended to be used for? I’d like to quote Anders Hejlsberg: “Generics is essentially the ability to have type parameters on your type.”[1] D’accord? Really simple but really powerful.

You know what generics are (if not, please see the previous paragraph), but have no idea what to use them for? If you are like one of my friends “I’m not in the business of writing frameworks, and the .NET framework already has generic collections, so what use are generics to me?”, rest assured that there are plenty of other non-class uses: generic methods (data access, anyone?) and generic delegates (in an instant makes callbacks that much more fun). Did you know about those two generics use cases?

To conclude this editorial, I’d like to firmly state that generics are positioned somewhere between being  “just a fancy way of replacing typed collections” and the all-too-powerful for shooting yourself in the foot C++ templates. Well designed, tightly integrated in the CLR, the right dose of power – with one problem: too many different views of what generics are, what they are intended for, and what they can be used for. I for one am confident that they will be useful to programmers – yes, useful –  nothing more, nothing less.

[1] Generics in C#, Java, and C++
http://www.artima.com/intv/generics.html

[2] How do C# generics compare to C++ templates?
http://blogs.msdn.com/csharpfaq/archive/2004/03/12/88913.aspx

[3] Generics Algorithms
http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx

[4] Dan Fernandez's Blog - Quick information on Generics
http://blogs.msdn.com/danielfe/archive/2004/06/21/161962.aspx

[5] Q&A with VJ# and C# Team on Generics
http://www.thedatafarm.com/blog/CommentView.aspx?guid=a71779f2-7a6a-4df1-81d4-3ccaa2f18cff

[6] An introduction to Generics
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/csharp_generics.asp

Bootnote: This blog entry originallly was intended to be an editoral, however, an editorial is an opinion piece, and the publisher wanted a different opinion. This is why the text is now in my blog where you can read (and flame) it freely.

Categories: .NET | 2 Ohhhh | C# | this
Friday, 10 December 2004 10:22:26 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 



#  Thursday, 09 December 2004

All you need is BetaPlayer (capable of MPEG, DivX and many other formats - best of it, this player is GPLed) and those free xmas videos.

Thursday, 09 December 2004 10:56:13 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 

As for the blogs, these are the Windows Mobile Team Blog and Jono's Blog. On the former I found the Xrossone Mobile GDI+ library (see the features to get an idea what this shared-source licensed library can do for you), on the latter the entry Resources for Packaging and Deploying .NET Compact Framework-based applications struck me as really useful.

Thursday, 09 December 2004 10:41:39 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 



#  Wednesday, 08 December 2004

Busy day in open source land for me - after releasing a .NET USB library earlier today, we now finally were able to release the book "Dissecting a C# Application - Inside SharpDevelop" as a free ebook! More than 500 pages of information (architecture and code) on a real-world application written entirely in C#.

The book was originally published (January 2003) by Wrox Press, which went under shortly after the book's release. With all three original authors (Christian Holm, Mike Krüger, Bernhard Spuida) agreeing, I worked with Gary Cornell from Apress to release the book to the general public for free - and I am more than happy to announce this event today! Thanks Gary, you have been really, really forthcoming - and wow, we made it happen before Christmas.

Categories: Books | Cool Download | this
Wednesday, 08 December 2004 20:07:27 (W. Europe Standard Time, UTC+01:00)  #    Comments [1]

 

September 13 – 16, 2005 with Pre-conferences September 11 and 12 in the Los Angeles Convention Center, Los Angeles, CA. PDC 2005 Site

Wednesday, 08 December 2004 15:17:17 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 

Today we released yet another open source project: #usblib (SharpUSBLib). The history for this project is quite similar to many other OS projects ("scratching an itch"): Mike built a terrarium for his soon-to-be-delivered chameleon, and he wanted to manage the ligthing using a USB-controlled power switch. Not having found a suitable USB library for .NET, he decided to write one himself.

The library is used for low level access to USB devices, and it works under WIN32/.NET and Linux/Mono. Documentation can be found in the wiki, a support forum also exists. The download includes source code for this dual-licensed (GPL and LGPL) library.

Categories: .NET | C# | Cool Download | this | Use the source Luke
Wednesday, 08 December 2004 11:28:39 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 

Not strictly a programming security topic, but useful nonetheless: Attack and penetration testing is a set of techniques and methodologies to test compliance to security policies, and to detect previously unknown vulnerabilities. The overall goal is to limit the points of exposure and to restrict the ability of unknown attackers to gain entry. However, developing an effective attack and penetration testing team presents unique management challenges. This discussion gives some best practice advice and lessons learned from the Microsoft IT experience building and operating an internal attack and penetration testing team. Download

Categories: Administration | Security
Wednesday, 08 December 2004 11:16:25 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 



#  Monday, 06 December 2004

There is a new hands-on lab for Web Services Enhancements 2.0: Learn how to secure Web services without writing code. Sample code is provided for both C# and VB.NET, so it should fit almost everyone.

Categories: .NET | ASP.NET | Security
Monday, 06 December 2004 18:57:51 (W. Europe Standard Time, UTC+01:00)  #    Comments [0]

 



#  Friday, 03 December 2004

Using WSE 2.0? Get SP2. Dont't know what WSE is? Here is a quick overview from the download page:

WSE 2.0 SP2 simplifies the development and deployment of secure Web services by enabling developers and administrators to more easily apply security policies on Web services running on the .NET Framework. Using WSE, Web services communication can be signed and encrypted using Kerberos tickets, X.509 certificates, username/password credentials, and other custom binary and XML-based security tokens. In addition, an enhanced security model provides a policy-driven foundation for securing Web services across trust domains. WSE also supports the ability to establish a trust-issuing service for retrieval and validation of security tokens, as well as the ability to establish more efficient long-running secure communication via secure conversations.

Categories: ASP.NET | Security | Visual Studio
Friday, 03 December 2004 10:28:46 (W. Europe Standard Time, UTC+01:00)  #    Comments [2]

 



#  Thursday, 02 December 2004

Ok, I was convinced to release my current development bits to the general public for public criticism. A PDF document accompanies the download. Make sure you read that first before installing, because installation is rough to say the least (developer friendly, but not end user compatible). But judge for yourself.

Now for the more interesting part: source code is included! This nice registry editor is open source, licensed under the GNU General Public License (GPL). I hope that it can serve for more than just a bad example of how not to do things on a Smartphone ;-). Count on me for documenting the pitfalls and stumbling blocks that I magically wasn't able to avoid.

So without further ado, here is the download. If you want to read up on the history of the project, simply dig into the Smartphone / PPC category of this blog.

Thursday, 02 December 2004 20:00:35 (W. Europe Standard Time, UTC+01:00)  #    Comments [6]

 



© Copyright 2017 Christoph Wille

newtelligence dasBlog 2.3.9074.18820
Subscribe to this weblog's RSS feed with SharpReader, Radio Userland, NewsGator or any other aggregator listening on port 5335 by clicking this button.   RSS 2.0|Atom 1.0  Send mail to the author(s)

 
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.