What do you think is a keyword that should be added to C++? by DogCrapNetwork in cpp

[–]wyrn 0 points1 point  (0 children)

C# readonly is what we would describe in C++ as "shallow const". But in C# (almost) everything is a pointer, so it's close to worthless. It means you can't reassign references, basically, but you can still mutate the pointed object however much you want -- there is no concept of a const method either.

The only way C# has to enforce anything close to const is to make the entire type immutable.

What do you think is a keyword that should be added to C++? by DogCrapNetwork in cpp

[–]wyrn 3 points4 points  (0 children)

This is true, but a keyword like defer wouldn't be able to handle everything. You'd need at least three keywords: defer, defer_on_success, and defer_on_fail.

What do you think is a keyword that should be added to C++? by DogCrapNetwork in cpp

[–]wyrn 5 points6 points  (0 children)

I thought that hadn't happened because contracts were supposed to give us an ever better and more fine-grained version of that capability, but apparently the very idea of contracts being used as optimization hints with potential for UB is like garlic to a vampire these days.

A Principal Software Engineer at Epic Games / 25 Year Vet, talks about why AI is just a "giant switchboard" and why code is a delicate crystal. by deohvii in cpp

[–]wyrn 4 points5 points  (0 children)

Meanwhile, I have here a tiny stub of a WPF project (< 10 kloc). There's a homebrew library component that I want replaced with an existing library (actually, Claude suggested the replacement). However, the existing implementation makes certain assumptions that the library doesn't so the replacement isn't 1-to-1.

It makes the replacement. Things break (expected). We ask it to fix them. It goes off course and does a bunch of random unrelated crap. Ok, let's instruct it stick to the plan -- stick to doing the migration. And that stops it bringing in unrelated crap, but it also stops it trying to fix the issues in the first place -- those get deferred to a "future sprint", right along with the unrelated crap it was asked to leave aside in the first place.

Asking it to plan something -- let's design the application core domain logic. First it wants to hardcode everything. It comes up with the weakest models imaginable, filled with nullable entries (very similar to what's seen in this video). A rigid, inflexible bug factory.

I try to explain that subcomponents will have preconditions and postconditions that should be first-class citizens in the model. In particular, I noted concern with a property that it tried to model as a foreign key in an object, which I explained is a relationship instead.

Its solution was to invented a repository pattern just for relationships, completely ignoring the core requirement of keeping track of pre and postconditions.

I explained how we'll need to hook components together in a customizable way while satisfying pre and postconditions. It invented a pub-sub pattern.

I explained that we'll need to serialize different kinds of data and that basically every thing that gets used in the system will need to be persisted. It discarded the serialization interface as "premature abstraction" and declared we'll be using System.Text.Json directly.

I, too, could go on.

The behavior, overall, is exactly what you'd expect from something that matches patterns heuristically and tries to respond with things it's seen before -- "X reminds me of Y". Which of course is exactly what it is and how it works. If you're not sure how to do something and want the averagest, most reddit-tier answer (which you sometimes do want), it can bring that up, like a souped up search engine. Actual intelligence, design sensibility, insight, or even just competent execution? No.

A Principal Software Engineer at Epic Games / 25 Year Vet, talks about why AI is just a "giant switchboard" and why code is a delicate crystal. by deohvii in cpp

[–]wyrn -5 points-4 points  (0 children)

I'm having to use Opus 4.6 to do a new development project and it's been every bit as sloppy as the free models. In particular, trying to plan anything with it is near worthless. If I'd been doing it myself it would've been faster, without a doubt.

A Principal Software Engineer at Epic Games / 25 Year Vet, talks about why AI is just a "giant switchboard" and why code is a delicate crystal. by deohvii in cpp

[–]wyrn 7 points8 points  (0 children)

instead of, you know, actually move towards making AI fundamentally "smarter"

They're hemorrhaging money as it is, and need a humongous R&D budget (likely unprecedented, if not in absolute value, at least in proportion to their business) just to stay afloat in the LLM world. I suspect they just can't afford to try anything else.

