I was wondering about the following questions:
- What does it mean “some language is
a subset/superset of another“? Can
it be defined in mathematics? Is it
related to the subset/superset
concept in elementary set theory? -
Are almost all existing languages
implemented/written in some small
number of low-level languages? For
example, are most languages written
in C? Is C++ written in C?Is there some relation between the
implementation relation and the
concept of subset/superset of
languages? -
In terms of language features, some
languages have more than some other.
In some cases, some has all the
features of some other, for example,
does C++ have all the features of C?Is there some relation between the
subset/superset relation in terms of
the set of features and the
subset/superset relation between
languages? - Are there other aspects that
characterize relation between
languages?
Thanks and regards!
Syntactically a language A is a subset of a language B if every program that is valid in language A is also valid in language B. Semantically it is a subset if it is a syntactic subset and each valid A program also exhibits the same behavior in language B.
Syntactic subset: If
P_Ais the set of all valid programs in language A andP_Bis the set of all valid programs in language B, then languageAis a syntactic subset of languageBexactly ifP_Ais a subset ofP_B.Semantic subset: Let
A(p)be a function which describes the behavior of programpin language A, andB(p)describe the behavior of programpin language B. A is a subset of B if and only if for allpfor whichA(p)is defined,B(p)is also defined andA(p) = B(p).This depends on your definition of “almost all” of course, but I’m inclined to say no. Many compilers and interpreters are written in C and C++ (simply because a lot of software in general is implemented in C and C++), but by far not all.
As has been pointed out in comments already, C++ is a language not a piece of software.
g++which is the GNU C++ compiler is written in C, but there are also C++ compilers which are written in different languages (probably).Yes (unless you count simplicity as a feature).
If a language is a superset of another language, the set of that language’s features will also have to be a superset of the other language’s features (again unless you count simplicity or things like “the language does not allow X” as a feature).
This is not applicable in the other direction however (i.e. just because A’s features are a superset of B’s features, A does not have to be a superset of B).