News for hackers. Stuff that matters.
Re:Swift Regrets by tialaramex on Wednesday September 22, 2021 @02:43PM (#28620095)
C++ pays an extraordinary price for the fully parallel builds, concealed in the "One Definition Rule".

The price is, if you violate the ODR the standard says your program is not valid C++ (and thus has no defined meaning) but there is no requirement for a diagnostic (ie a compile or link error) and the build might complete.

This has sometimes been described as "False positives for the question is this a program?" and is a pretty serious penalty to pay for the benefit of improved compile time.

Re:Swift Regrets by germandiago on Wednesday September 22, 2021 @04:31PM (#28621376)
Modules mitigate in a big measure ODR violations. It will be quite more difficult. Compile times will also be better, at least incremental ones.
Re:Swift Regrets by novok on Wednesday September 22, 2021 @03:25PM (#28620642)
Could you have ODR and proper warnings / errors handling the issue when it pops up without much penalty?
Re:Swift Regrets by tialaramex on Thursday September 23, 2021 @03:56AM (#28626412)
No. ODR allows the compile step to be embarrassingly parallel. Since all the separate definitions of X are, by fiat, identical we needn't detect inconsistency at all and so there's no interaction, it's like merge sorting the files, you can spin up as many threads or processes as you like and process more source files.

If we decide "Oh, but I do want to detect inconsistencies, my users would want me to warn them about that" then we can't have the parallelization because we need to rendezvous constantly to verify the definitions are consistent.

There are a bunch of tricks that people do today to get some semblance of ODR checking for not too high a cost, and to avoid some ODR pitfalls that might defeat the checks they have. C++ programmers have accepted this danger, if you don't like it then C++ isn't the language for you.