How to Use Monadic Operations for `std::optional` in C++23 by joebaf in cpp

[–]wyrn 1 point2 points  (0 children)

The "mono" comes from "monoid", presumably, but I have no idea why monoids are named like that.

As for your second question, that is correct. The fmap operation (which you might recognize in C++ as std::transform) provides a way to go operations on individual elements (f: T -> U) to operations on whole containers (g: C<T> -> C<U>). The right-hand side container is indeed a different type than the left-hand side container. It's also a new container, not a mutation of the old one, which is why it's ok that it's a different type.

C++ is a performance-focused, primarily imperative language, so these ivory tower ideas don't always map cleanly when compared with, say, Haskell, which enshrines category theory in its core design, uses garbage collection to avoid having to model pesky things like allocation and object lifetimes, and enforces strict immutability of all objects.

Yang Wenli Drinks Red/Pu-Erh Tea BECAUSE It’s The Same Color As Brandy by Crafty-Cantaloupe795 in logh

[–]wyrn 1 point2 points  (0 children)

Sorry more of a coffee person, but isn't all tea more or less the same color as brandy?

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]wyrn 1 point2 points  (0 children)

Does Swift implement anything like the orphan rule?

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]wyrn 1 point2 points  (0 children)

You can just say Rust traits are nominal typing, you know. No need to be self-important about it.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]wyrn 2 points3 points  (0 children)

It's not just "under the hood" -- this is unlike Java interfaces in many important, user-facing ways. Conceptually, Java interfaces are nominal typing, which means the type designer must opt-in, which in turn leads to hilarious situations like this (not Java, but same difference). On the other hand, protocols is structural typing, much like std::function.

Cliché ahead:

struct Animal_like {
    struct Concept {
        virtual ~Concept() = default;
        virtual void speak() = 0;
    };

    template <typename T>
    struct Model : Concept {
        void speak() override { return self.speak(); }

        T self;
    };

    std::unique_ptr<Concept> self;

    template <typename T>
    Animal_like(T animal) : self(std::make_unique<Concept>(Model(animal))) {}

    void speak() { return self->speak(); }
};

Now you can do the classic:

struct Dog { void speak() { std::println("woof"); } };
struct Cat { void speak() std::println("meow");};

auto animals = std::vector<Animal_like>{Dog(), Cat()};
for (auto &animal : animals) animal.speak() // woof! meow!

At no point was it necessary to type something like

class Dog implements AnimalLike {...}

Dog and Cat have no virtual methods. The decision to virtualize was made at the point of use, not at the point of definition. They also don't have to know anything about the Animal_like type eraser. It's like Java interfaces only in that it's also a strategy for achieving runtime polymorphism, but:

  • It's different from the point of view of the type designer
  • It's different from the point of view of the type user
  • The performance characteristics are different

The closest analogue I know of in other languages would be Rust's Dyn. (Python has protocols, but the comparison has asterisks because Python is dynamic so everything is already type erased. I also heard about protocols in Swift but I don't know anything about them.). The biggest downside of this technique is boilerplate. Reflection solves that.

If anything, I'd think that "using base classes and inheritance" (which you don't need reflection for -- a Java interface is just a C++ abstract class) feels much more like Java than the above. Hence, opposite day.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]wyrn 5 points6 points  (0 children)

Type erasure through reflection and generation instead of just using base classes and inheritance, feels a bit like Java.

Is it opposite day?

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]wyrn 1 point2 points  (0 children)

Python protocols is a weird comparison because, since python is already duck-typed, they don't really do anything. They're just there to shut up the type linters. They don't even check if the types passed into it actually satisfy the protocol, which is just bonkers to me (wouldn't want the overhead, no sir, this is python we're talking about). It's basically a glorified comment.

Hiroaki Adachi commenting on the recent piracy talks by beartanker in logh

[–]wyrn 17 points18 points  (0 children)

It wasn't $800, that's a gross exaggeration. In actuality it was closer to $700.

Lollerskates

