Showing posts with label .NET Framework. Show all posts
Showing posts with label .NET Framework. Show all posts

Monday, April 7, 2008

Visual Studio Codenames

Today I was listening to a Microsoft internal presentation and they kept referring to codenames of our Visual Studio products. This aspect of the presentation was not secret by any means as all of these names are very much public knowledge, but my big issue is they were confusing me.

You see life outside of Microsoft tends to refer to products in their finished state: Visual Studio 2005, Visual Studio 2008, etc. (This might not be true everywhere, but has been true for me.)Now though that I work for the company of acronyms and codenames I am starting to pay more attention to them in an attempt to stay sane.

To help, here is one collection of codenames everyone should probably know (and im sure has heard of) in the VS.NET family:

Codename Description
Everett Visual Studio 2003
Whidbey

Visual Studio 2005

Orcas Visual Studio 2008
Rosario Visual Studio Team System 2008+ (source)
Hawaii "Visual Studio family past Orcas" (source)

If anyone has additional names that belong to this list and I missed please dont hesitate to contact me with them or post a reply to this entry.

Wednesday, February 27, 2008

int vs Int32

int iViaKeyword = 0;
Int32 iViaClass = 0;

The above two lines of code declare the same exact Integer variable. Back in the VB6 days for example an Integer was 16 bit but in today's world in both VB.NET and C# the int Keyword represents a signed 32bit  integer.

So what is the difference, why have the two ways to declare the same exact thing? Lets examine both of our options in more detail to try and figure this out.

Comparing: Int32 to Int

Int32 is defined in the documentation as a Struct (System Namespace) that represents a signed 32bit integer.

Int instead is defined as a Keyword that points to the Int32 Struct and therefore also holds a signed 32bit integer.

Given this information both seem identical and can be used interchangeably. For example one could says iViaClass = iViaKeyword from our code above and get no errors nor a message that requests an explicit type conversion in C#. For all coding purposes these two are exactly the same.

To me personally this is a bit confusing as an implementation and I would have gotten ride of the int Keyword, but perhaps given the legacy comfort developers have typing int into their IDE this could perhaps explain its existence.

Int32, Optimized for the processor?

As for using Int32 vs. Int16 or vs. Int64 various documentation state that an Int32 is optimized by the compiler for the processor and therefore should be used in most cases where it wont overflow.

I do have to question this though now that 64 bit processors exist, does that mean that Int64 would be more optimized on a 64bit platform? I am not sure of this answer and will look into it later.

Coding for Change

I have seen some discussions in forums that argue when you type Int32 you guaranty that your code will target an Int32 no matter what, as this is a specific implementation. Using the Int keyword does not necessarily come with this guaranty as one day Microsoft might change the Int keyword to mean Int64 as it once changed Int from 16 to 32.

To me such a breaking change seems unlikely but one can never be 100% sure and I would give this argument some validity. If I was building a system that needed to stand the test of time I would consider following this advice.

Closing

I look forward to your feedback and any comments or corrections. Even this simple concept in .NET has a lot of depth and I look forward to any discussion that this might spawn.

Wednesday, January 2, 2008

Pre-compiling Winform .NET Applications

Questions and Confusion

Before the new year holiday I had a good friend of mine ask me a question I must admit I didn't fully understand. The main point of his question was centered around the lifecycle of the MSIL code once its compiled into binary. Did the compiled copy get created per application session? Is it stored in a cache? When and how does it expire?

The main confusion I had was context, is he talking about Winform or ASP.NET? I assumed Winform as I know my friend understands ASP.NET very well and I was right. After talking to him he explained that his main concern was the performance of .NET code vs native C++ code. He assumed that the difference would be minimal if the code can be pre-compiled as the JIT would be one of the biggest performance hit in this kind of scenario.

To be honest I didn't know the answer to his question, but doing some research I believe I have come up with the answer.

NGEN Utility

image

NGEN is a utility that comes with the .NET Framework and can be located at paths such as the one below for the 2.0 edition:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\NGen.exe

For more information on how NGEN works I recommend this article from MSDN magazine May 2006 issue: CLR INSIDE OUT: The Performance Benefits of NGen. This article talks in detail on how to use NGEN to gain performance benefits but here is the general idea.

The basic idea behind JIT for .NET in a scenario were NGEN pre-compile is not used is as follows

  • You call for the execution of a .NET managed EXE or DLL
  • The JIT (Just-in-time compiler) kicks in and compiles it inside of the windows directory (best guess of the location, more on this later) under some funky name
  • As long as you keep running your program, it stays in the Native Image Cache (NIC)
  • When your program terminates the Native Image is cleaned out of the NIC. Meaning that next time you run your program, it will need to recompile again

When using NGEN to install your application through the "NGEN INSTALL c:\yourapppath\yourapp.exe" command the application and its dependencies are pre-compiled into the %WINDIR%\assembly directory. This save startup time and avoides the constant JIT compilation on every start.

The downside to using NGEN (as noted in various articles and blogs) is that the disk footprint of your application becomes larger, since the compiled Native Image is larger then the MSIL code. With today's hard drives though I don't see how this would be an issue in most circumstances.

To me based on this information using NGEN seems like a smart move that can benefit any application but especially large ones or those that spin-up and spin-down often.

Unfortunately I do not have time right now to try all of this for myself so all my information should be taken with a grain of salt.

Pending Questions about NGEN

