4 ms·
> Even templates in C++ are notorious for puking near impossible to decipher errors. "Even"? I actually miss the macro-like power of templates when I'm using
by SloopJon 6y ago
> Even templates in C++ are notorious for puking near impossible to decipher errors.
"Even"? I actually miss the macro-like power of templates when I'm using generics in Java and C#, but generating the longest possible error message using templates is practically an Olympic sport. I presume that SFINAE is partially to blame, because a lot of the output enumerates all the candidates that didn't match.
- bcrosby95 6y agoThis is why I've always hated C++. Taking something like templates, and abusing the turing-completeness of it. If I wanted macros I would use a language that actually supports them so I wouldn't have to resort to byzantine hacks. Stuff like this is why lots of people would rather use C over C++.
- AnimalMuppet 6y agoDoesn't C++ exactly support C macros? In what way is using C macros "better" than using the exact same macros in C++?
- teleforce 6y agoD language is probably the Goldilocks of programming languages for the rest of us in terms of compilation speed (comparable to Go), program execution (comparable to C/C++) and ease of programming and debugging (comparable to Python). The author of the D language despises macro more than you, and has designed a solution for modern and sane approaches to template programming [1][2]. If you want to program like C in D modern eco system there is a safer betterC. Heck now there is even borrow checking capability if you want safety guarantees similar to Rust. [1]https://mobile.twitter.com/WalterBright/status/1343128003178541056 https://mobile.twitter.com/WalterBright/status/1343128003178... [2]https://dlang.org/blog/2018/03/29/std-variant-is-everything-cool-about-d/ https://dlang.org/blog/2018/03/29/std-variant-is-everything-...
- zwieback 6y agoI love-hate C++ templates because deep down they are just macros and you don't have to obsess about constraints like in Java and C#. To me it's pretty interesting how the three big static OO languages have implemented generics: super flexible permissive macros in C++ (with murderous error messages), type erasure in Java (gross) and actual generics in the runtime (C#). For everyday usage it doesn't matter much but I always like thinking about what's going on under the hood.
- kaba0 6y agoThis is my usual nitpick, but pretty much every language does type erasure and there is nothing bad with it, blahblah. Haskell is arguably great with types, and it does type erasure as well.