On Tue, 14 Dec 2021 10:58:43 +0000
James Harris <
james.h...@gmail.com> wrote:
> How can someone make sure a new language is 'complete', i.e. that no
> essential is left out and that it will allow a programmer to do
> anything he might need to do?
>
I'd guess that depends on how you define "complete". I.e., in what way
do you mean "complete"?
E.g, if the language is very close to the assembly language of a
particular microprocessor, or even similar to many of them, then the
language will be able to do whatever can be done in assembly. I.e.,
it's "complete" as far as having a high-level language that can easily
convert into the functionality of the microprocessor as represented by
the assembly language, which should be Turing complete.
E.g., if the language is meant to be a high level language abstracted
entirely from the machine representation, then you can probably never
assure that the language is "complete" in the sense that there may be
some new algorithm or math or implementation that is difficult to
implement on specific machines, e.g., think shoehorning C onto old
mainframes which non-standardized architectures, bizarre character
sizes, word addressing, and non-contiguous memory spaces.
While you can design in known language features you desire, it's really
only through testing the language by writing code for it, that the
errors and mistakes and missing features become truly apparent, and what
gets tested by the latter activity is truly a matter of an individuals
IQ or that of many individuals. I.e., you don't want only choose "dumb"
people to test a language, nor would you want to limit the language to
home computers or smart phones while ignoring mainframes, etc,
especially if you want a broad appeal. There is nothing wrong with a
domain specific or even machine specific language, as long as that is
your goal, but most people seem to want a good general purpose language.
One path you could take is to compare similar languages (*), and strip
the languages down to their fundamental features held in common. That
could provide a base language to build up from. Then, you might
compare the features to those required by critical concepts such as
spaghetti code, structured programming, procedural programming,
object-oriented programming, code density and function points (**), and
Turing completeness.
(*)
https://en.wikipedia.org/wiki/Programming_paradigm
(**)
http://web.archive.org/web/20061231170804/http://www.theadvisors.com/langcomparison.htm
> The reason for asking is that I recently realised that I had to add a
> new parameter mode. Because of certain choices I found I couldn't get
> away with just in, inout and out so I had to add a new mode. I'm
> avoiding going in to the details as they could divert from the topic
> but the point is that I found that something was missing and it got
> me wondering what else could be needed.
>
> So is there a way to make sure a new language is complete?
> [...[
> One approach is probably to base a new language on an existing one.
You'd inherit defects that way, but you won't design in new defects, at
least until you extend the base language with the new elements.
I'm thinking of the Tesla car. Supposedly, it was a from-scratch or
from the ground-up design. So, it failed to inherit defects from other
long established car platforms designed by other automotive
manufacturers, which is a good thing. However, they designed in a
bunch of defects too (which are usually dismissed as slander or libel
by Tesla, e.g., whompy-wheels that pop-off when you hit pot-holes, total
burn down from damaged batteries, incompetent or retarded AI driver to
help drunk drivers not get a ticket, etc. I'm not making any statement
towards or against the validity of these claims about Tesla. That's
just what's floating around the Internet.).
> Then as long as the earlier language is complete it should be easier
> to make sure the new one is, too. But even that has its weaknesses.
> For example, one might base a new language on C but then find that
> some things cannot be done - or cannot be done reasonably - without
> the preprocessor.
Unfortunately, C as I know it, really isn't C without the preprocessor.
I ran into this issue with some C lexers and parsers, as I needed C
preprocessor features, but they weren't available. Even the very
minimal Small C by Ron Cain had to implement some C preprocessor
features in order to compile a subset of C.
> If attempting to create a new language without an antecedent then the
> situation is even more challenging. There will be no prior model to
> guide the design.
>
> So, any suggestions?
Formal design? You need to know what you want in the language, which
means you need to know about the purpose of the language (general
purpose, domain specific), which means you need to know a lot about the
functionality of the host platform(s), which means you need to choose a
programming paradigm (procedural, object-oriented), etc. You may need
to learn how to do the formal proofs for such things too.
Ad-hoc design? Attempt to do something, find out what you need, add it
to the language as you go. Again, this will depend on your own
abilities, as you won't find stuff that is missing in the language, for
things you never use or never do.
E.g., I wouldn't notice if unsigned integers were missing from C, or
floating point either, or if a language has no complex numbers (unless
I coded something with Mandelbrot sets), nor GUI mechanisms, etc.
But, GUI mechanisms are usually in an external library. So, maybe the
question should be where does the language end and the libraries begin?
I.e., the more that you can push out of the language proper and into
the language libraries, the more likely the language will be "complete".
Or, at least, the language will be "complete" enough to implement the
language libraries ... I guess this goes towards your other thread
about OS and library separation.
--