Re: technology discussion → does the world need a "new" C ?

Liste des GroupesRevenir à cl c  
Sujet : Re: technology discussion → does the world need a "new" C ?
De : cr88192 (at) *nospam* gmail.com (BGB)
Groupes : comp.lang.c
Date : 06. Jul 2024, 05:30:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6adrm$3ljg6$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 7/5/2024 5:40 PM, Ben Bacarisse wrote:
BGB <cr88192@gmail.com> writes:
 
On 7/5/2024 6:20 AM, Ben Bacarisse wrote:
BGB <cr88192@gmail.com> writes:
>
On 7/5/2024 3:09 AM, Keith Thompson wrote:
BGB <cr88192@gmail.com> writes:
On 7/4/2024 8:05 PM, Lawrence D'Oliveiro wrote:
It’s called “Rust”.
>
>
If anything, I suspect may make sense to go a different direction:
     Not to a bigger language, but to a more narrowly defined language.
>
Basically, to try to distill what C does well, keeping its core
essence intact.
>
>
Goal would be to make it easier to get more consistent behavior across
implementations, and also to make it simpler to implement (vs an
actual C compiler); with a sub-goal to allow for implementing a
compiler within a small memory footprint (as would be possible for K&R
or C89).
>
>
Say for example:
     Integer type sizes are defined;
     Nominally, integers are:
       Twos complement;
       Little endian;
       Wrap on overflow.
     Dropped features:
       VLAs
       Multidimensional arrays (*1)
       Bitfields
       ...
     Simplified declaration syntax (*2):
       {Modifier|Attribute}* TypeName Declarator
>
>
*1: While not exactly that rare, and can be useful, it is debatable if
    they add enough to really justify their complexity and relative
    semantic fragility. If using pointers, one almost invariably needs to
    fall back to doing "arr[y*N+x]" or similar anyways, so it is arguable
    that it could make sense to drop them and have people always do their
    multidimensional indexing manually.
>
Note that multidimensional indexing via multiple levels of pointer
indirection would not be effected by this.
[...]
Multidimensional arrays in C are not a distinct language feature.
They are simply arrays of arrays, and all operations on them follow
from operations on ordinary arrays and pointers.
Are you proposing (in this hypothetical new language) to add
an arbitrary restriction, so that arrays can have elements of
arithmetic, pointer, struct, etc. type, but not of array type?
I'm not sure I see the point.
>
As-is, the multidimensional arrays require the compiler to realize that it
needs to multiply one index by the product of all following indices.
>
So, say:
    int a[4][4];
     int j, k, l;
     l=a[j][k];
>
Essentially needs to be internally translated to, say:
     l=a[j*4+k];
>
Eliminating multidimensional arrays eliminates the need for this
translation logic, and the need to be able to represent this case in the
typesystem handling logic (which is, as I see it, in some ways very
different from what one needs for a struct).
How can it be eliminated?  All your plan does is force me to wrap the
inner array in a struct in order to get anything like the convenience of
the above:
struct a { int a[4]; };
struct a a[4];
l = a[j].a[k];
Most compilers with generate the same arithmetic (indeed exactly the
same code) for this as for the more convenient from that you don't like.
All you can do to eliminate this code generation is to make it so hard
to re-write the convenient code you dislike.  (And yes, I used the same
name all over the place because you are forcing me to.)
>
>
It is not so much a dislike of multidimensional arrays as a concept, but
rather, the hair they add to the compiler and typesystem.
>
Granted, one would still have other complex types, like structs and
function pointers, so potentially the complexity savings would be
limited.
 Then the "hair" is still there.
 
Possibly true.
I am now left thinking maybe the issue was not that the multidimensional arrays exist, but rather, how I had approached implementing them...
Ironically, I probably should have leaned harder into the "daisy chained types" interpretation, rather than treating it as an undesirable implementation tradeoff.
As noted, my conceptual approach to types was a little different; and, implicitly, more directly mimics how types behave in the Java VM (but with C like type semantics being expressed on top of this).
Though, rather than I/L/F/D/A (Int/Long/Float/Double/Address) as the fundamental types, it is more like I/L/D/X/A/V (Int/Long/Double/XLong/Address/Variant).
With arrays and by-value structs being treated like subtypes of the Address type, just with pre reserved storage being created in the prolog.
Variant also exists, holding any types that are nominally represented as tagged references (and type-checked at runtime; though using all this is non-standard in C).
The XLong category mostly holds types with a 128-bit format.
Well, and with a C compiler that originally started out as an interpreter for a JavaScript clone (before later taking influence from the JVM and moving towards a static-typed core; with a fork of this VM having been modified to be able to parse C, ...).
Design isn't entirely free from hair.
The backend did end up with a fair bit of complexity as well, as some initial ideas turned out to not have been so good in retrospect.

