Hacker News new | past | comments | ask | show | jobs | submit login

I'm not sure this is a useful distinction. I'm sure you're correct for whatever definition of "template metaprogramming" you're using, but Rust does have a pretty powerful generics system. That gets you most of the way to what C++ templates are used for, albeit less cruftily IMO. Coming at it from a different side, if a C++ person asks you, "does Rust have templates?", you're likely to say "no, but it does have generics which let you do most of what you need templates for". It's definitely enough to let you write complicated, over-general code if you want to. So in an informal context like this, the difference between "template metaprogramming" and generics is probably not one you want to stand on, at least not for your whole argument. There's lots of better arguments to make even if you accept Animats' language.



The claim that Rust's generics system is "fancy template cruft" on top of "all the complexity of C++" is absurd, though.


Yes, which is why I carefully phrased my post to avoid any implication that I might agree with that claim. To nevertheless get a reply like this is profoundly irritating.


I'm sorry.


It's a little unfair to unload on you, I'm just sick to hell of straw men, and it feels like there's no way to make sure people will engage with what I'm actually saying target than what they think I'm saying. It's a pervasive problem. :/


Template metaprogramming is the ability to e.g. say

int x = factorial<5>::value;

and have 'x' initialized to "120" (i.e. execute computation at compile time, not just define new types). Can you do anything like that in Rust? I only read a few about Rust, but my feeling was that it has powerful generics, but NOT template metaprogramming.


We just accepted an RFC for this. So not today's Rust, but tomorrow's.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: