• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

how was java written?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgive me for perhaps a stupid question, but what language was java written in?
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean to say in what language is the java compiler written in?
probably C/C++.
[ March 15, 2005: Message edited by: Tanveer Rameez ]
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sun's JVMs are written in C/C++ and a little assembly.

The Java compiler that ships with the JDK is written in ... Java! This has been the case since the very first release.

Writing a compiler for a language "A" in the language itself is a very common procedure known as "bootstrapping." First, you have to write a compiler "C1" for at least a subset of language "A" in some other language "B". Now you have to write, in this subset, a compiler "C2" for a (generally larger) subset. Compile C2 using C1, and now you've got a compiler for language C2 which is, itself, written in C2. You can now compile C2 with itself! More interesting, of course, is to write a compiler for an even larger subset, C3, and compile it with the C2 compiler. Eventually, in a small number of passes, you get a complete compiler for "A" written in "A". Cool!
 
Michael Beck
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply. Sounds interesting, though I don't full understand it. Could you recommend a good resource to learn more about this?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, here's the first Google hit for "bootstrapping compiler." It's a neat little article.
 
lowercase baba
Posts: 13073
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember, a compiler is itself a program. it parses a text file, enforces some grammer, and converts it to some other kind of file. You can write a compiler FOR any language IN any language. The trick here is how you get started.

A simple, contrived, (and probably not very good) example would be a made-up language that does arithmetic, call the language EasyMath.

EasyMath is a language that supports addition, subtraction and multiplication.

on your first pass, you write a complier using Java, for example. All this compiler handles is addition and inverting a bit pattern. you now have a compiler that can handle any EasyMath program, as long as it ONLY has addition or bit inversion in it.

ok, so now what? well, subtraction can be defined in terms of addition. you negate the number and add. How do you negate a number? invert the bits and add 1. AHA!!! my first compiler can handle that. Multiplication can also be defined in terms of addition. my first compiler can handle that.

so, now i write a compiler, in EasyMath, that converts multiplication and subtraction into addition problems. i run THAT through my first compiler, and create a NEW compiler.

i now have a compiler, written in EasyMath, that can compile any EasyMath program.

does that make more sense?
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic