Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Counterpoint to the C++ fragment in "Error handling" section:

  void foo()
  {
    Matrix *a = new Matrix(1000, 1000);
    Matrix *b = new Matrix(1000, 1000);
    
    delete b;
    delete a;
  }
Pretending exceptions solve error handling gets you a big fat zero. Look at boost: despite being written by C++ experts and held up as an excellent library (which it is!), it contains exception-unsafe portions. Why? Total exception safety is just as hard as the original error handling problem.


Counterpoint to your counterpoint:

  void foo()
  {
  	typedef std::auto_ptr<Matrix> matAP;
  	matAP a(new Matrix(1000, 1000));
  	matAP b(new Matrix(1000, 1000));
  }


I don't think it's because the Boost guys thought it "too hard". Having seen/used some of those libraries, I'm 100% sure they can handle the alleged "hardness".

C++ in general values performance over safety almost everywhere (just like C). That's probably why they made certain parts exception-unsafe.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: