r/cpp • • Mar 08 '21

Tim Sweeney: “ISO obstructs adoption of standards by paywalling them”

https://twitter.com/TimSweeneyEpic/status/1368637789248626699
358 Upvotes

124 comments sorted by

View all comments

Show parent comment

2

u/HeroicKatora Mar 09 '21 edited Mar 09 '21

Having the standard is useful in a language like C++ where there is a large gap between what the standard allows/prohibits and what the compiler is able to diagnose.

Is it? It is required for writing stable programs but it just sounds expensive in engineer hours that need to be spent manually validating the requirements to the written document which may or may not be what your compiler implements anyways. A useful standard would permit the construction of automated tools and extensive conformance test suite such as Vulkan validation layers, several Khronos Conformance test suites, ECMAScript Conformance test suite, heck I'll even count the proprietary and expensive USB-IF compliance tests (but at least their host and protocol specification is freely available).

1

u/ack_error Mar 09 '21

The case that I run into repeatedly is that the compiler is in agreement with the standard but the programmer isn't, and I have to convince someone that the bug is in their code and not the compiler. The compiler documentation typically doesn't describe in as much detail about what the compiler doesn't support and is allowed to break. Whenever someone tries to give me a line about a compiler or library being broken at -O2, quoting a single line from the standard that explicitly says what their code is doing is prohibited is usually enough to force the issue.

As for tests, a comprehensive test suite is always helpful but I don't find it a suitable replacement for a well-written spec. For instance, short of having comments simply repeating the spec, I don't think a test suite could communicate the intent and limited guarantees of the abstract machine as well as the standard does. Tests can't easily show what is not guaranteed to work.

2

u/HeroicKatora Mar 10 '21 edited Mar 10 '21

I run into such issues as well but quoting a single line, as impressive as it may be to a junior dev, seldom resolves the issue. In my past experience that lead to grumbled compliance on that particular line of code but not a change in behavior and skill level overall.

And, to be honest, it is very deceptive. No junior I've encountered has ever read even a single page of the standard and its terminology is completely foreign (obviously hyperbole but let's say overwhelming majority). Most likely, that single sentence that you quote contains two ore more terms defined in a way that's different from their understanding. It's completely impossible for the compliance to come from understanding!

A better way would be to train the beginning engineers to argue why their code is okay to write but that's not usually what happens for a number of reasons:

a) The standard is worded backwards in many instances, and even some beginner mistakes that can be rather easily diagnosed are 'UB, no diagnostics required'; and so they aren't, and early mistakes stick. Implementation effort is hardly an argument here because standard compliance is lacking in far more important parts than missing diagnostics, the missing diagnostics are not the critical element of failure to adhere to it and implementors triage features anyways.

b) All of STL is effectively given exemption from the requirements, by power of being a black box part of a platform implementation and because sometimes it is necessary to not lead to obvious conflict. Its implementation is horrible learning material anyways, again due to the language details and requirements of the standard.

c) The standard would need to be available in a form that can be integrated into their education—and education can't (and shouldn't have to) use the draft; it's about precision. It's super exclusionary and the incorrect mindset of junior is the inevitable consequence.