News for hackers. Stuff that matters.
Re:Beautiful Binary Search in D by 2h on Saturday February 18, 2023 @01:40PM (#34849679)
Agree. This just screams of being too clever. It's OK to repeat things sometimes. If you DRY to the point that the code is not even readable, is that really an improvement?

Also I physically shuddered when I saw the word template. Did no one learn from C++ mistakes?

Re:Beautiful Binary Search in D by mhh__ on Saturday February 18, 2023 @01:42PM (#34849714)
> Did no one learn from C++ mistakes?

D was designed by Walter Bright (who played a large role in inflicting C++ on the world) and Andrei Alexandrescu so you could say that...

Re:Beautiful Binary Search in D by ternaryoperator on Saturday February 18, 2023 @04:52PM (#34851483)
> D was designed by Walter Bright (who played a large role in inflicting C++ on the world)

That's a rather unfair characterization. He wrote the Datalight/Zortech C++ compiler. He was never--that I recall--a big flag-waver for C++.

Re:Beautiful Binary Search in D by mhh__ on Saturday February 18, 2023 @05:53PM (#34851935)
His company originally was a C++ toolchain shop.

Anyway, I was joking — Walter did one of the first (if not the first?) "Proper" C++ compilers, so the idea of not learning from C++ is rather ironic.

Re:Beautiful Binary Search in D by btschaegg on Saturday February 18, 2023 @11:58PM (#34854601)
> Also I physically shuddered when I saw the word template. Did no one learn from C++ mistakes?

While we might disagree on a lot of semantical things on this, I'd argue that D very much learned from those mistakes. There's a strong argument for D's templates to be "templates done right" (which C++'s most certainly aren't).

So I encourage you to read more into this topic. To me, this question seems just about as uninformed as someone complaining about a LISP tutorial on macros, asking "did no one learn from the mistake that is the C preprocessor?".

If/where there are other models better suited for metaprogramming would be another (interesting) discussion (full of tradeoffs, I'm sure), but the notion of proper (hygienic?) templates not being adequate anywhere can certainly not be inferred from C++'s implementation alone.