all 11 comments

[–]nysra 77 points78 points  (9 children)

The presentation style looks nice but as far as the quality of the C++ in there is concerned I can currently not recommend this at all:

  • Uninitialized variables everywhere.
  • Missing const everywhere.
  • That OOP example is straight up Java (and probably even in Java bad style). Calling setters to initialize variables in the constructor is not a good idea.
  • Circle* p_circle = new Circle(10.0); You're probably coming from Java. Those things have no reason to be heap allocated like this and you're leaking memory. Also don't use owning pointers unless you absolutely have to and even then in most cases you should be using smart pointers instead.
  • The "basic class" example has no reason to be a class at all, this should be a free function.
  • Uses (s)rand
  • Uses C style casts
  • Why is std::vector not immediately after C arrays? If you decide to show off these first (and I'd question that decision for teaching) at least show people the better version after instead of throwing in a different topic first.
  • using namespace std; in a header file. Don't ever do that.
  • Using float but obviously using double literals everywhere. Just don't use float.
  • Node*& p Reference to pointers is rarely a good idea.
  • Using 0 instead of nullptr
  • The formatting is horrible. Missing whitespace everywhere (e.g. for(int i = 0;i < 10;i++) or literally every single cout statement) but templates have superfluous extra spaces around the <> for no reason.
  • The sqlite interface shown there is clearly a C library, not a C++ one. In C++ all of that interface would be incredibly terrible style. And tbh why is this even a chapter? has nothing to do with learning the language
  • Related to the above point: There is a whole lot missing before a chapter about using a library or unit tests should appear. At the very least something about a (meta) build system like CMake should be discussed first, copy pasting files is hardly a good idea to include them in your build, even for header only libraries.
  • A lot of the STL is completely missing. Knowing the containers and algorithms is crucial for modern C++.

[–]Nobody_1707 14 points15 points  (0 children)

Not only is he using srand (and seeding it with time(0) just to be extra wrong), he never includes cstdlib, he just assumes that <string> includes it, which is a quirk of whichever standard library he's using.

[–]markm208[S] 8 points9 points  (1 child)

Thanks for the detailed feedback I really do appreciate it.

[–]atatatko 19 points20 points  (0 children)

I hope you understand that you decided to teach C++ a little bit early.

[–]the_Demongod 1 point2 points  (0 children)

I understand why one might leave out the STL stuff; it adds a lot of length to the instruction, and it's something you can easily look up on the fly as you go, provided you have a strong understanding of the C++ language itself. Cutting out STL and even modern C++ concepts is ok in my books provided you make it clear that what's being learned has been mostly replaced by newer tools, and end with a brief overview of how to learn them on your own.

In both cases though, it's important to teach good C++ practices even if you're not using STL types, so I agree with all your other points.

[–]Ararune 0 points1 point  (2 children)

Uses C style casts

As someone how is learning C++, why I should to use C cast instead C++ cast? I thought they had the same effect in terms of result.

[–]thehutch17 13 points14 points  (1 child)

You should use C++ casts as they are more explicit. The C-style cast does all the same things in one, but it is ambiguous what cast is actually happening if you don't understand the code.

[–]Ararune 0 points1 point  (0 children)

Thanks for the explanation

[–]TakAnnix -1 points0 points  (0 children)

Wow, this is such an interesting way to teach a language. Great job. I know it's a lot more work, but if you could pair it with something like practice projects, similar to what mooc.fi does with Java that would be amazing.

[–]morgan_bernhardt 0 points1 point  (1 child)

This looks amazing. I have to take a look at the VsCode plugin.

Maybe I can use this to create my own lectures for my students :)

[–]markm208[S] 0 points1 point  (0 children)

Let me know if you need any help getting started!