C++ guys hate static_if?

bearophile bearophileHUGS at lycos.com
Thu Mar 14 12:25:42 PDT 2013


Andrei Alexandrescu:

> A concept system would have helped me there if my intent was to 
> ship Kahan summation without ever testing it. That's not an 
> intent we want to cater for!

I think Issue 9715 isn't about Concepts.

- - - - -

Regarding the more general topic of Concepts (and their almost 
equivalent Typeclasses (http://dotat.at/tmp/p37-bernardy.pdf ) of 
the Rust language, or more powerful in Haskell), the argument you 
are proposing is exactly the same used by dynamic language 
proponents against static typing.

A difference is that adding a static type system to Ruby causes 
much larger changes compared to adding typeclasses to Rust (Rust 
didn't have typeclasses since recently. Rust used to have 
templates similar to C++, with some restrictions).

Haskell programmers have typeclasses, yet unit testing is done in 
Haskell, they have even invented a testing idea that was widely 
copied (QuickCheck).

Types (like ones of Typeclasses and Concepts) help avoid catch 
some bugs and shape your style of coding, the unittests avoid the 
other bugs and shape your coding, and contract programming 
catches other bugs and they too shape the way you code, for the 
better.

In the last Haskell version they have introduced a static type 
system at level of kinds, and it helps avoid some other bugs, or 
to catch them earlier.

For a Haskell programmer the great and numerous advantages of 
Concepts/Typeclasses are not in discussion. I think Rust 
programmers are now learning to appreciate them.

Bye,
bearophile


More information about the Digitalmars-d mailing list