News for hackers. Stuff that matters.
Re:The Rust I wanted had no future by pjmlp on Monday June 05, 2023 @10:33AM (#36196695)
In C++ it is an error, if one bothers to enable bounds checking.

https://godbolt.org/z/vYcMhE9h7

> Error: attempt to access an element in an empty container.

Re:The Rust I wanted had no future by dmm on Monday June 05, 2023 @10:52AM (#36196987)
Someone much more insightful than me pointed out that most of the safety advantages of Rust are really a cultural phenomenon, rather than a strictly technical one. You could write unsafe unsafe Rust that derefs invalid pointers all day but when building systems and libraries with Rust, people value safety and Rust enables that as a priority.
Re:The Rust I wanted had no future by pjmlp on Monday June 05, 2023 @11:00AM (#36197131)
Yes, that is kind of true.

It is also what attracted me into C++ coming from Turbo Pascal and Turbo Basic, back in the early 1990's.

Although C++ culture could be much better towards safety, it is definitely better than whatever WG14 is doing, or C has brought into the picture for the last 50 years.

Also anyone that just copy pastes C like code into C++, is the kind of developer that will be using unsafe{} all over the place, on the languages that have them.

Re:The Rust I wanted had no future by imtringued on Monday June 05, 2023 @11:50AM (#36198082)
Telling people to stop using unsafe is much easier than telling people to not have undefined behaviour.

C developers like telling themselves that only people with bounded rationality make security critical mistakes. All the skilled C developers have ascended beyond the mortal realm and would never let themselves be chained up with crutches for the weak like affine types or overflow/bounds checking.

Re:The Rust I wanted had no future by worik on Monday June 05, 2023 @04:27PM (#36203089)
> a cultural phenomenon, rather than a strictly technical one. You could write unsafe unsafe Rust that derefs invalid pointers all day

Yes you could. But I do not think " cultural" is the right term for not putting all your code in an `unsafe` block

Re:The Rust I wanted had no future by Ygg2 on Tuesday June 06, 2023 @05:48AM (#36210391)
> Someone much more insightful than me pointed out that most of the safety advantages of Rust are really a cultural phenomenon, rather than a strictly technical one

It's not. It's a safety phenomenon. See Java, C# etc.

Java doesn't have huge focus on it, but managed to get it right.

Re:The Rust I wanted had no future by Ygg2 on Monday June 05, 2023 @12:16PM (#36198517)
It's not an error by default and more importantly it's not an error under right circumstances (e.g. lets say number of pops and inserts is supplied via arguments).
Re:The Rust I wanted had no future by pjmlp on Monday June 05, 2023 @03:46PM (#36202470)
Yes defaults matter, it doesn't change the fact that protective gear is available, and like seatbelts, helmets and motorrad full body armour, it is up for security conscious people to make do of what is made available to them.

As for your dynamic arguments request, have fun,

https://godbolt.org/z/YYKrnh4Y9

Re:The Rust I wanted had no future by Ygg2 on Monday June 05, 2023 @05:51PM (#36204399)
It's not just that defaults matter, the problem here is why have footgun as the default?

In a runtime example I can run it with tests and it would behave fine if both values are same or first arg is bigger, in Rust's case it would behave valid for ANY combination of arguments.

Re:The Rust I wanted had no future by pjmlp on Tuesday June 06, 2023 @03:09AM (#36209249)
Likewise with C++ if the safety belt is buckled.
Re:The Rust I wanted had no future by Ygg2 on Tuesday June 06, 2023 @05:36AM (#36210298)
Heavy disagree. This is less giving a safety belt and more like saying we got airbags (that are deadly without seatbelts) and a DIY seat belt is somewhere in there too (it's in a box under the seat).

Coming from Java the C++ stuff is jarringly unsafe.

Re:The Rust I wanted had no future by pjmlp on Tuesday June 06, 2023 @03:40PM (#36218072)
Agree that Java is much better than using raw C++.

Still, if you want to contribute to OpenJDK internals, they will only be taking pull requests in C++, not Rust.

So better learn how to build those seatbelts and airbags, for all the projects we rely on, including Rust's own reference implementation, that aren't going to rewrite their code from C++ into something else.