Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a programming language be "implemented"?

maybe this is just a little misunderstanding but how can a programming language be implemented?

I'm not talking about how to implement my own programming language but about the word "implemented"? I mean, you can implement a compiler or an interpreter, but a programming language?

What does it mean if I read "C++ is implemented in C" or "Python was implemented in C"?

I think a language is more sth. like a protocol of how someone thinks about things should be implemented. For example, if he wants do display a messagebox he can say the command for this is ShowMessageBox(string) and implement a compiler who will translate this into something that works on a computer (aside from the selected programming paradigms he imagines).

I think this question leads to the question "what is a programming language in reality"? A compiler, an interpreter or just a documented language standard about how things should be implemented in a language?

[EDIT]

Answer: Languages are never implemented, only compilers/interpreters etc. It's this simple.

like image 845
Inno Avatar asked Jun 30 '10 12:06

Inno


People also ask

What are the three methods for implementing programming languages?

IMPLEMENTATION METHODS 1. Compilation – Programs are translated into machine Language & System calls 2. Interpretation – Programs are interpreted by another program (an interpreter) 3. Hybrid – Programs translated into an intermediate language for easy interpretation 4.

Which method is used to implement one programming language to another?

Compilers convert one programming language into another. Usually, compilers are used to convert code so the machine can understand it.

What is implementation in programming example?

In IT, the word implementation usually refers to installing a new hardware or software system or application. It can also mean the inclusion of a specific technical specification, software component or software standard. For example, software development tools contain implementations of a programming language.

How can a programming language be written in itself?

In computer science, bootstrapping is the technique for producing a self-compiling compiler – that is, a compiler (or assembler) written in the source programming language that it intends to compile.


1 Answers

Here's a very academic answer (from a longtime academic). First I'll reframe the question:

What does it mean for a programming language to be implemented?

I'll start with "what is a programming language":

  1. A programming language is a formal language (a set of utterances we can characterize precisely through algorithmic rules) such that a sentence in the language has a computational meaning. There are a variety of ways to give computation meaning; two of the most popular are that a computation stands for a function (from values to values, or from machine states to machine states) and that a computation stands for a machine that makes "state transitions" and interacts with the outside world.

  2. A language is implemented when a means is provided to read in an utterance and perform the computation, that is, calculate the function or perform the behavior. The means is the implementation.

Typical implementations include

  • Direct interpretation of the language syntax. This model is rare but FORTH probably comes closest to it.

  • Translation of the syntax into virtual-machine code, also called bytecode, which is itself another language and which is interpreted. It is popular to write bytecode interpreters in C. Lua, Perl, Python, and Ruby are implemented more or less this way.

  • Translation of the syntax into hardware machine instructions, which is itself another language, and which is interpreted by your CPU. C and C++ are typically (but not always) implemented this way.

  • Direct interpretation of the language in hardware. IA-32 machine code and AMD64 machine code are implemented this way.

When a person says "Language X is implemented in Y", they are usually saying that a translator for X or an interpreter for X's bytecode is written in language Y. One of the great secrets of compiler writers is the ability to write the compiler for language X in language X itself. If this interests you, get Andrew Appel's paper Axiomatic Bootstrapping: A Guide for Compiler Hackers.

Sometimes the answer to this question is not obvious. Squeak Smalltalk writes both a translator and a bytecode interpreter in Smalltalk, then translates the interpreter to C, which is translated to machine code. What is Squeak implemented in? Smalltalk.


Poke a professor; get a lecture.

like image 125
Norman Ramsey Avatar answered Oct 14 '22 19:10

Norman Ramsey