logoalt Hacker News

We have traits at home

14 points • by Ygg2 • yesterday at 11:24 PM • 2 comments • view on HN

Comments

Panzerschrek • today at 8:42 AM

I see little to no benefits of introducing such "traits" into a language having duck-typing in templates. It may sometimes improve code readability (slightly), but with more boilerplate code for traits handling in exchange. And the result machine code will be identical to code with no traits at all (with only duck-typing).

C++ is a good example of this. It had duck-typing in templates for decades. Then some sort of trait-like mechanism named concepts has been introduced. The only benefit of them seems to be slightly better error messages if someone misuses a template class/function.

no1guangming • today at 8:17 AM

Can't load the page