仮想マシン - Virtual Machine

Virtual Machine

A virtual machine (VM) is a software-based simulation of a physical computer. It provides an isolated environment where programs can run as if they were on a real machine. In programming, VMs are commonly used to execute intermediate code that is platform-independent.

For example, Java code is compiled into bytecode, which runs on the Java Virtual Machine (JVM). Similarly, C# code is compiled into Common Intermediate Language (CIL), which runs on the .NET Common Language Runtime (CLR). These virtual machines interpret or compile intermediate code into native machine instructions during execution.

The main advantages of virtual machines include cross-platform compatibility, security, and controlled execution environments. However, running code through a VM may introduce performance overhead compared to direct execution on native hardware.

仮想マシン

仮想マシン(Virtual Machine, VM)とは、物理的なコンピュータをソフトウェアで再現したものです。実際のマシンのように振る舞う仮想的な環境で、プログラムを安全かつ独立して実行できます。プログラミングにおいては、プラットフォームに依存しない中間コードを実行する目的で広く利用されています。

たとえば、Javaのコードはまずバイトコードにコンパイルされ、それを**JVM(Java仮想マシン)**が実行します。**C#**のコードも同様に、**CIL(共通中間言語)に変換され、.NETのCLR(共通言語ランタイム)**上で動作します。これらの仮想マシンは、中間コードを実行時に機械語に変換しながら処理します。

仮想マシンの主な利点は、クロスプラットフォーム対応セキュリティの確保実行環境の制御のしやすさです。一方で、仮想的なレイヤーを挟むため、ネイティブ実行に比べてパフォーマンスがやや低下することがあります。

重要表現

Virtual Machine (VM)
仮想マシン
物理コンピュータをソフトウェア上で模倣する技術。中間コードを解釈・実行する役割を持つ。

Bytecode
バイトコード
Javaなどの言語でコンパイル後に生成される中間形式のコード。仮想マシンによって実行される。

Intermediate Code
中間コード
ネイティブな機械語ではなく、複数のプラットフォームで使える中間的な命令セット。VMを使うことで動作可能となる。

JVM / CLR
Java仮想マシン / 共通言語ランタイム
それぞれJavaとC#の中間コードを実行するための仮想マシン。クロスプラットフォームや安全性を実現するための基盤。

Cross-Platform
クロスプラットフォーム
異なるOSやデバイス間で同じコードを動作させる概念。仮想マシンを用いることでこの柔軟性が得られる。

関連用語