4 ms·
Traits are not like Concepts. Concepts are for template meta-programming. You're thinking of the "Contracts" proposal which would be like concepts but for norma
by zenbsd 11y ago
Traits are not like Concepts. Concepts are for template meta-programming. You're thinking of the "Contracts" proposal which would be like concepts but for normal types, so like traits.
Also, can we have a C++ article where the comment section doesn't turn into a Rust ad?
- deleted 11y ago[deleted]
- 0xCMP 11y agoWe could if C++ wasn't so complicated, overwhelming, and prone to writing bad code that everyone feels compelled to replace it and going as far as starting a project like Rust to solve the issues Python or Go do for C++ with the same level of zero-cost abstractions. Devil's Advocate: C++ may be complicated, but try comparing hello worlds in each language. Maybe Rust still isn't the holy grail either.
- lambda 11y agoRust: fn main() { println!("Hello, world!"); } C++: #include <iostream> int main() { std::cout << "Hello, world!"; }
- masklinn 11y agoThe Rust version adds a newline (hence println) while the C++ version doesn't. Either the Rust version should use `print!`, or the C++ version needs an `<< std::endl`
- claudius 11y agoAdding '\n' to the string is perfectly fine, no std::endl needed (\n translates to the system-specific newline and the stream is flushed on destruction anyways).
- jguegant 11y agoYou just reached the Rustwin's point of Hackernews: "As a discussion about C++ or C grows longer, the probability of a comparison involving Rust, as a savior, approaches 1. Afterwards any further discussion is considered null and void".