Earlier quoted context omitted.
I'm not saying it doesn't matter. It just clearly doesn't matter enough on modern common non-tso CPUs enough to motivate anybody to add the compiler support. The history of the whole thing is very interesting.
As I understand it, it's the other way around: for x86 (which is TSO) the fence doesn't really matter because the "normal" load is already slowed down, but for ARM it does matter quite a bit, see e.g. [0] (admittedly old blog post) slightly lower on the page. But perhaps we did get to the point where even ARM CPUs and surrounding memory is already performant enough so that spurious fences aren't as noticeable. [0] ht…
C++26 is done: ISO C++ standards meeting Trip Report
421–430 of 437 posts
Re: C++26 is done: ISO C++ standards meeting Trip Report
#422Earlier quoted context omitted.
I can't tell if you imagine std::optional is a value (it is not) or if you know it's a templated type but you imagine that somehow it would be OK to redefine all programs so that every type is std::optional of that type instead so as to simplify initialization. Either way no, that can't work.
> Either way no, that can't work. Kotlin has explicit nullable types. Rust has no null, but has option types. Both languages work fine. I think your point was that neither approach could reasonably be retrofitted to C++, do I have that right?
I don't write Kotlin, so I can't speak to the details there.
C++ like Rust does not require that types have a default. In C++ the way you provide a "default" is usually via a zero argument constructor, since the compiler can just call that wherever you asked for an instance of that type and there's no requirement to write such a constructor, or indeed to provide any public constructor at all. So "just use the default" could not work in C++ as it exists today yes.
The other reason C++ can't do anything like this is that it makes a newer C++ with this behaviour behave differently despite no syntactical change. Rust is OK with that, because it has the Edition system to differentiate Rust 2015 code which means one thing from Rust 2024 code which means something else despite having the same text, but in C++ they do not have anything like that, it's not rare for somebody's C++ 17 code to get compiled in C++ 23 and people expect that to work (it doesn't always work but that's what they expect).
Re: C++26 is done: ISO C++ standards meeting Trip Report
#423Earlier quoted context omitted.
To me, the most important feature of Cargo isn't even the dependency management but that I don't ever need to tell it which files to compile or where to find them. The fact that it knows to look for lib.rs or main.rs in src and then recursively find all my other modules without me needing to specify targets or anything like that is a killer feature on its own IMO. Over the past couple of years I've tried to clone and…
Yep ... go/zig pkg management has the same benefit compared to c/c++.
Re: C++26 is done: ISO C++ standards meeting Trip Report
#424Earlier quoted context omitted.
> If you have a genuine question you should ask one but please do not disguise so that it only goes to prove your point. I think my question is pretty simple: "How does an optimizer-independent expression template implementation work?" Evidently the resources I've found so far describe "optimizer-dependent expression templates", and apparently none of the "expression template" implementations I've had reason to look…
Expression templates do AST manipulation of expressions at compile time. Let's say you have a complex matrix expression that naively maps to multiple BLAS operations but can be reduced to a single BLAS call. With expression templates you can translate one to the other, this is a static manipulation that does not depend on compiler level. What does depend on the compiler is whether the incidental trivial function call…
How does that work on an implementation level? First thing that comes to mind is specialization, but I wouldn't be surprised if it were something else.
> What does depend on the compiler is whether the incidental trivial function calls to operators gets optimized away or not.
> Of course in many cases the optimization level does matter: if you are optimizing small vector operators to simd inlining will still be important.
Perhaps this is the source of my confusion; my uses of expression templates so far have generally been "simpler" ones which rely on the optimizer to unravel things. I haven't been exposed much to the kind of matrix/BLAS-related scenarios you describe.
Re: C++26 is done: ISO C++ standards meeting Trip Report
#425Earlier quoted context omitted.
Why should C++ stop improving? Other languages don't need C++ to die to beat it.
Half-serious reason: because with each C++ version, we seem to get less and less what we want and more and more inefficiency. In terms of language design and compiler implementation. Are we even at feature-completeness for C++20 on major compilers yet? (In an actually usable bug-free way, not an on-paper "completion".)
Also modules was a lot and was kind of the reason it took so long. They are wonderful and I want them but proper implementations (even with many details being implementation defined) required a lot of work to figure out.
Most of the time all the compilers get ahead of the actual release but in that case there were so many uncertainties only rough implementations were available beforehand and then post release they had to make adjustments to how they handled incremental compilation in a user facing way effectively.
Re: C++26 is done: ISO C++ standards meeting Trip Report
#426Earlier quoted context omitted.
Expression templates do AST manipulation of expressions at compile time. Let's say you have a complex matrix expression that naively maps to multiple BLAS operations but can be reduced to a single BLAS call. With expression templates you can translate one to the other, this is a static manipulation that does not depend on compiler level. What does depend on the compiler is whether the incidental trivial function call…
> With expression templates you can translate one to the other, this is a static manipulation that does not depend on compiler level. How does that work on an implementation level? First thing that comes to mind is specialization, but I wouldn't be surprised if it were something else. > What does depend on the compiler is whether the incidental trivial function calls to operators gets optimized away or not. > Of cour…
struct F { double x; };
enum Op { Add, Mul };
auto eval(F x) { return x.x; }
template struct Expr;
template struct Expr{ L l; R r;
friend auto eval(Expr self) { return eval(self.l) + eval(self.r); } };
template struct Expr{ L l; R r;
friend auto eval(Expr self) { return eval(self.l) * eval(self.r); } };
template struct Expr, R2, Add>{ Expr l; R2 r;
friend auto eval(Expr self) { return fma(eval(self.l.l), eval(self.l.r), eval(self.r));}};
template
auto operator +(L l, R r) { return Expr{l, r}; }
template
auto operator *(L l, R r) { return Expr{l, r}; }
double optimized(F x, F y, F z) { return eval(x * y + z); }
double non_optimized(F x, F y, F z) { return eval(x + y * z); }
Optimized always generates a call to fma, non-optimized does not. Use -O1 to see the difference (will inline trivial functions, but will not do other optimizations). -O0 also generates the fma, but it is lost in the noise.The magic happens by specifically matching the pattern Expr, R2, Add>; try to add a rule to optimize x+y*z as well.
Re: C++26 is done: ISO C++ standards meeting Trip Report
#427Earlier quoted context omitted.
C++ needs to give itself up and make way for other, newer, modern, language that have far, far fewer baggage. It should be working with other language to provide tools for interop and migration. C++ will never, ever be modern and comprehensible because of 1 and 1 reason alone: backward compatibility. It does not matter what version of C++ you are using, you are still using C with classes.
Why should C++ stop improving? Other languages don't need C++ to die to beat it.
Re: C++26 is done: ISO C++ standards meeting Trip Report
#428Earlier quoted context omitted.
Why should C++ stop improving? Other languages don't need C++ to die to beat it.
Ironically the C++ standards consortium doesn’t want C to improve anymore and wants people to just use C++. Rules for thee but not for me.
But I do think the frustration that C++ can no longer be a super set of C is overblown by C++.
Re: C++26 is done: ISO C++ standards meeting Trip Report
#429Earlier quoted context omitted.
You can't fundamentally solve the issue of what happens if you call a function in another TU that takes a T but the caller and the callee have a different definition of T. Whether you call that IFNDR or UB doesn't make much of a difference. C++ mitigates that issue with its mangling (which checks the type name is the same), Rust goes the extra mile and puts a hash of the whole definition of the arguments in the symbo…
C++ ODR requires different definition to consist of the same tokens, and if not the the program is IFNDR. Name mangling catches some stuff, but this becomes less relevant today with more things being generated via templates from headers. In C, it is UB when the types are not compatible, which is more robust. In practice it also easy to avoid with the same solution as in C++, i.e. there is a single header which declar…
Things being built piecemeal also likely won't be using LTO (even if fat LTO allows this, no static library packages in a distro are built with it).
Re: C++26 is done: ISO C++ standards meeting Trip Report
#430Earlier quoted context omitted.
Late nineties is approaching thirty decades ago; if the C++ committee has now been working on this for nearly a decade, that's fifteen to twenty years of them not working on it. It's quite plausible that contracts simply weren't valued at the time. Also, in my view the committee has been entertaining wider and wider language extensions. In 2016 there was a serious proposal for a graphics API based on (I think) Cairo.…
> Late nineties is approaching thirty decades ago Boy, this makes me feel old... oh wait :) (I agree with your point; early 90s vs. mid-10s are two very different worlds, in this context.)
So what was it like back in the Egyptian age? :)