• 참고 사이트

    • AOT
      • https://en.wikipedia.org/wiki/Ahead-of-time_compilation
    • JIT
      • https://en.wikipedia.org/wiki/Just-in-time_compilation
    • Flutter Dart
      • https://dart.dev/overview
    • React Native Hermes
      • https://reactnative.dev/docs/hermes
  • JIT (Just In Time)

    • 런타임 환경에서 바이트 코드를 네이티브 코드(머신 코드)로 변환한다.
    • 네이티브 코드는 캐시에 저장해 재사용함으로써 성능을 끌어올린다.
      • 동일한 바이트 코드를 마주쳤을 때, 변환 과정을 거치지 않고 캐시에 저장된 결과를 재사용한다.
  • AOT (Ahead Of Time)

    • 프로그램 실행 전에 소스 코드를 네이티브 코드로 변환한다.
      • … compiling a higher-level programming language such as C or C++, or an intermediate representation such as Java bytecode or Common Intermediate Language (CIL) code, into native machine code so that the resulting binary file can execute natively…
    • 네이티브 코드로의 변환이 사전이 이뤄지는지 여부에 따라 AOT와 JIT가 갈린다.
      • When being used in this context, it is often seen as an opposite of just-in-time (JIT) compiling.
  • 플랫폼 별 컴바일 기법

    • Android
      • 앱 설치 시점에 AOT가 적용되지만 내부적으로는 JIT 컴파일과 AOT 컴파일을 모두 사용한다.
        • 최초 설치 시에는 JIT 을 함께 사용하여 설치 속도를 높이고, 런타임 환경에서 컴파일을 조금씩 해두기 때문.
        • https://www.reddit.com/r/androiddev/comments/1dtlym9/why_does_android_use_jit_and_aot/
        • JIT inject and compil at runtime because that's the only way it can work effectively on multiplatform. AoT is usable only when you know your target.
    • iOS
      • 앱이 빌드되는 시점에서 AOT 컴파일이 이뤄진다.
    • Flutter
      • 네이티브 영역은 Android, iOS와 동일하다.
      • Dart의 경우, 빌드 환경에 따라 JIT 혹은 AOT가 적용된다.
      • Debug 모드에서는 코드를 수정하는 즉시 앱에 반영(Hot Reload)하도록 하기 위해 JIT 컴파일을 사용한다.
        • During development, a fast developer cycle is critical for iteration. The Dart VM offers a just-in-time compiler (JIT) with incremental recompilation (enabling hot reload), live metrics collections (powering DevTools), and rich debugging support.
      • Release 모드에서는 네이티브 성능을 발휘하기 위해 AOT 컴파일을 사용한다.
        • When apps are ready to be deployed to production—whether you're publishing to an app store or deploying to a production backend—the Dart ahead-of-time (AOT) compiler can compile to native ARM or x64 machine code. Your AOT-compiled app launches with consistent, short startup time.
    • RN
      • 네이티브 영역은 Android, iOS와 동일하다.
      • JavaScript의 경우, JSC를 사용하던 시절에는 JIT 컴파일을 적용했으나 현재는 많은 변화가 이뤄졌다.
      • Hermes 도입 이후 바이트 코드 생성 과정이 추가되었다.
        • 패키징 시점에 JavaScript 코드를 바이트 코드인 .hbc로 변환한다.
        • 이후 hermes 엔진에서 바이트 코드를 JIT 방식으로 읽는다.
        • 네이티브 코드로 바로 변환하면 되는 것 아닌가?
          • JavaScript가 지닌 동적 언어로서의 특징 때문에 빌드 시점에서 네이티브 코드로 변환하는 것이 쉽지 않다.
          • 변수가 런타임에 다양한 타입의 값을 할당받거나, 객체의 구조가 변경되는 등
        • (일부 블로그에서는 hermes 바이트 코드의 변환하는 과정을 AOT라고 표현한다.)
          • 런타임 이전에 변환이 이뤄진다는 관점에서 본다면 틀린말은 아니다.
          • 런타임 이전에 변환이 이뤄진다는 관점에서 본다면 틀린말은 아니지만, Android의 바이트코드 생성 과정을 AOT라고 하지 않듯이 범용적인 관점에서 쓸만한 표현은 아닌 듯하다.
          • hermes를 소개하는 공식문서에서도 AOT라는 표현을 사용하지 않고 있음
      • Static Hermes 도입 이후, 네이티브 컴파일을 지원할 예정이다.
        • 정적 타입 언어인 TypeScript을 사용해 빌드 시점에서 네이티브 코드로의 변환을 지원할 예정
        • TypeScript는 다음과 같은 장점을 지닌다.
          • 명시적 interface를 사용해 객체의 구조 변경 방지
          • const를 사용해 값의 재할당 방지
          • 정적 타입 체크를 통해 컴파일 과정에서 오류 추적