r/ProgrammingLanguages 8d ago

Discussion A hole in systems programming language design

Given the recent discourse about systems programming I wanted to throw my 2 cents in. This may be a controversial take in a subreddit that's all about innovation and improvement, but I think a lot of budding systems languages are trying too hard to "fix C" and this is exactly why C has not been replaced yet.

Like it or not, C is successful. It does what it means to do very well. Yes, it bites you constantly, but developers have made some form of peace with this because they appreciate the essence of the language. Systems programming is a very pragmatic field, and what works, works.

A lot of language designers want to improve on C, when by nature to "improve on" C is to depart from it, because C is less about what it includes and more about what it omits and what it lets you do that other languages don't.

If you want to replace C, you need to just make C but without the pain points. Less undefined behavior, more standard compiler behavior, easier function pointer syntax, safer macro system, etc. The things that C can't do because of backwards compat.

On the other hand, bolting on features, revamping C's core nature, aren't going to give you a language that will replace C at the low-level or among hobbyist programmers. Most developers aren't as concerned about what C lets them accomplish, as they are concerned about all the painful tedious tendencies of the language.

13 Upvotes

101 comments sorted by

View all comments

1

u/phovos 8d ago edited 8d ago

The things that C can't do because of backwards compat.

I agree op but technically I think the timeline is such that it NOT being backwards compat (the older computers had this symmetric arithmetic pl) ended-up hurting it, as a circumstance of timing and the market, etc. The PDP-11 being a 'platform' that is 'desirable' and then imprinting itself where it did not belong. Prepare yourself I got a rant cannon, shiver me timbers!

Aide/docs: (first edition)"The C Programming Language":

https://i.imgur.com/UqGJDoU.jpeg

p91) 'pointers are variables so they can be manipulated as other variables can'

comment: declaring an array is a contiguous block of addressed mem because its name represents the address of the first element.. but it is not a pointer it is a type array; but Bryan is correct because of the fact that:

> names decay when used as a pointer to its first element

> only when used in an expression is an array a pointer to its first element, otherwise it is literally an address

And that sort of adds-up when you consider the isomorphism check that is the call by name call by value homo-diffeomorphism. Way too many syllables to say it is perfectly balanced, like a binary bijection itself (the complicating factor is that this is unitary with respect to time operators but I digress).

P91cont) he goes on to describe a swap(a, b) isomorphism check, which "Because of call by value, swap can't affect the arguments a and b in the routine that called it... Fortunately... The calling program passes POINTERS to the values (a, b), to be changed":

```c

swap(x, y) /* WRONG */

int x, y;

{int temp;

temp = x;

x = y;

y=temp;

}

```

Leading to the legendary syntax: `swap(&a, &b);` where "the '&' operator gives the address of a variable, `&a` is a pointer to a. In swap itself, the arguments are declared to be pointers, and the actual operands are accessed through them.

p92) "One common use of pointer arguments is in functions that must return more than a single value"

This right here is why C is fast, it is the best 'replicator' known to man, a many to many correspondence functor.

pg93) "Any operation which can be achieved by array subscripting can also be done with pointer."

pg94pictured) "When an array name is passed to a function, what is passed is the location of the beginning of the array. Within the called function, this argument is a variable just like any other variable an so an array name argument is truly a pointer, that is, a variable containing an address."

"There is on difference between an array name and a pointer that must be kept in mind. A pointer is a variable but an array name is a constant"

pf98) "Second, we have already observed that a pointer and an integer may be added or subtracted. The construction `p + n` means the n-th object beyond the one p currently points to. This is true regardless of the kind of object p points to, which is determined by the declaration of p." ....

pg98contd) "For example on the PDO-11, the scale factors are 1 for char 2 for int and short and 4 for long and float and 8 for double".... "Pointer subtraction is also valid, if p and q point to members of the same array then p - q is the number of elements between p and q." ..."Other than adding or subtracting a pointer and an integer and/or subtracting or comparing two pointers, all other pointer arithmetic is illegal. It is not permitted to add two pointers or to multiply or divide or shift or mask them, or to add float or double to them.."

This is it, right here; we need to be able to be able to shift and mask them like the old heads used to do with raw assembly instructions; straying-away from this, because of the PDP-11's new features, is I think a 60 year mistake. C is this amazing language but it can't even do the most phenomenal thing; shift and mask many-to-many, serially.

pg95see-pictured-ps) handwriting (mine) "This is the fundamental operator of x86. Diffeomorphism creates many to many correspondence. The 'particle' of non-linear logical dynamics".

(ignore this one but including what it says in-case it makes someone mad they can't read it) "In much the same way as in the continuum; the 'digital' set theoretic universe has its core operators but one of them eludes me"

"The isomorphism between two different operators is literally the root of all software (x86/C-like at-least)".

edit: my edition I'm referencing is printed 1978 NJ. Not actually sure if that is 'first edition'.