Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why was C++ mentioned as a 'usually' compiled language?

Tags:

c++

In the C++ tag wiki, it is stated that

C++ is a ... (usually) compiled ... programming language ...

Yet Wikipedia and cplusplus.com assert that C++ is a compiled language without mentioning any exceptions.

Could you please tell us the reason why C++ is usually, yet not always, a compiled language? When can C++ be deemed a non-compiled language?


Wikipedia:

C++ is a compiled language, with implementations of it available on many platforms.

cplusplus.com:

... is a compiled language. C++ compiles directly to a machine's native code, allowing

This may suggest that there are non-compiled forms of C++. What makes the wiki to state 'usually'?

like image 938
Herpes Free Engineer Avatar asked Feb 14 '18 16:02

Herpes Free Engineer


People also ask

Why is C called a compiled programming language?

C is a compiled programming language. This means that it uses a compiler to analyse the source code written in C and then turns it into a binary file that the computer's hardware can directly execute. This will be specific for each particular machine.

Is C language compiled language?

C is what is called a compiled language. This means that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute).

Is C generally compiled or interpreted?

A compiled language is a programming language that is generally compiled and not interpreted. It is one where the program, once compiled, is expressed in the instructions of the target machine; this machine code is undecipherable by humans. Types of compiled language – C, C++, C#, CLEO, COBOL, etc.

What does it mean for a language to be compiled?

A compiled language is a programming language whose implementations are typically compilers (translators that generate machine code from source code), and not interpreters (step-by-step executors of source code, where no pre-runtime translation takes place).


2 Answers

Because "C++" as defined by the C++ Standard is only a programming language, operating in an abstract machine. Implementations are free to do whatever they want to emulate the behaviour of that abstract machine.

Therefore, regardless of whether someone actually makes a C++ interpreter, saying that C++ is always compiled would be an unfounded assumption.

like image 106
Quentin Avatar answered Nov 13 '22 01:11

Quentin


There is no technical reason why you can't write a C++ interpreter rather than a compiler and I believe some have been written in the past.

C is also a (usually) compiled language, but I myself wrote a (slow, recursive decent) C89 interpreter some 20 years ago. C++ is just a (much) harder version of the same problem.

like image 22
Jesper Juhl Avatar answered Nov 13 '22 03:11

Jesper Juhl