Number of Types in the .NET Framework


Occasionally I get asked how big the .NET Framework is in terms of surface area for developers.  As you might guess this is something we track.  As you can see, in each release we are adding new functionality that make it easier to build .NET applications.    The number of types in the .NET Framework is 11,417!  Any guesses on how many types will be in .NET Framework 4.0?

 

image     image

 

image        image

 

   
   
Comments (63)

  1. Estimados Amig@s , El día de hoy me he topado con un artículo muy interesante escrito por Brad

  2. ASP.NET, Web Evítate problemas: pon SIEMPRE un nombre de aplicación en Web.config . Una recomendación

  3. shuggy says:

    Sorry are these public only? (relevant to surface area for users rather than BCL developers.

    I really should whip up a treegridview of this by names space…

  4. Mike says:

    Who ever said more types == easier to program?

  5. dotGicu says:

    Mike you are not required to use all that types, you chose ones that meets your requrements, perhaps I think it is better to have choise.

  6. Anonymous says:

    So when is .net framework 4.0 coming along?

  7. Greg says:

    The large number of types is why our code reviews focus on reducing the number of different .NET framework calls our applications use.  More framework calls means larger likelihood of bugs in existing applications and when the framework is upgraded.  

    It would help us greatly for the MS compilers to emit a map file, a cross reference file, etc that we can process using simple scripting tools (e.g., Findstr) to find these type of problems.  The VS class browser is nice but it is not something we can put into an automated build.

    Reflection, for example, is scrutinized heavily since we’ve experienced it being used for a number of bad programming practices (e.g., A consultant not concerned with maintenance costs built a large data model and then recursing its object hierarchy to generate a report instead of just writing the report from the original database data. (Apparently, it was resume driven development or turn in and forget about your semester project))

  8. Each new library has a mandatory lifetime of 3-5 years? or is that just speculation? This might be one reason for the exponential appearance of the complexity curves above.

  9. Mafaz says:

    That’s some good information. But as Mike says, I doubt if we have numerous classes there might be a learning curve. Anyways having too many things implemented eases life for lazy developers.. 😉

  10. sangram says:

    thank Brad for information

  11. Ajit Singh Shekhawat says:

    As per trend analysis

    Assemblies    y = 15.1x + 17.3     108

    Namespace   y = 51.6x + 51      361

    Types    y = 2249.3x + 626.9    14123

    Members   y = 21343x + 7951.3    136009

  12. Josh Coswell says:

    I wonder if there would be a break point at which a bifurcation would accure and split the .NET framework into two or more than two branches.

    I do not know what would they call it but this is my guess. As the monolithic systems become too big there is tendency of heirarchy etc etc.

    (When heirarchies become too big they become monolithic and this cycle goes on and on)

    (Just like C# classes)

    Josh Coswell

    http://riverasp.net

  13. Ganesh says:

    Well I think we may see .NET 4.0 in 2 years time from now.

    Types – 12,500 odd.

  14. Jarod says:

    @Josh

    I believe they are already doing this. Red bits & Green bits. Not a split as you allude, but a core with extensions. From my understanding its pretty much ‘someones going to die’ before a red bit is changed now-a-days.

  15. kees van Sighem says:

    Design is finished when there is nothing left to remove. It looks like there is a lot of work to be done 😉

  16. David says:

    mmm, are MS planning to release some GOOD doc, instead of MSDN, which is totally unuseful ?

    It would be appreciable…

  17. amar says:

    We would probably end up with multiple editions of framework like .NET Lite, .NET Mobile, .NET Server, .NET Regular etc. Or may be in other dimention, .NET Desktop, .NET Enterprise Server, .NET Web Server etc..

  18. Mai Omar says:

    David .. The MSDN is realy great.. just read it. it’s very useful.

    but MS always have this mesg " The Program encountered a problem & need to close " :-(

    Hope it would be fixed one day..

    I Realy wonder how .NET 4.0 going to be … it sure will help more & will be easier..

  19. Serware says:

    More types==more .NET funcionalities==less work for programmers==more productivity==more end software funcionalities.

    Thanks.

  20. Chabster says:

    Adding new functionality is good. But killing old functionality is even better. Who needs ArrayList anymore? Who needs File.ReadAllLines if it could be implemented by an extension method and put into separate assembly which i wont ever use.

  21. Eric says:

    Re: Chabster.

    ArrayList and File.ReadAllLines is needed as soon as you open a old project that you’ve received a bugreport on. Marking them as deprecated so they throw a warning, sure, but you can NEVER remove anything. Doing so will kill all of us who work professionally in anyway.

  22. Stu Smith says:

    Was this a personal investigation, or part of a larger MS code review? If the latter, it would be interesting to hear about it. Come to think of it, I haven’t heard any rumours about .NET 4 – care to give any hints? (Or are you guys only just starting to think about it now that .NET 3.5 has been released).

    With regards code reviews, any comments on the increasing proportion of .NET surface area that isn’t available to us (ie, internal)? My brief analysis:

    http://www.feedghost.com/Blogs/BlogEntry.aspx?EntryId=17806

    Hopefully I haven’t come across as too negative – the .NET framework is a fantastic achievement – so thanks for making my coding life more pleasant!

    Stu

  23. Chabster says:

    Re: Eric

    Compatibility is the main thing that slows any progress. If you need to open an old project you will definitely open it in an old version of Visual Studio and continue using an old version of .NET FW.

    If thing are never removed every framework becomes a monster. AFAIK .NET 1.1 is not supported on Vista. How would you you explain your customer why he must install a 100 Mb library instead of 20 Mb for compatibility reasons?

  24. Eric says:

    Chabster…

    .NET is built with each new version incrementing on the old one. The new one doesn’t remove features that were there previously, although I THINK that replacing is done, even though they probably use extension methods for that instead(see the linq additions to the old classes). If it did, versioning would be hell. 1.1 is compatible with everything from nt 4.0 up to and including vista, see compability  at http://www.microsoft.com/downloads/details.aspx?FamilyId=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en.

  25. Brad Abrams just did a post on the Number of Types in the .NET Framework . Here are the results I obtained

  26. Kent says:

    Is the source code for .NET 2.0 available yet?  If so, where?  MSDN is nice, but the only completely accurate documentation is the source code.

  27. Have a glance here where I show what NDepend has to say in terms of metrics and dependencies when analyzing the entire .NET Fx3.5:

    http://codebetter.com/blogs/patricksmacchia/archive/2008/03/18/number-of-types-in-the-net-framework.aspx

    #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)

    SELECT METHODS WHERE NbILInstructions > 0:   341 842

    SELECT TYPES WHERE IsClass:  29 345

    SELECT TYPES WHERE IsStructure:   2 794

    SELECT TYPES WHERE IsEnumeration:  4 506

    SELECT TYPES WHERE IsDelegate:  1 312

    SELECT TYPES WHERE IsInterface:  2 864

    SELECT TYPES WHERE IsClass AND IsAbstract:  1 813

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

    SELECT TYPES WHERE DeriveFrom "System.Attribute":  728

    SELECT FIELDS WHERE !IsStatic:  103 349

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

  28. Ollie Riches says:

    People getting excited about C# 4.0 for me is like watching the famous Monty Python ‘Four Yorkshiremen’ sketch…

    Are there really any business problem you can’t solve with todays versions – I  know it might look more elegant in 4.0 but come on….

  29. Phil Shaffer says:

    Brian,  

    It would seem that no good dead goes un-appreciated.  I and many others appreciate your taking the time to share your metrics with us.

  30. Phil Shaffer says:

    errr…that was meant to be "good deed".

  31. Earl Truss says:

    "you are not required to use all that types, you chose ones that meets your requrements, perhaps I think it is better to have choise."

    Of course, but to make an informed choice one must know about all the possible things to choose from.

  32. Carter says:

    I am guessing 13,511 in 4.0 (this is with human brain + guessing analysis I didn’t break out moving average or trend lines etc.).  Do I win a pot of gummi bears if I get close without going over?

  33. if (dotnetcompiler)

    {

      using(JavaServer vmachine = new JavaServer())

     {

       vmachine.Impersonate(dotnet, "C#");

       objMachCode = vmachine.Compile();

       vmachine.Launch(objMachCode);    

     }

    }

  34. George Kapsambelis says:

    @Phil: Who’s Brian? :)

    Brad, thanks for the metrics.  I too see each successive release as making it easier to build an application that has much greater functionalitly with less written code from the developer.  The only caveat there is that it requires even more study of the framework itself with each release in order to gain a good understanding of what you can accomplish with it.

  35. partha says:

    What are you planning for .net 4.0?

    When will it be released?

  36. Yoda says:

    That is why you fail, Padawan.

    Master Occam has much to teach you.

  37. Some Guy says:

    Can we say "bloat", boys and girls?

    You clowns have no idea what you’re doing.  This is  precisely the same rathole that Taligent went down.  By trying to put everything you can imagine in the library code, you make it easier to just write your own widget than look for it in the multitude  of .NOT classes.

  38. Sambo says:

    I hope .net 4.0 will be design for good performance.

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

  40. You guys are just adorable... says:

    You’re right.  The Java docs are so much better… Just look!

    http://java.sun.com/j2se/1.4.2/docs/api/index.html

    Oh, wait… was that sarcasm?

  41. a says:

    Un-be-smegging-lievable. Given that the .net framework is apparently being "designed" by people with absolutely no clue and no taste whatsoever, I’d say the number of types in version 4 will be well in excess of a bazillion. And all of them shite.

  42. Intergenite Andrew Tokeley recently blogged about how a Microsoft developer has to know so much more

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

  44. TerryLee says:

    概述本期共有10篇推荐文章,由于忙着写Silverlight2系列,所以导读写的不多,都是三言两语带过,希望大家见谅。1.CreatingaCustomSkinforSilverlig…

  45. Recently Brad Abrams wrote a blog post about the number of types in the NET framework with some general

  46. dnadvisor says:

    Interesting info.  I never would have guessed that high but then I really didn’t have a clue!

  47. Jacky_Xu says:

    概述

    本期共有10篇推荐文章,由于忙着写Silverlight2系列,所以导读写的不多,都是三言两语带过,希望大家见谅。

    1.CreatingaCustomSkinforSilverl…

  48. Anytao says:

    Namespace, Types, and Assembly, are all the main component in Framework.

  49. A dummy says:

    More type =>> dummies can program =>> less $ for everybody.  

  50. BradA says:

    >>Shuggy: Sorry are these public only? (relevant to surface area for users rather than BCL developers.

    Yes, these are public types and publicprotected members

    >>Mike: Who ever said more types == easier to program?

    You have a good point… We absolutely look at the surface area of the a feature vs. the value it provides.  We have rejectedrefactored many designs that have come through review because they are simply more complex than is warranted for the feature they are providing.     On the other hand, if you look at something like WPF, it adds a lots of new surface area, but then it also adds a lot of new value in terms of the way differentiated UX is created with .NET… Clearly we are not perfect across the framework on this, but we are totally with you that more types doesn’t alway

    >>So when is .net framework 4.0 coming along?

    We are working hard on future releases of .NET… I don’t have anything I can say right now, but stay tuned!

    >>Frank Hileman: Each new library has a mandatory lifetime of 3-5 years? or is that just speculation? This might be one reason for the exponential appearance of the complexity curves above.

    Boy, we are making a big mistake if new libraries only last 3-5 years.. I started designing frameworks working on  the BCL…  We are coming up on the 10th anniversary of the design of much of the BCL and it seems to be standing the test of time. But you right that the new growth of the framework  is primarily based on adding new subsystems…  for example ALL of the 2.0->3.0 growth was from adding WPF, WCF and WF functionality… all new subsystems that made is much easier for people to build new classes of applications.  

    >>Ajit Singh Shekhawat: As per trend analysis….

    I love it!  I will try to do a similar post as we get closer to future releases of the framework… and we can all look back and see if you were right!

    >>Josh Coswell: I wonder if there would be a break point at which a bifurcation would accure and split the .NET framework into two or more than two branches.

    Good through.. we are thinking hard about this right now.. on the one had I think .NET offers developers an excellent end-to-end continuum.. As a .NET developer your skills will take you from desktop, to web, to RIA to REST services nodes and back!  Whatever we do, we must preserve that end-to-end value of .NET… that said, getting some SKUs that are more focused on particular scenarios could be a good idea.. in many ways, this is what Silvelright 2 is… a SKU of .NET For RIAs…  Possibly we need more options… we are thinking about it.

    >>Jarod: I believe they are already doing this. Red bits & Green bits. Not a split as you allude, but a core with extensions. From my understanding its pretty much ‘someones going to die’ before a red bit is changed now-a-days.

    Yea, you know.. to be honest, my opinion on the whole Red bits green bits thing is evolving..  even the name “red bits” implies you can’t make any changes… I don’t think that makes sense.. I think we need to be able to innovate across the stack, but clearly we have to do that in a way that doesn’t break apps.  I think you will see some examples of this in future servicing releases of the framework.  I think of this as  more like “Yellow bits” 😉

    That said, there will be another release of the .NET Framework that is fully side-by-side… this is important for a lot of reasons.. and I hope no one has to die to make it happen!  

    >>kees van Sighem: Design is finished when there is nothing left to remove. It

    Good call!  I actually totally believe you on this one…    The team is actually very committed to using an economy of surface area to enable the great functionality customers are asking for.  It might be fun to do a summary of all the work we do to reduce the types in the system and make them cleaner and easier to use for you…  

    >>Serware: More types==more .NET functionalities==less work for programmers==more productivity==more end software functionalities.

    You know, that is exactly what we are aiming for… try to do a transacted web service or a work flow in .NET 2.0 before we added WCF and WF in .NET 3.0… try to do OR mapping in .NET 3.0 before we added LINQ…. Clearly we are adding a lot of great value to the framework in every release..

    >>Chabster : Adding new functionality is good. But killing old functionality is even better.

    Oh, this is a good meaty conversation…  I am totally with you in spirit, but as a company we have an deep obligation to compatibility..  We owe it to our customers to keep their apps working!

    >>Stu Smith: Was this a personal investigation, or part of a larger MS code review? If

    This is part of a larger MS code review.. we do them all the time actually.. there is a formal process for getting new surface area into the framework that my team runs..  Boy, I wish I could tell you all the issues we have caught over the years!  Clearly there is more work to be done, but we do have a process and it is staffed by the right people.    I hear your point on wanting more of the framework to be exposed… If you look at efforts like ASP.NET MVC, that is exactly what we are doing…  But we are doing it in a very thoughtful way… every public API cost us lots in support and documentation and testing costs..  we need to be wise.

    >>Chabster : Compatibility is the main thing that slows any progress. If you need to open an old project you will definitely open it in an old version of Visual Studio and continue using an old version of .NET FW.

    I hear you… But we also have customers that have really large applications… they may need to only touch part of the application to use say some cool new UI with WPF… do they have to re-write the data layer just to use WPF? NO!  We have kept the framework compatible across versions for this reason.

    >>Kent: Is the source code for .NET 2.0 available yet?  If so, where?  MSDN is nice, but the only completely accurate documentation is the source code.

    Yes!  Check out the details: http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx

    >>Ollie Riches: Are there really any business problem you can’t solve with todays versions – I  know it might look more elegant in 4.0 but come on….

    I am very glad you find .NET 3.5 so useful!   I do as well…  As we are thinking about .NET 4.0 we are thinking about the business problems of the future as well as today…  Are you very sure your business problems will not change?  

    >>Phil Shaffer: It would seem that no good deed goes un-appreciated.  I and many others appreciate your taking the time to share your metrics with us.

    Thanks!  I really appreciate that.. but I do love all the feedback!  It is a good conversation.  

    >>George Kapsambelis:   I too see each successive release as making it easier to build an application that has much greater functionalitly with less written code from the developer.  The only caveat there is that it requires even more study of the framework itself with each release in order to gain a good understanding of what you can accomplish with it

    It is a good point – we try to mitigate the learning curve as much as possible by following a common set of guidelines, patterns and basic types as we build out new subsystems of the .NET Framework… so for example if you know how to use File IO, moving to networking is no big deal…

  51. mohojojo says:

    Két érdekes linket szeretnék megosztani. Mindekettő a Framewrok terjedelmességét hivatott bizonyítani

  52. raisch says:

    More design is usually not good design.

  53. phil daniels says:

    .Net is like a capitalist economy, if it doesn’t grow then the media will deem it to be in trouble.  

    Shrinking economies are said to be in recession, IMO a shrinking software library would be a thing of beauty.

    Regarding backward compatibility (eg ArrayList) – why not allow multiple versions of the same library to be incorporated into code – thus System.Collections.1 would contain ArrayList whilst System.Collections.2 would not.

  54. Ditemi quali classi usate e vi dir

  55. Thought I would bring this back again and see if it was popular or not this time around. So many things

  56. Leidsin väga huvitava postituse Brad Abramsi blogist, kus on visuaalsed graafikud selle kohta, kuidas

  57. topzengyi says:

    概述

    本期共有10篇推荐文章,由于忙着写Silverlight2系列,所以导读写的不多,都是三言两语带过,希望大家见谅。

    1.CreatingaCustomSkinforSilverl…

  58. Mayur says:

    excellent :)

    well i will not crib about how good or bad this is … but must say the info is really interesting … never thought about that though

  59. Interesting Post. I immediately wanted to know the critical surface area component: # of interfaces. Smachia provides this with 2,864, but he also has a only 39,509 types. Not sure why the discrepency, but can someone provice the number of interfaces. I we tout programming to interfaces for 90% of the code then this would be the waypoints of some other metric to limit the overall surface area.

  60. sunjie says:

    本期共有10篇推荐文章,由于忙着写Silverlight2系列,所以导读写的不多,都是三言两语带过,希望大家见谅。

    1.CreatingaCustomSkinforSilverlight…

  61. .NET Bits says:

    There was a question today on how many types are there in the .NET framework and I remembered reading

  62. Your Story is Submitted – Trackback from DotNetShoutout