CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Patrick Smacchia [MVP C#]


Number of Types in the .NET Framework

Brad Abrams just did a post on the Number of Types in the .NET Framework.

Here are the results I obtained with NDepend (slightly higher):

 

#assemblies:  119

#namespaces:  933 (here there are some duplication across assemblies, i.e the namespace System for example will be counted as 21  because it is defined in 21 assemblies)

#types:  39 509

#methods:  384 300

#fields:  240 070

#IL instructions:  8 562 828  (equivalent to around 1.7M lines of C# or VB.NET code, it took 6mn to analyze on a quad 64 bits 4GB machine)

SELECT METHODS WHERE NbILInstructions > 0:   341 842

SELECT TYPES WHERE IsPublic16 463

SELECT TYPES WHERE IsClass29 345

SELECT TYPES WHERE IsClass AND IsPublic12 324

SELECT TYPES WHERE IsStructure:   2 794

SELECT TYPES WHERE IsStructure AND IsPublic511

SELECT TYPES WHERE IsEnumeration4 506

SELECT TYPES WHERE IsEnumeration AND IsPublic1 838

SELECT TYPES WHERE IsDelegate1 312

SELECT TYPES WHERE IsDelegate AND IsPublic690

SELECT TYPES WHERE IsInterface2 864

SELECT TYPES WHERE IsInterface AND IsPublic1 790

SELECT TYPES WHERE IsClass AND IsAbstract1 813

 

SELECT TYPES WHERE IsClass AND IsAbstract AND IsPublic1 008

SELECT TYPES WHERE DeriveFrom "System.Exception"633  (DeriveFrom means derives directly and indirectly)

 

SELECT TYPES WHERE DeriveFrom "System.Attribute"728

SELECT METHODS WHERE IsPublic212 234

SELECT METHODS WHERE IsPublic AND IsStatic29 664

 

SELECT FIELDS WHERE !IsStatic103 349

 

SELECT FIELDS WHERE IsStatic AND !IsEnumValue AND !IsLiteral AND !IsGeneratedByCompiler 22 783

 


Here is a treemap view of the entire .NET framework, the size of the rectangle being proportional to the number of ILinstruction:

 

 

Here is a dependency matrix between the 119 assemblies of the .NET framework (click on it to get a bigger view). A blue cell means a dependency from the assembly in x-coordinate/absissa to the assembly in y-coordinate/ordinate.A red square means that there are some cycling dependencies between assemblies. The last row being full blue represent the fact that mscorlib is used by all other assemblies. In the same spirit, low-level assemblies are down in the matrix and are represented with a lots of blue cells (because they are heavily used). High level assemblies are upper in the matrix.

On the big matrix, the green square are symmetrical to blue square, in other words a IsUsing relation has a symmetrical IsUsedBy relation.

The weight printed on the blue cells is the number of members of the assembly used that are used by the assembly user.

The weight printed on the green cells is the number of members of the assembly user that are using something of the assembly used.

 

 



Comments

Mark said:

That Silverlight and Mono are unlikely to catch on outside Windows.

# March 18, 2008 1:34 PM

Q said:

What is .Net? It is used in a real project?

# March 18, 2008 1:40 PM

Xigam said:

Mono is outside windows since it is an open source version of .NET for Linux. So it's practically 100% outside windows.

There is a version of Silverlight for Linux called Moonlight.. I'm unsure if Silverlight/Moonlight will catch on though.. we will see.

# March 18, 2008 3:04 PM

Krzysztof Cwalina said:

Patrick, are you including internal types or only public ones?

# March 18, 2008 3:39 PM

purrl.net |** urls that purr **| said:

These are the web's most talked about URLs on Tue 18th Mar 2008. The current winner is ..

# March 18, 2008 4:04 PM

DirtyBirdNJ said:

What does this all mean? That the .NET framework is a giant bloated piece of crap... heck I knew that before I read this article. Pat put some pretty graphs that visually show you how much of a slow pig it all really is.

I'll take Adobe AIR/Flex over M$ .NET crap any day.

# March 18, 2008 4:32 PM

miles thompson said:

lots of ignorant comments in the above...

the dependency matrix above is actually really pretty impressive - the relatively small number of 'dark' squares (compared to many projects) and their tendency to cluster together indicates that the .net framework creators have been quite discipined in their creation and come up with quite an elegant design..

# March 18, 2008 5:05 PM

TheHinokiMan said:

@DirtyBirdNJ

Bloated??  I think a better term might be 'complete'.  You don't actually think that all of the APIs get compiled into each .Net app, do you?  .Net apps tend to be quite small in size.  Please don't criticize what you don't understand.

Oh, and go clean your cage.

# March 18, 2008 5:11 PM

Patrick Smacchia said:

> Patrick, are you including internal types or only public ones?

Krzysztof, I included all types, internal, nested and public.

Curtis, I have been forced to delete your comment. Feel free to repost it with normal vocabulary without being vulgare. And I don't see what Adobe AIR/Flex has to do in here? really?

# March 18, 2008 5:41 PM

Haha said:

What TheHinokMan said.

Do your homework.

# March 18, 2008 5:41 PM

manas mittal said:

hello. thanks for this useful visualization. now i realy can start "programming better", as you put it!

# March 18, 2008 9:15 PM

TimeBandit said:

"Net apps tend to be quite small in size"

Yes, if you put aside the fact that everyone of them require the right version of the .NET runtime environment. That is far from being small

# March 18, 2008 9:19 PM

TheHinokiMan said:

@TimeBandit

Not at all true.  .Net runtime updates are part of the normal Microsoft Updates, and they're not very large.  Please educate yourself before making public statements like this.  Pat's post just made it to the top of ./, so let's all be wary of the anti-MS trolls who are about to post religious commentary...  :-)

# March 18, 2008 9:54 PM

Vic said:

.NET Apps really are pretty small.  The framework pretty much comes shipped with the OS now.  I do develop in a corporate environment (which can be quite forgiving, of course) but seriously, when's the last time one had to ship a copy of the framework / runtime to get things to work?  It's pretty much a given now.

# March 18, 2008 10:02 PM

Microsoft .NET by the numbers : techamber said:

Pingback from  Microsoft .NET by the numbers : techamber

# March 18, 2008 10:19 PM

Older!=Wiser said:

@TheHinokiMan --

Yep, I just came over from Slashdot (I think that's what you referred to with "./"). I have what you may consider the unusual ability to admiire the .NET Framework for what it is while at the same time vehemently opposing the perverse and anti-competitive practices of the vendor that sells it. What sort of religious commentary does that make?

# March 18, 2008 10:40 PM

vonyc said:

Well the framework really is not that big, however installing it can take some time. The ubiquity of the framework is a different issue. Having developed cots solutions using .net, I will say that every application that requires .Net must include the runtime installation as part of the application or otherwise ensure it's there. Ubiquity has not really been achieved. To me .Net is the only viable option for general development of Windows software. MFC/ATL/WTL is a nightmare. Handle Unicode in windows c++ applications and just generally dealing with the C API windows provides is like walking on needles, just painful. So if I have an application where the primary demographic is Windows based users I use .Net. WIth the invention of mono, I ensure that my .Net code is platform independent enough to run on mono.

As far as the vast size of .net goes, this is not surprising and definitely leans towards complete. Complete may be a good or bad thing. Perl/PHP/Python/Java are not really complete. For instance I don't think Perl or PHP can parse an XML document out of the box. But thats because of a different approach. PHP has PEAR, Perl has CPAN and I guess I would say that Java has apache(xerces, xalan, tomcat, jakarta) at this point. But which one is better is hard to say. Every time I have to put together a cots application with usability requirements stating the install must be easy, it's a complete pain unless your using something native.

--

Damien Hogan

# March 18, 2008 10:52 PM

Sarphati said:

I can understand the confusion. I dislike Microsoft and their anti-competitive practices. I prefer open source. But, I am a .Net developer and I actually do like C#.

Does this make me confused?

On the framework comments... It is true that you must have the correct version of the framework installed. I don't think the frame work is that small either. However, have you every seen a Windows production server that did not have the the first 2 frameworks installed? It is standard practice when setting up a server. It becomes a non issue. It only becomes annoying when you want to run something locally on your computer.

# March 18, 2008 11:18 PM

J. Watrous said:

C# was really a Java implementation created by Fisher Price and sold to MSFT.

MSFT has a sure win with all the future toddlers cutting the teeth on C#; continuing vendor lock in vis a vie spoon feeding it's handy capable 'code assemblers' the sweetest no thought required developer tools.

Soon coding will be like assembling a burger at McDonald's - high school students will get an IDE that resembles that cash register with press the picture for the right function/Lib code combo  meal.

Not in the empty calories fast food crowd you probably got a degree in MIS.

Well I imagine  that coding C# for you is like having a degree in Architecture but with a preferred medium  of  bunch of lego blocks with preassembled buttresses  etc.

The thrill being Cloning other famous landmark designs but building them in lego.

You may say robust and mature with it's 384,300 blocks to play with, but I say dangerously simple.

# March 19, 2008 12:00 AM

Jon Limjap said:

Why is it that whenever someone writes about .NET's characteristics, some FOSS/LAMP/Java/Ruby/Perl/Python zealot comes in to start a pissing contest?

# March 19, 2008 12:48 AM

Derreck said:

They're jealous, that's why.

.Net is huge and sometimes seemingly unwieldly but it has done a good job encapsulating everything you need to write anything in a concise manner.  I give them props for that and that alone.

# March 19, 2008 1:01 AM

Richard said:

J. Watrous "C# was really a Java implementation created by Fisher Price and sold to MSFT"

Wow, have to say that this is the most brain dead, dumbass comment I've ever read.  Anders is a brillant language designer and if you EVER even studied language design in the slightest you'd have a basic clue as to why you are an idiot.

Here's your challenge; do something better or STFU!

# March 19, 2008 1:04 AM

dot net types » article » Thats The New Thing! said:

Pingback from  dot net types » article » Thats The New Thing!

# March 19, 2008 1:07 AM

Espresso Fueled Agile Development said:

As anyone who has ever tried to find docs on MSDN already knows, the .NET Framework is big. Real big.

# March 19, 2008 1:09 AM

turbo pascal rocked my world said:

Richard, you're absolutely right on J. Watrous...

Easy to talk a big game and spew typical anti-MS rhetoric.  Much harder to actually have the chops to do it.  

Is .NET big? Debatable.

Is .NET complete? Pretty much.

Do these graphs show that the framework designers are capable of taking a complex problem and designing it as elegantly as possible?  Without a doubt.

Let the trolls spew forth their nonsense.

They're still just trolls.

# March 19, 2008 1:43 AM

mike said:

.net quite simply, rocks!  I'll never go back to PHP.

# March 19, 2008 3:31 AM

MSDN Blog Postings » The .NET Framework is a bit on the big side. said:

Pingback from  MSDN Blog Postings  » The .NET Framework is a bit on the big side.

# March 19, 2008 3:36 AM

janus said:

Oh, I will still be using PHP. It has it's uses and I also still use it for commercial applications. Having said that I really like C# and .NET (having run Linux for 10 years on the Desktop).

# March 19, 2008 3:45 AM

James W said:

@J Watrous: Wow, Fisher Price is pretty good at language and framework design. Given at release C# fixed a lot of annoying issues with Java which the JCP took too long to resolve, and is now firmly ahead of the curve in terms of innovation. Framework performance also gives Java a run for its money.

# March 19, 2008 3:51 AM

Stilgar said:

Can someone explain what we are seeing in the graphs? I think I lack the knowledge to understand them.

BTW "programming in .NET is too easy and everyone can do it" is really stupid argument when you are trying to insult the technology. It actually shows how good it is. What is more it is not entirely true.

# March 19, 2008 4:14 AM

Michiel U said:

.Net beats Java in terms of speed and usability, that's for sure.

But really, the way the .Net environment is set up makes it a enormously uncontrollable mess. Basically, if you want to work with .Net, you have to do it the MS-way (using the .Net interface, even if it does not match your requirements) or you had better leave it.

Finding out the underlying structures that you need to override if you want to adjust behaviour is way too complex. Documentation at MSDN is available, but for three or four different versions of .Net that either not implement the same API or implement it differently. Developing for .Net is developing for a moving target: not pretty.

I pitted .Net, perl and PHP against each other in a web-development situation. It turns out PHP on Linux consistently performs better except where a compiler can excel in optimizing loops and such. Even on Windows, PHP performs almost as good as .Net and as far as I know, PHP performance has increased in IIS7.

.Net eats too much memory, takes too much resources to 'manage its code' and suffers from overly complex interfaces.

The only situation where I would recommend .Net, is if you were bound to a Windows platform running IIS and you had to develop a common code-base for several web-projects that also had to interface with specific features of the Windows platform system management. In all other cases: use a weakly-typed, interpreted platform for webdevelopment.

For non-webdevelopment, why take .Net? Take C++. MS has one of the best, if not the best, C++ compilers of the world and as you are tied into the Windows platform anyway, your binary environment is set already. The MS development environment is roughly the same. Plus C++ supports multiple inheritance. And it avoids the horribly complex GAC setup and stuff.

# March 19, 2008 4:40 AM

Java Zealot said:

Here is a message from Java zealot ;) : with all their merits and deficiencies Java and .Net are the 2

platforms to dominate the next 10 years of general purpose software development. C# is in may ways

better than Java the language - partly because it had the opportunity to learn from Java mistakes. .Net

is comparable to Java the platform. Not yet as mature but going there. .Net however has bleak prospects

on the server side because of its dependence on Windows. I would just NEVER venture to run a farm

of Windows servers. Even Linux is MUCH better than that and commercial UNIX-es are light years

ahead in stability, reliability, scalability, security, manageability. Desktop and server are inevitably

entirely different worlds and attempts to cover both with the same OS are doomed.

P.S.: Yes, I do try hard to judge .Net on its own merits regardless of my feelings about MSoft. And those

feelings are harsh not because MSoft is as big as it is and as arrogant as any company of its size would

be but because no truly innovative technology idea was ever born in there. When they needed a real

operating system (as opposed to Windows 3.x, 95. 98) they bought a team from DEC to create that.

When they needed a platform to compete with Java they bought a team from Borland to create that.

To me MSoft is just a big money making machine which does not really care about technology excellence

and creativity and since I do care about those I also do feel the way I feel about MSoft.

# March 19, 2008 5:28 AM

Lucian's weblog said:

Daca v-ati intrebat vreodata cate metode, clase, campuri, etc. sunt in .NET Framework si daca inca nu

# March 19, 2008 5:53 AM

Mr. Happy said:

Patrick,

Thanks for the info.  It's nice to have the framework quantified.  Makes me feel far less silly not knowing all the internals.  I'm sure the Java folks feel the same way though, especially with a few extra years for maturity.

Of course, it doesn't really matter since I'm building Lego(tm) stuff for my fortune 50 clients and apparently going to straight to hell (don't pass St. Peter's Gate, don't collect 200 Purgatory dollars) because I'm using a Microsoft product.  :)

# March 19, 2008 7:25 AM

Victor Mierla said:

C# is a much needed development for Linux (especially from GUI point of view).

The big mistake in Java IMO is its awfull aproach to GUI ( In UNIX). First Awt , than swing and now swt wich is "rendered" throguh GTK Or Motif. (and by that , bounded by their deficiences - and there are lots of them).

C#'s aproach to graphics ..."write it from scratch" .---they started coding libgdiplus..rendered via cairo/antigrain...with backend  on OpenGL or X , high level widgets (buttons,etc) being written in managed code (c#) over libgdiplus.

This is a novelty for SDKs in Linux...and i think it's the correct way.

Sticking to API like SDK,Motif or QT is a big mistake... if we want Linux to be a competitor to Windows(aero) or MacosX.

I really dont like microsoft ..but there are some things they do well and i think they should be "imported" in Linux.

For the rest ..i think that current capabilities of .net and java are equivalent for more than 90% of the programmers.

The difference will be made at GUI side IMO, because we just can't have console-based apps anymore.

# March 19, 2008 8:13 AM

Patrick Smacchia [MVP C#] said:

I am impressed by the buzz done around my last post on Number of Types in the .NET Framework . Actually

# March 19, 2008 8:31 AM

SW said:

.NET makes it easy to do things badly, and harder to do them right.  It's a deeply flawed toolkit.  Porting that monstrosity as though it was something you'd actually want to use if you didn't have to is a sick joke.

Hurry up and die, MS.  Hurry up and die.

# March 19, 2008 8:44 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# March 19, 2008 8:56 AM

Ian MacMillan said:

Great job! I knew it was on the vast side... having done development in both camps (currently jee/ajax/framework-of-the-day) I like how C# has evolved as a language but can't say the same about WCF and some of the 3.0 curiousities. I agree with the above comments about GUI development but the clients I deal with are all moving toward web browser based interfaces to their functionality. My biggest concern is the cost factor, as are some very big clients I have worked for who are moving away from MS to either LAMP or more java-ish open source solutions - and the driving factor is cost. One of them was a long time MS shop (COM/ATL C++) with a huge investment, but decided that on going licensing costs as well as equipment upgrades for Vista were the last straw... and unless MS can get its OS house in order the future of a very mature development (that really rocks if you dial in reSharper) could become shaky to say the least.  ...unless they port it to the Mac.  =o)

# March 19, 2008 9:43 AM

Wil Palen said:

What a load of cr*p comments here. Is this symptomatic for .net devz? It looks to me that very few posters here actually ever went beyond the complexity of a 'hello world' app.

# March 19, 2008 9:45 AM

Will Mockridge said:

I'm surprised at the amount of vitriol for M(dollar sign).  You people are adults right?  Would you fault Caterpillar for having OMG HUNDREDS OF VALVES ON A BACK HOE MY TRACTOR ONLY HAS SIX THATS ALL ANY MACHINERY NEEDS MY TRACTOR CAN DO ANYTHING YOUR BACKHOE CAN?

Sure using .NET to write a device driver or high performance software that's rarely going to change, or to write one off tools for system administration or academics, but it's also silly to try to write software in Haskell or C that's being developed as it's being deployed and half of it is going to be rewritten in a matter of months by a half dozen different people.

# March 19, 2008 9:59 AM

Commodore73 said:

I love it when the Linux zealots show their ignorance of .NET. They probably won't read the responses to their invalid posts though.

# March 19, 2008 10:14 AM

dude said:

I don't know how to read the graphs, maybe its beyond the scope of the article, but would be cool to have some expln. Re: the ".net sucks" comments, use the right tool for the job. For many jobs .net is the best tool. Any tool that boosts productivity should have a place at the table. If an app is bloated or runs slow I say blame the engineer not the tool!

# March 19, 2008 10:22 AM

randy said:

that is fucking sweet! nice work!

# March 19, 2008 10:42 AM

Fred said:

Whenever I read strongly worded statements about one language / tool / environment it reminds me of how inexperienced many developers are.  I've written code for over 25 years in about a dozen languages and on different OS's.  Unix, Linux, Windows, VMS and MVS to name a few.  The environment is less important that your own skills.  Come see me for a job interview and spend the entire time harping on your C# or Java skills.  Unless you have a broad range of skills then you'll come off as a narrow minded, one trick pony.  I won't hire you if your not able to switch over to another toolset without formal training.

The most important thing a young developer can learn is to use the right tools for the job.  Picking ASP w/C# or Python for a project should have little to do with what an individual "likes" to do.

I've written thousands of lines of C# over the past 5 years.  I do like it but it has its shortcomings.  The framework feels very "heavy" and slow.  The IDE behaves the same way.  There's a lot of baggage with .net apps and especially how it integrates with the OS.  A lot of work done in .net is for the sake of making a specific "logical" structure.  Everything is very formal.  The multi tiered model isn't always necessary either.  Many applications don't need to have a business object layer that's remoted through a BL layer and persisted with a DA layer.  The model is complicated, slow and not often used for the sake of efficiency or scalability.  It's often done more because it's "cool" or that it's "the way it should be".  In production, logical layers often end up being hosted on the same hardware but in VM's.  A bad move by the operations team but something that's done all the time.

I picked up python last year because I was disappointed with what I could do with ASP.Net.  I found that .net involved more work on architecture, models and design of the code.   I started to question why that work was necessary.  Sure the software was cool, in fact incredible but what was the value in doing it that way?

So I started exploring other languages and frameworks.  I started looking at what other market leaders were using.  I tried many tools and eventually got drawn into a framework called Django.  I was so amazed at home much more of my time was spent working on software functionality vs. cool "textbook correct" code.  I was able to write web applications in 1/20th of the time that .net required and the code was much smaller.  I know this because I re-wrote a number of ASP.Net applications.  Another benefit was being able to host the code on multiple OS's, multiple databases and multiple web servers.  Yes, you could do this with .net but not as easily.  You have to code all of this support into your design.

This is one example of how different an experience you can have with different tools.  I still use both environments because .net is a mandated standard for our organization.  But for contracted or personal projects I'd rather pick the best tool for the job.

# March 19, 2008 10:52 AM