Runtime
Runtime
The environment in which a program runs. Examples include Node.js (JavaScript), the JVM (Java), and the Python interpreter.
Runtime
The environment in which a program runs. Examples include Node.js (JavaScript), the JVM (Java), and the Python interpreter.
Runtime refers to the point at which a program is executed and the environment that supports that execution. In contrast to compile time (the point at which code is written/transformed), it refers to the state in which a program is loaded into memory and actually running.
The runtime environment provides services required for program execution, such as memory management, type checking, garbage collection, and exception handling. Node.js is a runtime that allows JavaScript to be executed outside the browser, and the JVM is a runtime that executes Java bytecode.
A runtime error is an error that occurs while a program is running and is not detected at compile time. Typical examples include division by zero, null references, and array index out of bounds. Dynamically typed languages perform many checks at runtime, so runtime errors may be more frequent.
Recently, new JavaScript runtimes such as Deno and Bun have emerged, offering features such as faster execution speed, improved security, and native TypeScript support.
// Node.js 런타임 정보 확인
console.log('Node.js 버전:', process.version);
console.log('플랫폼:', process.platform);
console.log('아키텍처:', process.arch);
console.log('메모리 사용량:', process.memoryUsage());
// 런타임 에러 예시
function divideNumbers(a, b) {
if (b === 0) {
throw new Error('런타임 에러: 0으로 나눌 수 없습니다');
}
return a / b;
}
// 런타임 환경 감지
function detectRuntime() {
if (typeof window !== 'undefined') {
return '브라우저';
} else if (typeof process !== 'undefined' && process.versions.node) {
return 'Node.js';
} else if (typeof Deno !== 'undefined') {
return 'Deno';
} else if (typeof Bun !== 'undefined') {
return 'Bun';
}
return '알 수 없음';
}
console.log('현재 런타임:', detectRuntime());
// 런타임에 모듈 동적 로드
async function loadModule(moduleName) {
const module = await import(moduleName);
return module;
}
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free