How do we define the implementation language?

M

Matt

For example, we want to produce a new language called NewLang. When we
implement
the compiler of NewLang, we should use languages other than NewLang.
Correct?

But I heard Java is implemented in C/C++. More specifically, does it
mean
the Java compiler is written in C/C++? But the Java API is written in
Java itself.
This is the confusing part.

How about C++? I always heard people saying C++ is written in C++
itself. I think it
means C++ libaries are written in C++. But C++ compiler is written in
pure C.
Is that correct?

My conclusion is that a language's compiler should be written in
another language.
But a language's libraries can be written in its own language. Then it
makes the
implementation language definition little bit tricky.

Please advise and discuss. thanks!!
 
P

Phlip

Matt said:
For example, we want to produce a new language called NewLang. When we
implement
the compiler of NewLang, we should use languages other than NewLang.
Correct?

You ask how to bootstrap a language into existence.

For example, Pascal was notoriously implemented by writing the source for a
Pascal compiler (probably on a typewriter;), and then reading the source and
pretending to apply it to itself. The output then goes into a real Assembler
program to produce the ultimate machine opcodes.

A compiled language, such as a C-style language, typically bootstraps from a
previous language. Then it's used to compile itself, and this vets its
capacities. Small-C can bootstrap like that.
But I heard Java is implemented in C/C++. More specifically, does it
mean
the Java compiler is written in C/C++? But the Java API is written in
Java itself.
This is the confusing part.

Most languages are implemented in K&R C, to maximize portability. That means
they are implemented in a sufficiently narrow subset of ISO-C that one can
compile them with very old (obsolete) K&R C compilers.

Ruby and Python are both brilliant examples of interpreted OO scripting
languages that port to a wide range of platforms. One can write Ruby
expressions directly in C, using a VALUE type and a handful of support
functions.

(Perl, by contrast, _requires_ brilliance to use...;)

All these languages come with complete libraries (up to things like HTTP
protocol, built-in databases, etc.), mostly written in their own language.
How about C++? I always heard people saying C++ is written in C++
itself. I think it
means C++ libaries are written in C++. But C++ compiler is written in
pure C.
Is that correct?

Depends on the vendor. I suspect GNU C++ is written in K&R C.
My conclusion is that a language's compiler should be written in
another language.
But a language's libraries can be written in its own language.

Well, the exception might be Visual Basic ;-)

Its libraries are overwhelmingly _not_ written in VB. That should tell us
something about the language's quality.
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

Matt said:
For example, we want to produce a new language called NewLang. When we
implement
the compiler of NewLang, we should use languages other than NewLang.
Correct?
In the very first implementation, you have to do that, for obvious reasons.
But I heard Java is implemented in C/C++. More specifically, does it
mean
the Java compiler is written in C/C++? But the Java API is written in
Java itself.
This is the confusing part.
There are atleast 2 types of languages, those that are compiled to
machine/hardware language, and those that are not. C++ is typically
compiled to "native" hardware language, while java run within a
virtual machine. Now a virtual machine needs to be written in something
that will run on actual hardware, C/C++ are suitable for that.
(And yes, you can very well run C++ within a virtual machine/interpreter
and you can make hardware that executes java bytecode directly, the
reverse is what the respective languages were designed for though.)
How about C++? I always heard people saying C++ is written in C++
itself. I think it
means C++ libaries are written in C++. But C++ compiler is written in
pure C.
Is that correct?
Yes and no. C++ compilers are usually written in C or C++. The standard
library is written in C++ usually, it makes more sense...
My conclusion is that a language's compiler should be written in
another language.
Why's that ? It will usually be dictated by wether your language is
meant/designed to run on actual existing hardware I'd say.
But a language's libraries can be written in its own language. Then it
makes the
implementation language definition little bit tricky.
Writing libraries in its own language is often favorable, since other
languages might have trouble interacting with the new one. Note that
many languages (e.g. perl,python, and even java) have parts of their
libraries written in C or C++, often for sake of speed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,965
Members
47,512
Latest member
FinleyNick

Latest Threads

Top