Swift mention in C++ safety post

Chandler Carruth, of C++ and Carbon, recently blogged about the trend towards safety in languages, citing Swift and other safer languages a couple times.

He links a recent google blog post that only showed a small regression of "0.3% for bounds checks in all the standard library types!" Has anything changed in modern hardware to enable this or it purely a matter of tracking and optimizing away extra bounds checks in languages better? Presumably the new Vector proposal will provide more opportunities for such compiler optimization.

He also writes about Swift:

"With that in mind, it is important to consider whether this changes how we should expect temporal safety to work in C and C++ ā€“ should it throw into question the widely held belief that this cannot be automatically provided at a tolerable cost? Have our measurements been biased by hitting some systematically ignored but fundamentally solvable problem in our compilers and optimizers?

So far when doing that re-examination, Iā€™m not seeing enough indications. The costs largely seem much more fundamental and inescapable in the way that they must be represented when using a fundamentally unsafe language like C or C++ ā€“ the kinds of interactions guarded against are often non-local and involve indirections through memory and data structures.

The closest place I see here that might have changed is in reference counting. I think there is some compelling evidence that for smaller systems (phones, laptops, things attached to batteries), the cost in cache traffic and potentially synchronization overhead is marginal at best. Swift I think has shown strong evidence that with some investment in optimization infrastructure and careful implementation, reference counting can be extremely efficient on these processors. However, so far I still see evidence that those costs scale poorly to large server processors with 100s of cores and huge, complex cache hierarchies. We also, in large part thanks to Swift, are getting more realistic numbers here with infrastructure that is aware of the overhead. Still, an area worth keeping an eye on going forward I think."

What do those keeping an eye on it here think, at both ends of the scale?

3 Likes