@aud To be a little more precise, a function like `void foo(Bar bar)` and one like `fn foo<T: Bar>(bar: T) -> ()` are morally quite similar, if extremely different in literal meaning. They're both ways of saying "this function takes a value of any type that's Bar-like," but the former *also* adds that any individual value of a Bar-like type can be referred to by a binding of type Bar.
That's a very heavy additional assumption, and places severe constraints on how you organize code.
@aud So you can solve that with `T add<T>(T a, T b)`, but now you've lost the `Addable` constraint. The most common solution I've seen is to have `T add<T: Addable>(T a, T b)`.
But there's a word for "a collection of types that can be used to satisfy a constraint on valid type parameters." It's a typeclass, or in Rust terminology, a trait. Or in C++ terminology, a concept.
@cthos @aud @trochee Yeah, I almost made that point with the original post in my thread, where you have two very different ways of doing the same nominal thing, "define a function that acts on a Bar-like value."
Which one *should* an AI code generator do? Which one will an LLM trained on O(GitHub) do when it rolls the 1dOOP dice? Who knows!
@cthos @aud @trochee Like, the whole act of programming is to take some poorly defined goal, make that goal precise, come up with a design that would accomplish that goal, and then implementing that design.
You can't just YOLO your way through taking an imprecise goal to a precise and actionable goal!
@cthos "AI, sort this list for me." Motherfucker, *how*? Merge sort? Introspection sort? Bubble sort?
We even have a way of making that precise, and the AI bros just... don't do that! One of the few things I actually like about C++ is that the STL specifies things like sort in terms of guaranteed algorithmic complexity, rather than a specific algorithm, so you have a precise definition of what properties you're guaranteed when you call the STL's sort function.
@cthos But with AI? Who knows! Is your list nearly sorted? Do you need to sort it in-place? Do you need your sort to be stable under equivalence of the sorting key? Do you care more about worst-case or average-case performance?
Aaaaaaaaaaaaaaaa
@xgranade Listen, I just need it to do JortSort on everything.