HN user

dabitude

19 karma
Posts0
Comments10
View on HN
No posts found.

In schools, there is a lot of violence and aggressivity. Kids hit, lie, steal, call names, harass. When two kids are fighting, they frequently are both punished even if actually one was only defending themselves and was in the right. Sometimes the whole class is punished for the misbehaving of a few.

We would not accept being treated like this as adults, but yet we have no problems putting our kids through this.

I work without exceptions, and the typical solution is to crash the whole program (using assert) if the parameter is invalid. This way you can preserve the invariant.

To avoid crashing, the caller has to validate the parameters before calling the constructor, and handle the invalid parameters at this time rather than in the exception handler, but in the end it's the same.

You don't need a benchmark. Given any C code, you can make a C++ code that runs as fast (just use the same code). This proves that C++ is at least as fast as C.

From there, maybe you could use C++ features to improve the speed (and then C++ is faster) or you could not (and then they have the same speed).

This is a pretty bad article.

In the last example (which is actually the most common case in practice), they give wrong instructions. They should only revert the bad commit, not all the following commits. Reverting everything is impractical and useless, and if you want to do that you may as well use revert (which is still a bad idea).