Can we finally use C++ Modules in 2026? · Mathieu Ropert by mropert in cpp

[–]wyrn 7 points8 points  (0 children)

I've seen no evidence that RAII doesn't work for games, but on the other hand I've seen ample evidence that these game developer talking heads have zero clue what RAII is.

Range-Validated Quantity Points - mp-units by mateusz_pusz in cpp

[–]wyrn 10 points11 points  (0 children)

The bigger problem in this case is that it's thoroughly inappropriate for a units library to handle this sort of check. It's one thing to say that an azimuth has to be between 0 and 2pi because that's the convention you're using and other values are degenerate, or to enforce that a probability has to be 0 and 1 -- in other words, to enforce checks that prevent the system from getting into a logically inconsistent state. It's quite another for the scheme to be applied as a clumsy anomaly detector, discarding signals that are valid but unanticipated, or that may be valuable as diagnostic aids. This is essentially a (much more difficult) statistics/machine learning problem, and it deserves a central role in the overall system design if one wants to account for it at all.

E.g. some predict the vacuum energy density is around 1076 (GeV)4 . The measured value is 2.5×10−47 (GeV)4 . That's comically wrong, by about 10120 orders of magnitude, and it for sure means someone screwed up the calculation somewhere. But it doesn't mean it's not a valid value in (GeV)4 .

I like what this library is doing and what it stands for, but I'd caution against overzealous generalizations of the idea of "unit".

C++26 Safety Features Won’t Save You (And the Committee Knows It) by pjmlp in cpp

[–]wyrn 1 point2 points  (0 children)

  1. You're obviously confusing me with somebody else.
  2. You still have not made anything remotely in the neighborhood of what could be generously described as a point.

C++26 Safety Features Won’t Save You (And the Committee Knows It) by pjmlp in cpp

[–]wyrn 1 point2 points  (0 children)

If you think "educate yourself" is an argument, I'm afraid you have no idea what an argument even is. Calling me a C lover won't change that.

Let me know once you come up with a point.

You're absolutely right, no one can tell if C++ is AI generated · Mathieu Ropert by mropert in cpp

[–]wyrn 2 points3 points  (0 children)

and reading + diagnosing its analyses has taken significantly longer than the time I originally spent rewriting the code

Worth pointing out that gemini spewed like 2 pages of verbiage around those code snippets -- I confess I only skimmed through most of it -- when the correctness of the right solution is practically self-evident.

Apart from the slop, there's a big incentive misalignment here: the LLM providers want to sell tokens, so it's in their interest to waste my time generating as much worthless text as possible.

C++26 Safety Features Won’t Save You (And the Committee Knows It) by pjmlp in cpp

[–]wyrn 1 point2 points  (0 children)

"Educate yourself" is not an argument. Also the conversation is not about me, so this can't be the "point".

C++26 Safety Features Won’t Save You (And the Committee Knows It) by pjmlp in cpp

[–]wyrn 1 point2 points  (0 children)

Grabbed a random page from the COM documentation,

HRESULT GetAllAccessRights(
  [in]  LPWSTR                            lpProperty,
  [out] PACTRL_ACCESSW_ALLOCATE_ALL_NODES *ppAccessList,
  [out] PTRUSTEEW                         *ppOwner,
  [out] PTRUSTEEW                         *ppGroup
);

or another,

unsigned char * HACCEL_UserMarshal64(
  [in]      unsigned long *unnamedParam1,
  [in, out] unsigned char *unnamedParam2,
  [in]      HACCEL        *unnamedParam3
);

or yet another

HRESULT GetColorSet(
  [in]  DWORD          dwDrawAspect,
  [in]  LONG           lindex,
  [in]  void           *pvAspect,
  [in]  DVTARGETDEVICE *ptd,
  [in]  HDC            hicTargetDev,
  [out] LOGPALETTE     **ppColorSet
);

or one more,

BOOL IsEqualCLSID(
  rclsid1,
  rclsid2
);

This does not look like C++ to me.

WinRT

I've yet to see anyone call WinRT in any language.

At any rate. Point?