Reputation: 2672
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'?
Upvotes: 7
Views: 1182
Reputation: 1053
There are some interpreters for subsets of C++ (related question), but the overwhelming majority of C++ work is done using compilers. Using interpreters is so rare that no C++ literature or sizeable C++ library or program not explicitly about/for those interpreters will restrict itself to the subset of C++ that can be used on an interpreter.
With C++, it's actually more common to compile further C++ on the fly than interpret any.
For whatever it's worth, the most recent related news I've read (on Hacker News) was about a C++17 REPL.
Upvotes: 2
Reputation: 153955
In most cases C++ is compiled but, e.g., cling is a C++ interpreter. I haven't tried it much but it seems to be a fairly complete C++ implementation.
Upvotes: 1
Reputation: 63154
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.
Upvotes: 10
Reputation: 31459
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.
Upvotes: 8