Is the compiler of Java Bootstrapped ?
How was the first compiler of java written if it is bootstrapped ?
Many compilers for many programming languages are bootstrapped, including compilers for BASIC, ALGOL, C, C#, D, Pascal, PL/I, Haskell, Modula-2, Oberon, OCaml, Common Lisp, Scheme, Go, Java, Elixir, Rust, Python, Scala, Nim, Eiffel, TypeScript, Vala, Zig and more.
Bootstrapping is used to produce a self-hosting compiler. Self-hosting compiler is a type of compiler that can compile its own source code. Bootstrap compiler is used to compile the compiler and then you can use this compiled compiler to compile everything else as well as future versions of itself.
It is an approach for making a self-compiling compiler that is a compiler written in the source programming language that it determine to compile. A bootstrap compiler can compile the compiler and thus you can use this compiled compiler to compile everything else and the future versions of itself.
Java compilers include the Java Programming Language Compiler (javac), the GNU Compiler for Java (GCJ), the Eclipse Compiler for Java (ECJ) and Jikes. Programmers typically write language statements in a given programming language one line at a time using a code editor or an integrated development environment (IDE).
It's an interesting question. The current javac
compiler from Oracle, which is only one compiler of many (1), is actually written in Java which means, yes, you could consider it bootstrapped, assuming your definition means "has been bootstrapped so that it can now compile itself" (2).
The virtual machine itself is written mostly in C++ from memory so, while the compiler is bootstrapped, building the JRE requires a C++ compiler.
(1) GCJ is another one, and it happens to be written in C, so it depends on which compiler you're referring to.
(2) The single word "bootstapped" in your question could be taken in a number of ways. If your definition of "bootstrapped" means "has to be bootstrapped to get a working compiler", then the answer is no.
As to how the first Java compiler was written before bootstrapping, that remains lost in the mists of time (or the minds of Gosling et al).
Given that a compiler can be written relatively easily without any of the fancy OO concepts, my guess would be that they simply wrote the first one (or few) in C or C++.
That seems borne out by this entry from the Wayback Machine:
The team's efforts kicked off the development of a new object-oriented programming language that Gosling called Oak, after the tree outside his window. Loosely based on C++, the language was stripped down to a bare minimum in order to be compatible with the limited space the chips in handheld devices would offer, and was designed to allow programmers to more easily support dynamic, changeable hardware.
and, later:
Arthur van Hoff wrote an Oak compiler entirely in Oak instead of in C. Naughton and Jonathan Payne built an Oak-ready browser called "WebRunner." The first applet -- Duke waving back at his parents over the Internet -- was born.
In addition, from Patrick Naughton's epilogue in his book "The java Handbook" (my bold):
Now that we had a plan of record, to ship Oak in source form on the net, things got much more productive. We started focusing on fixing all of the loose ends in the language. Jonathan Payne was working on optimizing the interpreter. Arthur van Hoff rewrote the compiler in Oak itself, replacing the C version that James originally wrote. This was also a good test of the environment since this compiler was the largest single Oak program ever written. A fair number of burned out engineers were using this time as paid vacation by Sun, but for the most part the core team ignored them and got back to work.
So, it looks like the original version of the "Java" (Oak) compiler was written in C, then bootstrapped from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With