Skip to main content
GameDev.net gamedev.net
🔒 Locked

Managed programming...?

Started by xissburg Jan 21, 2007 at 8:46 AM 6 replies 1.2k views
Original Post
xissburg
xissburg
I think this is a very stupid question! sorry :P but, I wanna know what managed programming(managed DirectX for example) really is. What is the difference between managed and non-managed( = native?)?! Thanks ;)
.
Silver Phoenix
Silver Phoenix
Managed programming (more accurately, managed programming language) is a type of programming where dynamically allocated memory is managed by the program or framework instead of the programmer.

For example, Java and C# are managed programming languages. The programmer does not need to explicitly allocate memory. It is done implicitly by the keyword new. The programmer also does not need to deallocate/delete the memory. A garbage collector finds unused memory and deletes it.

A non-managed language (or native language) requires the programmer to indicate when to allocate and delete memory.

For example, C and C++ need to be explicitly told when to allocate memory (C uses malloc while C++ uses new, which uses malloc transparently) and when to deallocate memory (C uses free and C++ uses delete).
My passive agressiveness can be so devastating. - Alanis Morissette, "Everything"
xissburg
xissburg
Oh!now I see....I'm a Java and C++ stupid programmer and I have already seen this diference between them, and I thought: Is this managed programming?!?...Now I know the answer for this question(but, is this the only difference?!). And...what about performance? is there any difference between managed and native?!?

Thanks ;)
.
CTar
CTar
There are many different definitions of managed code. In Windows-only environments managed code is often defined to be the code which is executed by the .NET Framework or a port of it (Mono or DotGNU). According to that definition Java bytecode is not managed. Another just as, if not more, popular is that managed code is any code interpreted. The managed part doesn't come from memory management, it comes from the fact that the code is managed by an environment completely controlling the code which can help allocate memory, enforce (security) policies, etc.

Quote:
Managed programming (more accurately, managed programming language) is a type of programming where dynamically allocated memory is managed by the program or framework instead of the programmer.

So Managed C++ isn't managed? Its name sure seems to suggest it's.

Quote:
And...what about performance? is there any difference between managed and native?!?

Of course there is, but whether it's faster or slower depends on the circumstances. Garbage collection often (but not always) beat ordinary native memory allocation, but it can have certain disadvantages. For instance it group deallocations together and it can cause problems for real-time applications.
Promit
Promit
Managed code usually refers to code running on a .NET-compatible framework. It's occasionally used to refer to other similar forms of runtime, such as Java.

I don't know of a good all-encompassing term for environments like Java, .NET, Ruby, Python, etc. But these are generally considered "managed" and tend to show certain characteristics:
* The code is either interpreted or bytecode compiled and JITted.
* Highly portable, much more so than C or C++.
* Memory deallocation is usually automatic. Allocation usually isn't.
* There may be protection mechanisms for security. These mechanisms vary widely.
* Extremely large support class libraries included, which gives you a massive set of tools without any effort on your part.
* Widely varying performance characteristics, depending on what you're doing. I've seen Python programs that run faster than their C++ equivalents.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Silver Phoenix
Silver Phoenix
Quote:
Original post by CTar

Quote:
Managed programming (more accurately, managed programming language) is a type of programming where dynamically allocated memory is managed by the program or framework instead of the programmer.

So Managed C++ isn't managed? Its name sure seems to suggest it's.


Without wanting to start a war on this, Managed C++ has the ability to run managed and native code side by side. So, Managed C++ is a managed programming language if the programmer uses its extensions. If the extensions aren't used then we are programming in plain C++.
My passive agressiveness can be so devastating. - Alanis Morissette, "Everything"
cobru
cobru
And I thought "managed programming" means programming with a manager looking over your sholder... ;)

Q: How many programmers does it take to write a nice piece of software?A: MORE.
gharen
gharen
Just a note: even with managed code, there are situations where you have to do some deallocation yourself. A good example would be using a .Net library that wraps a native library, like Managed DirectX does. In this case you still need to call the object's Dispose method so the unmanaged resources used by the object are deallocated. The garbage collector only disposes managed resources, and has no knowledge of the underlying unmanaged resources.

So, if you're not carefull to call Dispose when you're done, your .net graphics code can be just as leaky as the equivalent c/c++ code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.