Friday, August 26, 2011

Managed vs. Unmanaged Development

Benefits of Managed Code

Managed code refers to code written for managed programming languages, such as .NET and Java. These languages provide a generalized way to handle the details of memory management and garbage collection, at the cost of a small amount of overhead. This trade-off frees you from error-prone tasks, and allows you to write more compact, readable, and error-free programs.
Historically, game developers used unmanaged code. At first, there were no managed languages. When these languages appeared, the extra cost of the managed layer was too high for games, many of which require extremely high performance, particularly in terms of graphics processing.
Today, game developers use managed code more often, because even on Windows Mobile devices, the hardware performs a great deal of the graphics processing, so the graphics code is less often the performance bottleneck. Managed code development using the .NET Mobile Framework on the Windows Mobile platform has become very popular, particularly for casual game development in which graphics performance is less important than stability.
Managed code that runs on Windows Mobile requires the Windows Mobile Class Library and the .NET Mobile Framework. Windows Mobile 6 now includes the .NET Compact Framework version 2 SP2 in ROM, in all devices.
For more information on developing for Windows Mobile using managed code, see the following topics:
For 3D graphics programming for Windows Mobile, use the Managed Direct3D Mobile library, which is part of the .NET Compact Framework 2.0.
For information on Managed Direct3D Mobile, see:
If you use an unmanaged language, such as C++, you must write extra code to manage memory and security, and clean up objects after they have served their purpose. The housekeeping details are complicated, and don't relate to the intended function of the program, so developers often neglect these tasks, ignore them, or lose track of them. As a result, unmanaged code is often more costly and time consuming to test, and it requires greater programmer training and discipline.
However, developers often prefer unmanaged code because it executes faster, allows more flexibility in the use of pointers, and gives direct control of hardware. Because of that preference, most of the documentation in this SDK targets unmanaged code.
You might choose to use an unmanaged language for Windows Mobile games for either of the following reasons:
  • Maximum speed of execution. The managed layer adds around 10% overhead to the program.
  • Maximum flexibility. Some features of some APIs are unavailable through the managed library. Using unmanaged APIs from a managed code program is possible but more difficult, and introduces its own performance issues.
  • You can create a marketable game using either approach. The main criteria for the decision are your experience and comfort level with the languages, and the performance that the application code requires. For example, managed code probably delivers the performance required for a card game, but unmanaged code is probably a better choice for a 3-D flying game.

No comments:

Post a Comment