you are viewing a single comment's thread.

view the rest of the comments →

[–]Vulptex[S] 1 insightful - 2 fun1 insightful - 1 fun2 insightful - 2 fun -  (0 children)

Oh no, what I mean is we're taught that it's a good practice to waste time coming up with intricate OOP structures instead of actually programming something. And they tell us to comment everything it's doing when it's completely obvious, as if a non-programmer should be able to read it, not to explain why you're doing something.

Code is still written in C (as well as C++ and some more esoteric languages) because existing codebases use those languages.

And also because those languages still suit a lot of things better than others. C and C++ aren't dead, new projects are started in them all the time.

Currently that would be JS and Node JS. A while ago it would have been Python, and Java before that.

Holy shit hell no not javascript that's a nightmare. It never works right and you have callback hell and a bunch of other crap. If you think C is hard JS is 100x harder. Python is easier, but very slow and not too powerful. Java is easier but not as powerful and a bit slower. But the real reason those languages are easier is because of the abundance of libraries available for them, not because the language itself is inherently easier.

one of the main abstractions of C++ is RAII and specifically move/copy constructors.

Yes, those are in C too. You just have to actually do them instead of hiding them behind an interface that makes it look like nothing much is happening.

In conjunction with references and const declarations, these allow you to describe the ownership of an object and safely pass it between various scopes.

C has const, and references are the same thing as pointers.

Whereas in C, you're passing around raw primitives/structs, pointers to those primitives/structs, and pointers to functions, which all give the compiler none of the context it needs to effectively inline function calls or remove unnecessary initialization/copying.

Can you give me an example? Classes and other abstractions would usually prevent the compiler from being able to make those optimizations, not help it. The only exception is templates, which can be done in C, even though people don't use them for some reason. You just can't mangle the names of the generated functions (which makes sense, so you get the expected assembly output). And nowadays even that might not matter, because compilers are starting to make indirect function inlines.