While eliminating structs could also simplify things; structs also tend to
be a lot more useful.
Indeed.  And I'd have to use them for this!
>
>
Errm, the strategy I would assume is, as noted:
   int a[4][4];
   ...
   l=a[j][k];
Becomes:
   int a[16];
   ...
   l=a[j*4+k];
 That's what you want to force me to write, but I can use and array of
arrays despite your arbitrary ban on them by simply putting the array in
a struct.
 Anyway, sine C exists, I won't be forced to use your proposed
alternative.
 
IN most contexts, I don't really see how a struct is preferable to a multiply, but either way...
Whole language design is still a hypothetical at this point anyways (and my actual compiler does support multidimensional arrays).

Much like what one would typically need to do anyways if the array was
heap-allocated.
 Only if you forbid variably modified types (note not VLAs).
    int (*a)[n] = malloc(m * sizeof *a);
 allows me to index a[i][j] conveniently.
 
This is another one of the edge cases that I would likely omit from such a language (rarely used in my experience).
But, as noted elsewhere, sizeof would also likely no longer be allowed for expressions.

Though, the major goal for this sort of thing is mostly to try to limit the
complexity required to write a compiler (as opposed to programmer
convenience).
 Ah.
 
Like, for example, I had tried (but failed) to write a usable C compiler in
less than 30k lines (and also ideally needing less than 4MB of RAM). But,
if the language design is simplified some, this might be a little
closer. Might still be doable, but a C compiler in 50-75k lines is much
less impressive.
 Why do you think this matters to other people?
 
As-is, C compilers tend to be a relative pain to implement.
A simplified language would be less of a pain, so people can more easily throw together their own compiler as-needed, rather than have an implicit assumption of "one compiler to rule them all".
But, C is at least a little more amendable to people rolling their own compilers, than, say, a language like C++ (where hand-rolling a full-featured C++ compiler seems likely out of reach for a single developer project).
But, say, for example, you want to be able to write a compiler that runs on a system with relatively limited RAM and possibly no MMU.
Granted, there is also MicroPython, but... blarg...
At present, I was left with inertia from my current compiler:
Given I am pretty much exclusively cross-compiling from a PC, the incentive to invest effort on a smaller compiler is lacking.
Technically, I might also want a compiler that can deal with GLSL.
Using my existing compiler to static compile shader programs would be possible, but tacky and wouldn't mesh well with the OpenGL API (which generally expects shaders to be loaded in plain text form, rather than, say, as a statically-compiled part of the program, or as COFF objects or DLLs or similar).

