↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Why Managed Code Is Safer

Managed code became common in the late 1990s with Java and later .NET. The page contrasts it with unmanaged code, which runs machine code directly and is used where close-to-the-metal performance matters. Managed code targets a virtual machine, which translates the intermediate code and adds safety checks.

Reading notes
#

  • Unmanaged code runs directly as machine code and is typical of compiled programs in languages such as C, C++, Visual Basic, and Delphi/Pascal.
  • It is described as closer to the metal, useful for drivers, embedded code, and games, and it can have a very small footprint because it does not need a full framework.
  • Managed code is compiled to intermediate code for a virtual machine, as in Java bytecode and .NET IL assemblies.
  • The VM converts the intermediate code into native code or interprets it, which can add slight startup delay.
  • Managed code is presented as safer because the runtime checks it and prevents the machine from crashing.
  • The VM can provide garbage collection, so programmers do not have to write memory management code to free allocated blocks.
  • Virtual machines such as HotSpot can monitor performance and apply optimizations while the program runs.
  • Managed code also benefits from large frameworks, which centralize many classes and reduce dependency juggling across libraries.
  • The page says the tradeoff is a small performance cost in exchange for extra safety.
  • Managed languages for the same platform share built-in libraries, which reduces reinvention for common features such as string manipulation and networking.