News for hackers. Stuff that matters.
Re:How fast can you allocate a large block of memory in C++? by asdfasgasdgasdg on Thursday January 16, 2020 @12:52AM (#22062008)
I think the evidence is pretty clear that programmers can't, in general, use bare pointers properly. The very best write use after free, double free, stack smashers, and all manner of other memory related bugs. We can see the evidence of this fact in the CVEs, the syzkaller bugs, etc. If you haven't been bitten by a serious instance of one of these, then you just haven't written very much C++.

IMO the debate about whether programmers can safely handle bare pointers is over. They can't. The only question is whether smart pointers help enough to make the extra line noise worth it.

Re:How fast can you allocate a large block of memory in C++? by choeger on Thursday January 16, 2020 @02:10AM (#22062271)
And the guys that implement smart pointers are what, exactly? Uberprogrammers? Is there a certificate to get into that club? What about compiler authors, that deal with, gasp, optimizations of these bare pointers? Kernel developers? Embedded system engineers?

It is ok to stay above a certain level of abstractions consciously, but stating that one cannot go below safely is just steadying mediocrity.

Re:How fast can you allocate a large block of memory in C++? by lmm on Thursday January 16, 2020 @02:19AM (#22062316)
> And the guys that implement smart pointers are what, exactly? Uberprogrammers? Is there a certificate to get into that club? What about compiler authors, that deal with, gasp, optimizations of these bare pointers? Kernel developers? Embedded system engineers?

One cannot do any of those things safely by hand. Compilers, kernels, and embedded systems do indeed do these things; they also have bugs.

Re:How fast can you allocate a large block of memory in C++? by choeger on Thursday January 16, 2020 @03:56PM (#22068814)
You are contradicting yourself. If one cannot do these things safely by hand, then noone can implement the automatic abstractions either.
Re:How fast can you allocate a large block of memory in C++? by rcxdude on Friday January 17, 2020 @03:04PM (#22078637)
You cannot safely control an internal combustion engine's valve timings by hand, but it is clearly possible to implement this automatically (and fairly simply). Some things are much easier for machines to do than humans, even though the machines are designed and build by humans.
Re:How fast can you allocate a large block of memory in C++? by pjmlp on Thursday January 16, 2020 @07:08AM (#22063754)
> Is there a certificate to get into that club?

There is and the large majority fails at it, as proven by the CVE database, in spite the rigorous process to contribute code to the Linux kernel for example.

Re:How fast can you allocate a large block of memory in C++? by choeger on Thursday January 16, 2020 @03:57PM (#22068823)
I call bullshit. And arrogant bullshit at that. The wast majority of bare metal components is highly functional and relatively bug free.
Re:How fast can you allocate a large block of memory in C++? by pjmlp on Thursday January 16, 2020 @06:21PM (#22070171)
You can call whatever you like, CVE database, yearly security reports, and OS release notes from all major OSes provide the necessary facts.

Sadly liability still isn't a thing on software development.

Re:How fast can you allocate a large block of memory in C++? by rcxdude on Friday January 17, 2020 @03:02PM (#22078603)
That's not the point. Smart pointer implementations aren't some dark magic, they're just the opposite: mostly fairly simple to implement (shared_ptr is a little trickier), and obviously right by construction: the compiler does the hard work of making sure the constructors and destructors get called appropriately (and this is a little harder but still far far easier than making sure that malloc() and free() match in all actual uses).