5 ms·
NOT TRUE! You are doing it wrong If you are manually managing memory on Modern C++. C++ has RAII built in even before Rust came to the scene. I've never had
by cultyyy123 6y ago
NOT TRUE!
You are doing it wrong If you are manually managing memory on Modern C++.
C++ has RAII built in even before Rust came to the scene.
I've never had a situation where I had to manage memory manually during my professional career in C++
If your students face seg faults, please show them Valgrind. Valgrind is better than GDB when it comes to seg faults. It can show you where exactly error occurred.
Edit: Oh I got downvoted for saying truth. I now know what they are really up to.
- dagmx 6y agoI believe that statement from the person you're replying to was in comparison to the issues with teaching C not C++
- cultyyy123 6y agoNo. See what he said, "C++ is a little better because they have experience with Java, but they are frequently mystified by constructors/destructors and how to manage memory manually"
- ModernMech 6y agoYou still need to teach what the delete keyword is and how memory management works in C++. There's tons of code out there not written with smart pointers. And yes we use valgrind, but it's important not to overload students who are new to programming. Students tend to reach for withdrawal forms when you tell them "I see you are overwhelmed by this new tool you're learning. To solve this problem here's a new tool to learn". The near-universal sentiment I've gotten from students going from C/C++ to Rust is "Wow, this is so much nicer". YMMV.
- cultyyy123 6y ago"new" and "delete" considered as bad practices. You claimed that you don't have to teach Manual Memory management in Rust so why not do the same for C++? "Rust makes all of this go away. They don't have to manage their memory manually" Both C++ and Rust has manual memory management but rarely needed. Both supports RAII where everything managed automatically.
- ModernMech 6y ago> "new" and "delete" considered as bad practices. Depending on what kind of work you do, you may not have a choice as to whether you get to you smart pointers or not. Our students go into work with decades-old codebases littered with new and delete. They need to know what they do. > You claimed that you don't have to teach Manual Memory management in Rust so why not do the same for C++? Because there are no old rust codebases where manual memory management is an issue.
- cultyyy123 6y agoI have worked with decades old codebases. I use up-to-date compiler where you get to use smart pointers and all the Modern C++ features. It's your fault if you not teach them how to upgrade the compiler. There is zero risk when compiling C++98 with C++11. It's also student fault if he selects a company with C++98 codebase. The student shall do due diligence. It's my advice for you to teach the Modern C++ before driving into legacy C++ sort of like how you teach History. You start what's current then drive deep under. It builds intuition.
- ModernMech 6y agoOk. I'll take your advice and give it the consideration which it's due. Thanks for taking the time out of your day to create a throwaway account just to tell me how to do my job. Cheers.
- cultyyy123 6y agoUnfortunately, the C ++ Committee knows that universities do a terrible job teaching C ++, except the one Bjarne teaches. If you ask Bjarne, he will tell you the same things I said. A lot of universities stuck in C++98. It will takes them 1000 years to adopt C++20 tho. One of mistakes many universities do is teaching either C or Java before C++. I find C++ as a minimal OOP language to get head start. C++ -> Java -> C But if student is a complete noob to programming, I'd suggest to learn Javascript before going to C++ Again, this is to keep the intuition otherwise they will forget what they learnt. I wish if many universities listened to Kate Gregory talk. When you teach Java before C++, Students try to write C++ in Java Style (Eg with new and delete). I answer plenty questions of students on Reddit's cpp sub who are trying to write C++ in Java style. I might make a talk on this in CPPCon. When you teach C before C++, Students try to write C with Classes. But, as once Steve Jobs said, "I used to think that technology could help education. I’ve probably spearheaded giving away more computer equipment to schools than anybody else on the planet. But I’ve had to come to the inevitable conclusion that the problem is not one that technology can hope to solve. What’s wrong with education cannot be fixed with technology. No amount of technology will make a dent." You can laugh at me, that's okay. But truth is truth! By the way, This is my 50th throwaway account. I use them because I'm getting down voted to death when speaking in defense of C++.
- mlindner 5y ago> I've never had a situation where I had to manage memory manually during my professional career in C++ I don't know what kind of career you had but it's nothing like any C++ career I've ever heard of. Do you never allocate integers or other basic types on the heap? Do you never deal with C-strings? Do you never interact with C libraries? Do you never call posix functions? A C++ career is full of memory management. You got downvoted because it appears you're speaking from a lack of experience. Even if what you're saying is the truth, I would say you fell into a lucky niche that is unusual compared to the average C++ programmer.