Date Sujet#  Auteur
4 Jul 24 * technology discussion → does the world need a "new" C ?301aotto1968
5 Jul 24 +* Re: technology discussion → does the world need a "new" C ?298Lawrence D'Oliveiro
5 Jul 24 i`* Re: technology discussion → does the world need a "new" C ?297BGB
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?2Lawrence D'Oliveiro
5 Jul 24 i i`- Re: technology discussion → does the world need a "new" C ?1yeti
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?267Keith Thompson
5 Jul 24 i i+- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
5 Jul 24 i i+* Re: technology discussion → does the world need a "new" C ?264BGB
5 Jul 24 i ii+* Re: technology discussion → does the world need a "new" C ?18Ben Bacarisse
5 Jul 24 i iii`* Re: technology discussion → does the world need a "new" C ?17BGB
6 Jul 24 i iii +* Re: technology discussion → does the world need a "new" C ?14Ben Bacarisse
6 Jul 24 i iii i+* Re: technology discussion → does the world need a "new" C ?9BGB
6 Jul 24 i iii ii+* Re: technology discussion → does the world need a "new" C ?2David Brown
6 Jul 24 i iii iii`- Re: technology discussion → does the world need a "new" C ?1BGB
7 Jul 24 i iii ii`* Re: technology discussion → does the world need a "new" C ?6Ben Bacarisse
7 Jul 24 i iii ii +* Re: technology discussion → does the world need a "new" C ?2Keith Thompson
7 Jul 24 i iii ii i`- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
7 Jul 24 i iii ii `* Re: technology discussion → does the world need a "new" C ?3BGB
7 Jul 24 i iii ii  `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i iii ii   `- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i iii i`* Re: technology discussion → does the world need a "new" C ?4Malcolm McLean
6 Jul 24 i iii i `* Re: technology discussion → does the world need a "new" C ?3BGB
6 Jul 24 i iii i  `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i iii i   `- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i iii `* Re: technology discussion → does the world need a "new" C ?2Janis Papanagnou
6 Jul 24 i iii  `- Re: technology discussion → does the world need a "new" C ?1BGB
5 Jul 24 i ii`* Re: technology discussion → does the world need a "new" C ?245Keith Thompson
6 Jul 24 i ii `* Re: technology discussion → does the world need a "new" C ?244Lawrence D'Oliveiro
6 Jul 24 i ii  +* Re: technology discussion → does the world need a "new" C ?228BGB
6 Jul 24 i ii  i+- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i ii  i+* Re: technology discussion → does the world need a "new" C ?6James Kuyper
6 Jul 24 i ii  ii`* Re: technology discussion → does the world need a "new" C ?5BGB
9 Jul 24 i ii  ii `* Re: technology discussion → does the world need a "new" C ?4David Brown
9 Jul 24 i ii  ii  `* Re: technology discussion → does the world need a "new" C ?3Michael S
9 Jul 24 i ii  ii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i ii  ii   `- Re: technology discussion → does the world need a "new" C ?1BGB
7 Jul 24 i ii  i`* Re: technology discussion → does the world need a "new" C ?220Keith Thompson
7 Jul 24 i ii  i +* Re: technology discussion → does the world need a "new" C ?215BGB
7 Jul 24 i ii  i i`* Re: technology discussion → does the world need a "new" C ?214James Kuyper
7 Jul 24 i ii  i i `* Re: technology discussion → does the world need a "new" C ?213BGB
8 Jul 24 i ii  i i  `* Re: technology discussion → does the world need a "new" C ?212James Kuyper
8 Jul 24 i ii  i i   `* Re: technology discussion → does the world need a "new" C ?211Kaz Kylheku
8 Jul 24 i ii  i i    +- Re: technology discussion → does the world need a "new" C ?1BGB
8 Jul 24 i ii  i i    +- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
8 Jul 24 i ii  i i    +* Re: technology discussion → does the world need a "new" C ?207James Kuyper
8 Jul 24 i ii  i i    i`* Re: technology discussion → does the world need a "new" C ?206BGB
9 Jul 24 i ii  i i    i `* Re: technology discussion → does the world need a "new" C ?205David Brown
9 Jul 24 i ii  i i    i  +* Re: technology discussion → does the world need a "new" C ?197bart
9 Jul 24 i ii  i i    i  i+* Re: technology discussion → does the world need a "new" C ?194Ben Bacarisse
9 Jul 24 i ii  i i    i  ii`* Re: technology discussion → does the world need a "new" C ?193bart
9 Jul 24 i ii  i i    i  ii +* Re: technology discussion → does the world need a "new" C ?184Ben Bacarisse
9 Jul 24 i ii  i i    i  ii i+* Re: technology discussion → does the world need a "new" C ?3BGB
10 Jul 24 i ii  i i    i  ii ii`* Re: technology discussion → does the world need a "new" C ?2Ben Bacarisse
10 Jul 24 i ii  i i    i  ii ii `- Re: technology discussion → does the world need a "new" C ?1BGB
9 Jul 24 i ii  i i    i  ii i`* Re: technology discussion → does the world need a "new" C ?180bart
9 Jul 24 i ii  i i    i  ii i +- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i i    i  ii i `* Re: technology discussion → does the world need a "new" C ?178Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i  `* Re: technology discussion → does the world need a "new" C ?177bart
10 Jul 24 i ii  i i    i  ii i   `* Re: technology discussion → does the world need a "new" C ?176Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i    +- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 i ii  i i    i  ii i    +* Re: technology discussion → does the world need a "new" C ?167bart
10 Jul 24 i ii  i i    i  ii i    i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
10 Jul 24 i ii  i i    i  ii i    i+* Re: technology discussion → does the world need a "new" C ?54Tim Rentsch
10 Jul 24 i ii  i i    i  ii i    ii+* Re: technology discussion → does the world need a "new" C ?14Michael S
10 Jul 24 i ii  i i    i  ii i    iii+* Re: technology discussion → does the world need a "new" C ?8David Brown
11 Jul 24 i ii  i i    i  ii i    iiii`* Re: technology discussion → does the world need a "new" C ?7Michael S
11 Jul 24 i ii  i i    i  ii i    iiii `* Re: technology discussion → does the world need a "new" C ?6Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iiii  `* Re: technology discussion → does the world need a "new" C ?5Michael S
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
11 Jul 24 i ii  i i    i  ii i    iiii   `- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
11 Jul 24 i ii  i i    i  ii i    iii+- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iii`* Re: technology discussion → does the world need a "new" C ?4Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    iii `* Re: technology discussion → does the world need a "new" C ?3BGB
11 Jul 24 i ii  i i    i  ii i    iii  `* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    iii   `- Re: technology discussion → does the world need a "new" C ?1BGB
10 Jul 24 i ii  i i    i  ii i    ii`* Re: technology discussion → does the world need a "new" C ?39bart
10 Jul 24 i ii  i i    i  ii i    ii +* Re: technology discussion → does the world need a "new" C ?37Michael S
10 Jul 24 i ii  i i    i  ii i    ii i+* Re: technology discussion → does the world need a "new" C ?34bart
11 Jul 24 i ii  i i    i  ii i    ii ii+- Re: technology discussion → does the world need a "new" C ?1Michael S
11 Jul 24 i ii  i i    i  ii i    ii ii`* Re: technology discussion → does the world need a "new" C ?32Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    ii ii `* Re: technology discussion → does the world need a "new" C ?31bart
11 Jul 24 i ii  i i    i  ii i    ii ii  +* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    ii ii  i`- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 i ii  i i    i  ii i    ii ii  `* Re: technology discussion → does the world need a "new" C ?28Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii ii   `* Re: technology discussion → does the world need a "new" C ?27bart
11 Jul 24 i ii  i i    i  ii i    ii ii    +* Re: technology discussion → does the world need a "new" C ?25Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii ii    i+* Re: technology discussion → does the world need a "new" C ?15bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii`* Re: technology discussion → does the world need a "new" C ?14David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii +* Re: technology discussion → does the world need a "new" C ?12bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i+* Re: technology discussion → does the world need a "new" C ?7David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii ii`* Re: technology discussion → does the world need a "new" C ?6bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii ii +* Re: technology discussion → does the world need a "new" C ?2bart
13 Jul 24 i ii  i i    i  ii i    ii ii    ii ii i`- Re: technology discussion → does the world need a "new" C ?1David Brown
13 Jul 24 i ii  i i    i  ii i    ii ii    ii ii `* Re: technology discussion → does the world need a "new" C ?3David Brown
17 Jul 24 i ii  i i    i  ii i    ii ii    ii ii  `* Re: technology discussion → does the world need a "new" C ?2Bart
17 Jul 24 i ii  i i    i  ii i    ii ii    ii ii   `- Re: technology discussion → does the world need a "new" C ?1David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i`* Re: technology discussion → does the world need a "new" C ?3Keith Thompson
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i `* Re: technology discussion → does the world need a "new" C ?2James Kuyper
12 Jul 24 i ii  i i    i  ii i    ii ii    ii `- Re: technology discussion → does the world need a "new" C ?1BGB
11 Jul 24 i ii  i i    i  ii i    ii ii    i`* Re: technology discussion → does the world need a "new" C ?9bart
12 Jul 24 i ii  i i    i  ii i    ii ii    `- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 i ii  i i    i  ii i    ii i+- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii i`- Re: technology discussion → does the world need a "new" C ?1James Kuyper
11 Jul 24 i ii  i i    i  ii i    ii `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i i    i  ii i    i+* Re: technology discussion → does the world need a "new" C ?2James Kuyper
11 Jul 24 i ii  i i    i  ii i    i`* Re: technology discussion → does the world need a "new" C ?109Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i    `* Re: technology discussion → does the world need a "new" C ?7Janis Papanagnou
10 Jul 24 i ii  i i    i  ii `* Re: technology discussion → does the world need a "new" C ?8Kaz Kylheku
9 Jul 24 i ii  i i    i  i+- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i ii  i i    i  i`- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
9 Jul 24 i ii  i i    i  +- Re: technology discussion → does the world need a "new" C ?1Michael S
9 Jul 24 i ii  i i    i  `* Re: technology discussion → does the world need a "new" C ?6BGB
9 Jul 24 i ii  i i    `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i `* Re: technology discussion → does the world need a "new" C ?4Lawrence D'Oliveiro
6 Jul 24 i ii  +* Re: technology discussion → does the world need a "new" C ?9James Kuyper
7 Jul 24 i ii  `* Re: technology discussion → does the world need a "new" C ?6Keith Thompson
6 Jul 24 i i`- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?26bart
5 Jul 24 i `- Re: technology discussion → does the world need a "new" C ?1lexi hale
7 Jul 24 `* Re: technology discussion → does the world need a "new" C ?2Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal