Coffeehouse Thread

14 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Can someone explain Managed Code in layman's terms?

Back to Forum: Coffeehouse
  • User profile image
    dpen2000

    People round here keep on talking about managed code. But I don't know what it is. Or why it's so important.
    My programming experience is limited to VB but since there is vb.net I guess this is applicable to VB.

    DP

  • User profile image
    Jeremy W

    Sure Smiley

    First, you may want to have a gander at this .NET Rocks show (which covers Managed Code): http://msdn.microsoft.com/theshow/Episode035/default.asp

    Managed Code is, in layman's terms, code that is not defined solely by itself. There are other forces, tools and checks that happen around that code.

    If you think back to old C and C++ days, you were having to, for instance, manage any physical memory you wanted to use (if you wanted to declare a variable).

    With Managed Code you don't. You declare a variable and it's taken care of.

    In the "old days" you also had to destroy the variable to free up the memory.

    With Managed Code you don't. It cleans up after itself.

    This is a fairly simple example, and really doesn't do it justice, but at it's core Managed Code is more than the sum of it's parts (or itself). When you compile or execute it you're drawing on a whole suite of other tools which make the programmer's (and the user's) life easier by handling the "simple things" (though they are often not simple at all).

    I hope that helps.

    If you weren't a developer I'd have given you an airplane example, or a car example to illustrate how Managed Code is a lot like "powered" systems (power brakes, autopilot, sensors).

    Thankfully you are.

    Let me know if that's not good enough, and I'm sure some other C9'ers will chirp in with other interpretations soon!

  • User profile image
    Jeremy W

    Oop, after writing the above I found this: http://blogs.msdn.com/brada/archive/2004/01/09/48925.aspx

    It's a bit more technical, but might help as well Smiley

  • User profile image
    ktegels

    dpen2000 wrote:
    People round here keep on talking about managed code. But I don't know what it is. Or why it's so important.
    My programming experience is limited to VB but since there is vb.net I guess this is applicable to VB.

    DP


    If you've beenw writin VB, then you've been -- in a sense -- writing managed code the whole time. Managed code is what unmanaged code isn't. In VB6, you rarely had to worry about freeing up any memory or other resources because the "run time" for VB took care of such issues for you. C++ programmers, on the other hand, had to explicitly "manage" the resources they used like sockets, blocks of memory and so on. In a managed code environment like .NET, the run time takes care of all that work for you.

    In current usage, "managed code" means programs running in the .NET CLR that are taking advantage of its resource management schema.

    That doesn't mean you are totally off the hook for resource management howerver. There's still some best practices you need to engage in when coding. If a class offers a dispose method, you should call it as soon as you are sure you're done with the instance to free up any system resources it may have tied up waiting for the Garbage collector to come along and make rid of them.

    Before you start fretting much about all of this, go make friends with FxCop. It will help you avoid the few really dumb things you might do otherwise (at least, it does for me... <grin />)

  • User profile image
    dpen2000

    Okay then. Why vb.net? why not vb 7? What does .net contribute to visual basic now? And maybe more importantly, am I going to find coding in visual basic .net easier than coding in visual basic 5 or 6(I never did upgrade to 6)?

    DP

  • User profile image
    Jeremy W

    Because there are a whole whack of changes, most of which are in relation to it now being a part of the .NET Framework, which is a fairl huge change in and of itself.

    Also, because at the time everything was new, and needed to be differentiated, hence the addition of ".NET" to everything which was .NET enabled. Future versions will drop this (I'm told).

  • User profile image
    ktegels

    dpen2000 wrote:
    Okay then. Why vb.net? why not vb 7? What does .net contribute to visual basic now? And maybe more importantly, am I going to find coding in visual basic .net easier than coding in visual basic 5 or 6(I never did upgrade to 6)?

    DP


    VB as was based on COM and was just kludged enough that it didn't make sense for it to migrate as was to the CLR. VB as was didn't support the essential "OO" concepts MS feels languages need today.

    My guess is, DP, the first month or so with VB.NET will seem really harsh because there's not many good entry points for you. Yes, learning how to write in the same mindset of VB.OLD is possible, but the real benefit of VB.NET is taking full advantage of the framework. Within six months you wonder why you waited so long. Smiley

    Again, I don't want to sound like a Homer here, but I really wish the Sells and Gehtland book would have been out when I first wanted to learn VB.NET. Its just about perfect, IHMO. But, since I was was such an early adopter, I had the Hollis/Lohtka book. That was a great book too, but its total irrelevant now.

  • User profile image
    Michael Elsdoerfer

    First, you may want to have a gander at this .NET Rocks show (which covers Managed Code): http://msdn.microsoft.com/theshow/Episode035/default.asp

    Actually this is not .NET Rocks, but only a .NET show (but still rocking Wink.

  • User profile image
    chuawenching

    Garbage Truck comes to your home and collect garbages for you automatically while you are asleep early in the morning. Smiley

  • User profile image
    SMac

    lol -- I never knew there was an actual garbage truck -- I just put it out at night and like magic it's gone the next morning... wow... I guess that solves that mystery..

    now you're going to tell me something like santa clause doesn't exist or something..

  • User profile image
    OldManCoyote

    Managed code.  Another name of cleaning up for sloppy development practices by junior developers.  The managed C++, the new secured C run times and MSIL.  Good C++ development practices have been doing for years what the three above are starting to do.

  • User profile image
    jj5

    chuawenching wrote:
    Garbage Truck comes to your home and collect garbages for you automatically while you are asleep early in the morning. Smiley


    Haha. Perhaps. But us programmers still need to take out the trash.. (or stop referencing it, as it were)

    John.

  • User profile image
    chuawenching

    Well layman terms right? Haha! Hmm.. let me think again.

    I define:

    Unmanaged - Blue Collar - work hard, tiring job, working in the hot sun. 

    Managed - White Collar - office work, easy and clean, working in the air conditioner room.

    Hehe!

  • User profile image
    caspre

    I LOVE managed code!

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.