locked
Managed vs. Unmanaged code - please assplain

    Question

  • i'm reading a lot of talk about managed vs. unmanaged code.  i've tried to understand the difference on my own, but Wikipedia writers aren't known for stating things simply :)

    i come from a Flash background.  What is Flash Actionscript?  Managed or unmanaged?  Or neither?  Or both?

    Can anyone explain the managed vs. unmanaged debate?  What are the points for and against each?  And why might i care?

    Thanks,

    -MrSock

    Tuesday, August 29, 2006 10:40 PM

Answers

  • Managed code is code that runs thorugh a runtime.  Essentially, it is a software layer that the application communicates with so that many functions that all programs should have are automatically done for you.  Some of these functions are garbage collecting and exception handling.  Garbage collecting is the cleanup and disposal of objects that are no longer used by your application.  In essence, your RAM is freed up automatically.  Basic Exception Handling is also controlled by the runtime.  Instead of a program just completely crashing and closing down without any kind of feedback, the runtime is able to notify that an error has occurred.  It is still up to you as the programmer to do something with that error, but if you choose not to handle it, the runtime doesn't necessarily just completely fail.  Popular managed code environments are Java (runs through the Java Runtime environment) and any of the .NET languages (which run through the .NET framework).

    Unmanaged code requires that the programmer write many of these common functions that the runtime handles.  Essentially, unmanaged code talks directly to the hardware.  So things like garbage collecting, etc., need to be written explicitly.

    Managed code allows programmers to focus on functionality of their application while not having to worry about the state of the hardware.
    Tuesday, August 29, 2006 11:10 PM

All replies

  • Flash is closer to managed code, it does not run directly on the hardware it runs in a software layer.

     

    The whole debate about Managed vs. Unmanaged is about speed, in the past and still now unmanaged code runs faster, however unmanaged code is closing the gap on performance speed.

     

    Managed code does have the edge in development ease and time.

    Tuesday, August 29, 2006 10:48 PM
  • Managed code is code that runs thorugh a runtime.  Essentially, it is a software layer that the application communicates with so that many functions that all programs should have are automatically done for you.  Some of these functions are garbage collecting and exception handling.  Garbage collecting is the cleanup and disposal of objects that are no longer used by your application.  In essence, your RAM is freed up automatically.  Basic Exception Handling is also controlled by the runtime.  Instead of a program just completely crashing and closing down without any kind of feedback, the runtime is able to notify that an error has occurred.  It is still up to you as the programmer to do something with that error, but if you choose not to handle it, the runtime doesn't necessarily just completely fail.  Popular managed code environments are Java (runs through the Java Runtime environment) and any of the .NET languages (which run through the .NET framework).

    Unmanaged code requires that the programmer write many of these common functions that the runtime handles.  Essentially, unmanaged code talks directly to the hardware.  So things like garbage collecting, etc., need to be written explicitly.

    Managed code allows programmers to focus on functionality of their application while not having to worry about the state of the hardware.
    Tuesday, August 29, 2006 11:10 PM
  • Thanks for the succinct answers, fellas.

    i've also caught the terms "safe" and "unsafe" code - are they synonymous with "managed" and "unmanaged" ?

    When people on this forum enter debate mode, garbage collecting seems to be one of the issues that comes up time and again.  Why?

    It sounds like Flash Actionscript, for the purposes of my understanding, is managed code.  Actually, it'd be really handy for me to understand the Flash equivalent of a bunch of these terms i'm hearing (but that'll only work if people here know Flash).  i mean, i have a feeling people are talking about stuff i understand, but they're using different terminology.

    What, for example, are the Flash equivalents of "pipeline" and "framework" ? 

    - MrSock

    Tuesday, August 29, 2006 11:18 PM
  • Unsafe code is a .NET feature which lets you temporarily step outside the usual limitations of the managed language, while still being able to program in C#. Inside an unsafe code block, you can write C# code that has raw access to hardware memory, bypassing the usual type safety features of the language. This can occassionally be useful for optimizing low level code, as it makes C# work a bit more like native languages such as C++, but only tends to be used in a minute fraction of C# programs.

    Java and Flash don't have any equivalent of unsafe as far as I know.

    I'll leave it for someone who knows more Flash than I do to try to explain "pipeline" and "framework" :-)
    Tuesday, August 29, 2006 11:36 PM
  •  I'm not sure if there is a parallel to the pipeline, but the the Framework in ActionScript would be the various pre-defined functions that you can call within individual frames (onclick, goto, etc). The Framework is just the underlying structure of the language/programming environment.

    ... If the pipeline is anything in Flash, it is where you import files into a library and then place those in a scene.

    Wednesday, August 30, 2006 3:15 AM