News for hackers. Stuff that matters.
Re:A Reply to “Let’s stop copying C” by WalterBright on Saturday January 25, 2020 @11:22PM (#22150371)
I wrote an article about this, "C's Biggest Mistake":

https://www.digitalmars.com/articles/b44.html

Re:A Reply to “Let’s stop copying C” by Animats on Sunday January 26, 2020 @01:30AM (#22150752)
Agreed. I've been saying that for too many decades.

My version of that is "The big safety questions are 'how big is it', 'who owns it', and 'who locks it'. C helps with none of those."

Most of the things done with pointer arithmetic are really array slices without the right syntax. If you're doing something with pointer arithmetic that can't be represented an array slice, you're probably doing something wrong. I once proposed adding slice syntax and array sizes to C. This was discussed on comp.lang.c at some length, and looks backwards compatible. But the political problems are huge.

Re:A Reply to “Let’s stop copying C” by pjmlp on Sunday January 26, 2020 @02:54AM (#22151012)
Politics are a big issue regarding security improvements with C, every attempt to improve the language's security has failed, including the now optional Annex K.

Hardware solutions like Solaris SPARC ADI, ARM MTE used by iOS and a requirement for future Android ARM devices, CHERI CPU seem to be the only way to tame those developers.

Sadly Intel dropped the ball on MPX, leaving x86/x64 as the only CPU not pursuing such kind of endeavours.

So memory tagging seems to be the only way.

Thankfully C++ community did not inherit this part of C culture, and several activities are in process to at least minimize the security impact of such features, e.g. lifetime profile, reducing the amount of UB, security guidelines, library types instead of raw C ones, ....

Re:A Reply to “Let’s stop copying C” by gingerBill on Sunday January 26, 2020 @07:12AM (#22151698)
This is why Odin does not have first class pointer arithmetic and has first class support for slices. I have found in practice that I don't actually need pointer arithmetic most of the time as slices solve that function.

The reason pointer arithmetic is so useful in C is because of its lack of array types, like slices. `x[n]` is the same as `*(x + n)` which means in C, you can do the "wonderful" trick of `n[x]`.

Re:A Reply to “Let’s stop copying C” by WalterBright on Sunday January 26, 2020 @02:08AM (#22150903)
> But the political problems are huge.

That's true. But there are no technical problems with it, not even backwards compatibility problems.

Re:A Reply to “Let’s stop copying C” by Gibbon1 on Sunday January 26, 2020 @06:17PM (#22155554)
I feel like the resistance is people think pointers are C's secret sauce. Reality is the only advantage is it makes it easy to write bran damaged unopimized compilers for C. Which no one does. I remember back in the 90's my boss gave me shit for using array indexes instead of pointers. Being a brat I looked at the assembly and there was no difference.

Ditto the cultural proscription on passing/returning small stucts by value. In practice it's no worse than passing the arguments separately. And likely easier for the compiler to optimize around.

Re:A Reply to “Let’s stop copying C” by Animats on Sunday January 26, 2020 @09:37PM (#22156473)
Ditto the cultural proscription on passing/returning small stucts by value.

Which really should be a compiler decision. Depends on the target CPU. If you pass something as const ref, the compiler should copy it if that's faster. For AMD64, it probably is. If something was just written, it's in the L1 cache and is really cheap to copy. On-chip data buses today can be as wide as 64 bytes. Anything not bigger than that is better copied.