Reimplementing the bulk of std.meta iteratively
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Tue Sep 29 19:58:37 UTC 2020
On Tuesday, 29 September 2020 at 18:53:26 UTC, bachmeier wrote:
> On Tuesday, 29 September 2020 at 13:44:55 UTC, Ola Fosheim
> Grøstad wrote:
> It's possible I'm wrong, but it says to me that the language
> developers should design the language worrying only about that
> 'small core of essential primitives'. Maybe 'libraries' refers
> to the standard library only, but that's not clear to me.
Yes, it is not terribly clear what people are talking about in
this thread because many different layers of a language is being
lumped together. So let me try to paint up my view of these
layers:
1. On the one hand you have the type system (I guess you can call
that the constraints you can put on constructs) where you
probably want a small set of "axioms" from which you cannot
deduce contradictions (soundness). A small core set makes it
possible to prove that it is consistent.
2. On the other hand you have the conceptual "quasi-theoretical"
building blocks from which you can describe everything that is
expressible in the language. Keeping this small is also valuable
for the same reasons. It is easier to reason about and ensure
correctness/soundness and build a language that is easy to grasp.
Basically, this often embeds a "modelling idea". (everything
should be expressible as an object, a list, a logical proposition
or a mix of two core concepts etc). If you look at the Eiffel
page they claim that it is a methodology supported by a language.
The same was Simula and Beta in a sense, languages supporting
modelling with objects. So the minimal core language is often
tied to a modelling-idea.
3. Then you have the construct that is actually implemented in
the compiler, which reflects the "quasi-theoretical" language,
but might be done differently for implementation reasons. Though
it should obey the "laws" of the quasi-theoretical language.
4. Then you have the syntax (with syntactical sugar) that allows
user to express that. Since it is a massive undertaking to let
libraries define new syntax it often is a lot of "syntactical
sugar", basically a few words generating many constructs in the
underlying "theoretical" language.
5. Then you have the language that programmers use, which
basically is what programmers often call "idiomatic" styles of
programming for that particular language and that includes
frequently used libraries. When newbies write bad code and
complain loudly the old timers will point out that they are in
essence "abusing the language construct" and "should learn to
speak the language before them correctly".
So, basically, a programming language design can let the
programmer believe that the compiler provides a string concept,
although the underlying "theoretical language" only has lists and
enumerations. So it strings might look different from lists in
the source, but on a "theoretical level" it isn't.
What makes this more complicated is that the "true
quasi-theoretical" language may emerge over time. As an example:
I think the underlying emerging core concept in C++ is vastly
different from C, that is, the most important concept in C++ has
turned out to be RAII in combination with exceptions. Objects
with deterministic constructors and destructors. If one were to
do C++ v2, then one probably should start with that and see how
small the core language could be made.
In practice compilers tend to bolt on poorly thought out "built
ins" that do not share the properties of the "theoretical
language" and then they stand out as sore thumbs that exhibit
behaviour that is perceived as bug-like by programmers.
Until recently the "aesthetics" of programming language design
has typically been to find the "one true language" that never
will have to change. However, languages like typescript pretty
much show that is better if programmers can configure the
semantics to their specific use case in a config file. Because
the context keeps changing.
Maybe one can modify a language like D to do the same, so that
you could get AA or even data-science libraries imported by
default so it feels more like a scripting language with that
config. Clearly, embedded programming and data-science
programming have different basic needs. Seems reasonable that one
could have seemingly builtin AA in one config geared towards
scripting-like programming.
More information about the Digitalmars-d
mailing list