Hacker News new | past | comments | ask | show | jobs | submit login

Imho, C++ should be thought of as a new language with a degree of backward compatibility with old C code, not as a 'bigger C'.

How I'd start:

    Lesson 1: Pointers don't exist in C++, we 
       have references.
    Lesson 2: malloc() doesn't exist in C++
    Lesson 3: Templates are awesome.
    Lesson 4: Smart pointers are awesome.
    Lesson 5: 'Structs' can have constructors, and 
       they're awesome!
    Lesson 5.5: Exceptions are awesome!
    Lesson 6: 'Structs' can have copy constructors and 
       assignment operators, but the default ones do 
       exactly what you'd expect so you shouldn't have 
       to write them often.
    Lesson 7: OK, OK... pointers still exist in C++ but
       smart pointers and references make them almost
       deprecated, right?
    Lesson 8: ...oh, and if you use raw C pointers you
      need to do all this extra donkey work when it 
      comes to handling exceptions, and write a lot 
      more of those pesky copy and move constructors 
      and assignment operators I told you you didn't 
      need to write.
      Example: writing a smart pointer (with C pointers!)
    Lesson 9: Implementing a safe, dynamic, exception-safe
      array in C++ using templates and C pointers.
    Lesson 10: back to sanity, the ease of using <vector>
      (or the output of lesson 9) in every day code. 
       Introduction to the STL, <string>, etc.
...and so on. The idea is to first teach the common C++ way, and then teach the penalty of ignoring it and going the C way, and then the places where you need to pay that penalty.

Imho teaching inheritance or virtual functions early is also a bad sign. I'd go with public/private access control first (leaving protected), then member functions, then pure virtual member functions and basic inheritance, all the while presenting no hint of Circles and Ellipses, just interfaces.

This is the approach taken by Bjarne in his new book "Tour of C++".

I tend to bash C and C++ a lot given their unsafe by default nature as a Pascal refugee, but at least C++ can be made safe when the right abstractions are used and I do like it anyway.

The instructor's (self-written) textbook gets terrible reviews on Amazon. Not a good sign.


What's wrong with handling errors with status codes as opposed to exceptions? Just because it exists doesn't mean one has to use it, no?

Exceptions allow you to leverage value semantics and safe reference semantic abstractions like smart pointers. If you fail to handle them properly you will also discover bugs a lot sooner.

Applications are open for YC Winter 2020

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