I also have a few important questions pending. I will attempt to answer them at a later point as time allows:

  • I cant seem to find where the JIT Native Images are stored when not using NGEN. I'm guessing the location is %WINDIR%\. This assumption is based on the following blog post talking of issues with JIT, Windows Directory and permissions on Citrix Servers: .Net Framework Applications Writing to the Windows Root Directory
  • I don't know when using NGEN starts making sense. Is there a natural point at which NGEN becomes a large performance benefit? JIT must be very fast for most modern applications?
  • Is NGEN automatically called by the installer when you create an MSI form Visual Studio or 3rd party tools like InstallShield? Perhaps NGE is already used a lot more often then I realize
  • Is .NET smart enough to recompile the Native Image in the Cache automatically if you update the EXE/DLL but don't run NGEN UPDATE command? If this is not the case then I see a major downside to using the pre-compile for applications that are updated manually

If anyone has any insights into these questions please feel free to post a comment reply to this blog entry, id love to hear from you.

Additional Resources

While doing my research I found a few other links worth mentioning:

  1. Improving WPF applications startup time: This post by the WPF Performance PM (no name given in Blog) talks about various points that can hurt WPF performance and touches on NGEN. Interesting article worth reading
  2. NGEN in MSDN Magazine: Another great NGEN article
  3. Windows Forms Performance Tips in MSDN Magazine: Talks about various way to improve the performance of your windows applications

Underlying Concern: Performance of the CLR

What drives this whole topic more then any other issue is the concept of performance. When comparing .NET C# vs lets say C++ native code people can definitely point fingers and claim various performance benefits in doing thing closer to the platform with C++. Fortunately anything gained by native code is in most situations outweighed by the productivity gained when using an easy to develop in managed environment as provided by VS 2005/2008 and .NET C# or VB.NET.

There is a time to build super efficient code and there is a time to deliver solutions quickly. Make the choices that make sense for your project and don't look back.

Friday, December 14, 2007

Visual Basic.NET, #1 .NET Language?

In a recent Hanselminutes episode Scott chats with Paul Vick, Principal VB Architect, and Paul Yuknewicz, a Senior Program Manager on the VB Team about the past, present and future of Visual Basic.

During the interview they talked about a statistic which indicates Visual Basic.NET is the #1 .NET language, based on the various internally ran Microsoft surveys and analysis. This surprises me, I really expected C# to win compared to VB.NET, but perhaps it is true (though sometimes statistics can be misleading and I have not seen them with my own eyes)

The other interesting claim from the same interview is again surprising, the #2 language in .NET platform is C++, only then followed by C#.

Originally I come from a VB6 background and spent many years on the language. Even with its problems I have always been a defender of VB6 as a comparatively productive business solution platform when evaluated against other languages and tools of the same era. When .NET 1.1 came out I as many others saw VB.NET as a very different animal and learning something new like C# was very attractive. I have not regret this decision and now use C# almost exclusively. (not to say I cant code in VB.NET, I just choose not to)

With Visual Studio 2008's version of VB.NET adding in-line XML enhancement while C# stays "poor" this decision has finally started to mean a real difference based on my language decision. Overall I think its a big mistake for Microsoft to allow such a split as the true interoperability between the two languages outside of syntax (with previously minor exceptions) has been a very effective selling-point of the .NET Framework.

Now adding this statistic to the mix I really question where the competition is going between the two languages. Will there be a point when using VB.NET vs. C# means a large difference in productivity? Is VS 2008 already that time? Only time will tell.

Source Podcast

Overall it was a wonderful interview Podcast, so check it out: Visual Basic Yesterday, Today and Tomorrow with Paul Vick and Paul Yuknewicz

Monday, December 10, 2007

.NET Framework Redistributable Reference

.NET Framework Redistributable Summary

Today a good friend asked me "I downloaded the .NET 2.0 framework and this application is still asking me for the .NET 1.1 framework, doesn't 2.0 include it?"

Unfortunately the answer is no, he still needed to download the 1.1 package separately. Also I knew of no easy way to get a reference to all the latest service-packed version of .NET. Hopefully this list will be a good and helpful reference for him and others who stumble upon it.

Enjoy!

Framework Redistributables: 1.1, 2.0, 3.0 and 3.5

Below is an easy reference of all the latest service-packed run-time distributions for .NET 1.1 through 3.5. I also included the description summary from the download packages to expose what's included with each Redistributable.

.NET Framework 1.1

Download details- .NET Framework Version 1.1 Redistributable Package

The .NET Framework version 1.1 redistributable package includes everything you need to run applications developed using the .NET Framework.

.NET Framework 2.0

Download details- .NET 2.0 SP1 (x86)

Microsoft .NET Framework 2.0 Service Pack 1 provides cumulative roll-up updates for customer reported issues found after the release of Microsoft .NET Framework 2.0. In addition, this release provides security improvements, and prerequisite feature support for .NET Framework 3.0 Service Pack 1, and .NET Framework 3.5.

  • Microsoft .NET Framework 2.0 Service Pack 1 (x64)
  • Microsoft .NET Framework 2.0 Service Pack 1 (IA64)

    .NET Framework 3.0

    Microsoft .NET Framework 3.0 Service Pack 1

    Microsoft .NET Framework 3.0 Service Pack 1 provides cumulative roll-up updates for customer reported issues found after the release of Microsoft .NET Framework 3.0. In addition, this release provides security improvements, and prerequisite feature support for Microsoft .NET Framework 3.5.

    .NET Framework 3.5

    Download details- .NET Framework 3.5

    Microsoft .NET Framework 3.5 contains many new features building incrementally upon .NET Framework 2.0 and 3.0, and includes .NET Framework 2.0 service pack 1 and .NET Framework 3.0 service pack 1.

    (Finally released from BETA on 11/16/2007)