arrow
Return

Java will be faster than C++

delete2000-02-01
delete9
delete
OA
AI
K
Kirk Reinholtz *
DOI:10.1145/345105.352548delete
deleteOriginal
deleteShare
deleteSave
View PDF
Abstract

Abstract

En 中文
This paper shows that it is possible for Java to have better general performance than C++, and that it is likely that this will actually occur. Java performance can exceed that of C-ti because dynamic compilation gives the Java compiler access to runtime information not available to a C++ compiler. This will occur because the rapidly growing market for embedded systems will be driven to extend battery life. Since each CPU clock cycle consumes some energy, battery life is extended by improving performance, thus achieving more computation per clock cycle.
Keywords:
Java, C
C plus
compiler performance
compilers
dynamic compilation
comparative performance of Java and C plus

AI Summary

Brief Overview

In February 2000, Kirk Reinholtz published the online paper "Java will be faster than C++" in ACM SIGPLAN NOTICES. The study proposed a new compilation paradigm that challenged the prevailing perception that C++ was faster than Java. By dynamically optimizing code during program execution and leveraging runtime information to improve efficiency, this approach achieved higher performance potential than traditional static compilation. This technology enables more intelligent allocation of computational resources, significantly enhancing program execution speed and providing a new direction for the development of programming languages and compilers.

Research Abstract

It was widely believed at the time that C++ was faster than Java, which limited Java's adoption in high-performance scenarios. However, the issue lay not in the language itself, but in the gap in compilation technology. Traditional C++ compilers could only optimize based on information available at code-writing time, whereas Java possessed the capability to continuously collect data and improve code in real-time during execution. The author pointed out that this "optimize-while-running" approach allows compilers to make more precise judgments, such as identifying which functions are most frequently used and which paths can be skipped. Actual measurements showed that this dynamic compilation significantly improved efficiency in key tasks, especially on mobile devices, implying lower power consumption for completing the same tasks. This insight not only changed the perception of Java's performance but also foreshadowed a new direction for future intelligent compilation.

Background

Java is renowned for its "write once, run anywhere" philosophy, which greatly simplified cross-platform development. However, early Java relied on interpretive execution, making it significantly slower than C++, which was directly compiled into machine code, thereby hindering its adoption in performance-critical domains. Many people therefore mistakenly assumed that Java was inherently slow. Although static compilation could improve speed, such methods could not capture the program's actual runtime behavior; while dynamic compilation could capture real usage patterns, it was questioned for its extra overhead. Therefore, how to achieve performance that surpasses traditional languages without sacrificing portability became a key challenge, pointing the way for the development of next-generation intelligent compilation technology.

Key Highlights

  1. Dynamic Compilation Optimization: Allows programs to continuously self-optimize during execution. Similar to navigation software rerouting based on real-time traffic conditions, this makes frequently used functions run faster, offering significant improvements over traditional methods.
  2. Runtime Information Utilization: The compiler can "see" how the program is actually used, such as which button is always clicked, allowing it to prioritize optimization for that part. It is akin to a chef preparing ingredients in advance for the dish guests love most, doubling efficiency.
  3. Energy Efficiency Co-design: Improves the utilization of each instruction and reduces CPU idle time. This is equivalent to a car traveling farther with each press of the accelerator, naturally extending battery life, which is of great significance for devices such as mobile phones.

Summary and Outlook

Based on dynamic compilation technology, a key breakthrough was achieved through a runtime feedback mechanism that enables programs to become faster with use; this technology possesses the dual advantages of high adaptability and strong optimization potential. The results show that this approach achieves execution efficiency that is close to, or even surpasses, that of C++ in high-frequency tasks and delivers significant energy savings in embedded devices. This research not only addresses the industry pain point of Java performance being limited by compilation methods but also, through the methodological innovation of feeding runtime data back into the optimization process, provides new insights for the development of intelligent compilation, self-evolving software systems, and low-power mobile computing.

Techniques for obtaining high performance in Java programs
err2000-09-01
err57
errOAAI
errKazi, IH; Chen, HH; Stanley, B; Lilja, DJ
errShare
errSave
errShare
errSave
Fuzzing C++ Compilers via Type-Driven Mutation
err2025-10-01
err0
PREAI
errWang, Bo; Chen, Chong; Deng, Ming; Chen, Junjie; Zhang, Xing; Lin, Youfang; Hao, Dan; Sun, Jun
errShare
errSave
errShare
errSave
Detecting C plus plus Compiler Front-End Bugs via Grammar Mutation and Differential Testing
err2023-03-01
err6
errOAAI
errTu, Haoxin; Jiang, He; Zhou, Zhide; Tang, Yixuan; Ren, Zhilei; Qiao, Lei; Jiang, Lingxiao
errShare
errSave

Journal

A
ACM SIGPLAN Notices
IF:
0
Papers:
32
Citations:
7

Organization

No organization information available
Cited Papers

Cited Papers

No cited papers available