I don't mind C++ code I wrote because I only use the subset of features I like and understand. The biggest problem of C++ is that everyone uses a different subset of the language and so trying to learn a new program every is like learning a new language.
People say you can simply avoid using the ugly parts of C++. The problem is that you still have to read and use code written by people who DO use those features.
There is a point where abstraction goes too far. EVERYTHING in C++ can mean something else. Macros, operator overloading and numerous features makes it extremely difficult.
Abstraction is good if you have a large code base and need to extend and modify the code. With a very good software architecture a similar convenience level can be achieved in C, but a) you have to be able to really really create such a good architecture and usually you notice too late all the oversights you made and b) if a new guy joins the team, you have to teach him a lot about how this architecture is too work. In contrast, every C++ developer knows how C++ inheritance works, so you have that covered already.
Abstraction is good, if you don't need bare metal access, but why on earth C++? It has features that don't matter if you need abstraction, but lacks features if you value it. It's like it takes the worst of both worlds: it's bad for if you need abstraction and it's bad if you need low level access.
@@powertomato In C++ you can do very low level things. In embedded systems that is important for a few things. A language that doesn't allow direct interaction with the hardware is not suitable for ended systems.
Many people told me Im the smartest guy that they ever met. So I bought an Unreal Engine C++ course, but the only thing I learned was that they lied to me.
Don't worry I'm a C++ dev myself for years, and I wanted to test Unreal Engine one day (without using Blueprints, so only using real coding with C++) and I quickly quited lol Unreal Engine C++ is like a new language by itself, everything from the original C++ is different, UE built their own garbage collector, they have built their own smart pointers, their own defines etc... It's liking learning a new language from scratch tbh.
@user-hl3qv8qg2s You would think that, but there are many women who appreciate guys like him, and how they articulate things; even if its nerdy. I have a friend who's slightly more attractive appearance wise, he's legit got a fkn harem at his college. I don't know how tf that happened, but he's had like 4 different groups of females orbit around him. I think being authentic is a big part of it.
This in general is a "problem" with abstraction. You trade code that is more traditionally readable and more concise for not immediately knowing low level details of what does what. Which is better is very dependant on the use case and personal preference. For most sub millisecond usecases I've had to deal with when writing stuff with C++ using some linear algebra library that does operator overloading it was more than fast enough for the job while making it just easier to write simple vector and matrix maths.
@@egg-mv7efc coders are a wild bunch. Them and bash scripters are the only group you'll find refusing to use IDEs in general. In reality, unless you absolutely need the best performance down to nanoseconds, you probably shouldn't be dealing with C at all. Use a modern language and develop 100x faster with infinitely easier to read code.
@@egg-mv7ef this isn't reliable 100% of time in 100% of IDEs, yes you can find how the abstractions are implemented but if the abstraction wasnt necessary to begin with all it means is anyone reading that code is going through more steps than they need to to figure out what thw code is doing.
@@jasonenns5076 1. Modern C++ syntax 2. Lack of abstraction (as in this vid) 3. Extensibility 4. C++ contributors' inability to name things correctly (see iota and range confusion) 5. The fact that I should use Rust instead of C++ in almost every instance, but the same can't be said for C, which is lower level. 6. Operator overloading 🤮 I can keep going. If you want modern language features, why not just use Rust? C is useful because it almost directly translates to assembly, while C++ is so far removed that there's no practical reason to use it. C syntax is simple, ubiquitous, and universal; C++ syntax changes between individual C++ developers because of how bloated the language is these days. Why even bother with C++? Just write in C, because everything you can do in C++ can be done in C, just maybe with different syntax.
@@MrGriefCreep C++ is true freedom. You are allowed to choose what you want to use. Operator overloading makes iterators such a pleasure to use. C++ syntax does not change, there are just additions to the language. Structured binding is a useful abstraction that does not change anything. You can still use the "older" syntax if you so choose. If you were to complain about how coroutines are inplemented in C++ and the whole promise object thing, then I would grant you that argument, but are you ever confused how to use std::vector? It was named incorrectly, but everyone knows how to use it. So then, what is the problem with iota or range. However, your suggestion of using C instead of C++ is ridiculous. It would not just have a different syntax, but it would be more work. The implementation of virtual functions would be additional work that is not necessary. There would be no automatic destructor call as there are for stack objects. There is no boost equivalent for C. So you would have to extern "C" all the functions you might want to use. That "slightly different syntax" is a large amount of work and not very memory safe.
You're obviously correct. You read C, you know what it does, C++ not so much. But that's the thing with OOP and higher level. That's the point. You don't really care to know how a tire is made. You just wanna use a tire to swap it for your flat tire in your car. In the same way, I don't wanna build a doubly linked list in C yet again, I'd rather just use something like a C++ std::list or whatever suits my problem.
Yeah but the issue arises when you’re doing more advance stuff or debugging with those types especially on such a low-level language you need to know exactly what it’s doing which can be really difficult with C++ Edit: don’t worry guys, I was wrong. Decided to buy a C++ textbook and go back and study it a lot more in-depth. Ended up liking it a lot.
@@BigJMC if you're doing more advanced stuff, you'd wanna use libs others wrote, you don't wanna reinvent the wheel. You pretty much know what the structures you are using are doing. Most libs also have documentation. I wouldn't worry as much on debugging, most problems are likely gonna be in your code.
@@StupidusMaximusTheFirst I would but I’m writing a game engine that sits directly on top of the Vulkan library which means it’s very time sensitive, I need to make sure my buffering and render call’s aren’t being held up by another library or it’ll cause big fps drops. Plus I wouldn’t even know what the libraries are actually doing, they could be doing the most inefficient loop calls known to man and I would be loosing my mind for hours straight wondering why my code is running so slow.
I like c++ because I can choose how much I want to abstract if at all. And once you get experienced with it, you know what's underneath the abstractions too and can think of it in both ways.
Yes. In general C++ is just a C (except constructs which are not compatible in C++ standard with C) with many OPTIONAL extensions. You can select what suits you the best.
@@julian_handpan you're correct; I did not know ruby, but I did a little speed reading and I feel like it's got a bit of that assembly flavor hidden in there so I'm gonna have to say its not zen enough for me 😜
In my personal projects I generally just create cpp files but write mostly C code and occasionally use C++ features where I need them and where I see a clear benefit over C counterparts. That's also why I really LIKE C++. You (mostly) aren't forced to use C++ features. Theoretically if someone really wanted, they could write a program in C++ but only using C features without anything from C++. Also I think there are good uses for both C and C++. For example when I'm writing more low level stuff (like drivers, internal os stuff etc) I like to use C. But for example when I'm writing code for games or stuff with UI, I prefer C++ and the OOP aproach instead of functional. This is my personal opinion, but writing game stuff or UI stuff not in OOP is pain, and on the other hand writing low level stuff in OOP is pain too, so I think everything has it's own use cases
My biggest complaint with trying to write C in C++ is the fact that MSVC doesn't comply to any _remotely_ modern C standard. So I do things that C should be able to do, and get hella frustrated as a noob because I downloaded Visual Studio because "internet said start with Visual Studio." But what you said is absolutely right, my problem is with the discrepancy between MSVC and RTFM.
it's possible C existed long before the idea of a closure existed, im not completely sure, but if C just had closures then i think you wouldnt necessarily need to use C++ for game development because closures on its own can accomplish many of the same things that an OOP language can but that an OOP language needs multiple separate features for. its really odd that C seems to continue to not adopt the idea of closures because it's a feature that would fit in perfectly with C and that is basically a given in any other much more modern functional-centric language.
@@Templarfreak what do you mean by a "closure"? Do you want a locally scoped variable inside a function to retain its value between function calls? That's the "static" keyword you're looking for. Do you want to call a function via dot operator? Let me introduce you to the wild and whacky world of 🌈 function pointers 🌈. It goes a little like this: struct mystruct { int a; void (*printvals) (struct mystruct); }; void printvals(struct mystruct mystruct) { printf("d%", mystruct.a); } struct mystruct mystruct = {3, printvals}; Then just call it by going "mystruct.printvals(mystruct);". It's a little annoying to type "mystruct" twice at the calling point, but I have not a singular clue how one would manage it without that. I'm pretty sure C just isn't that smart. Also, unless you use a constructor function (a macro would probably work best for that), that function pointer could point to any void with a single argument of type mystruct. Not sure how many of those you have lying around, but it's conceivable that that could screw things up.
"'Do you like C or asm more?' Dude, 100% like asm more, now this gonna probably come off as a skill issue, and it might, but, I don't like C because I think it abstracts away a lot of how the computer actually behaves. The reason why I like asm is because I can tell you exactly what every line of code is doing on the actual hardware."
Did a lot of C++ programming, and the first lesson I learned was that operator overloading is overrated and should be used *sparingly*. It just confuses things.
I agree! I'll usually declare a namespace and define my functions that do some special operations in it rather than overload the operators. It's much more readable that way.
Abstractions are great for saving time and not reinventing the wheel every day. Everything has its costs, low level is great but not a one size fits all
you should try c#. in c# not only dont you know what the OS is doing, you dont know what the program is doing on any level. It may just randomly decide because of how you spelled a variable name that it is gonna create a SQL server, or provide an API endpoint with that name.
Can't mate. You need a language that compiles to machine code for low level or kernel programming. C# is like java in that sense. C/C++, Rust and Zig are a few that can do this. Yes, there are workarounds for some, like fortran. But at this point, if you're not going with Rust or Zig, you might as well stay with C/C++
@rursus8354 I would prefer something like typeclasses (unfortunately not to be confused with types or classes) that define operators and can be implemented by a class. Haskell takes this approach: in order to make use of + - * you have to be a Num; to use / you have to be a Fractional. That way, we know that someone's not going to run off and start using + for string concentration or / for set intersection or whatever. Of course, that also ties into Haskell's type system, which is completely different from C++'s.
I legit had a nightmare yesterday that I was sitting at my desk in my dorm in a really bad incongruous outfit, typing “word.word.word.word.word” and trying to compile it and I’d get some errors, then I’d keep adding more “.word”s only for it to keep failing. I had a C++ nightmare.
Even though I dropped out, a moment of my computer science course that permanently changed the path of my career is when we compiled a non-trivial C program by hand. Since then I’ve worked a lot on compilers, with low-level hot loop optimisation (including giving talks/workshops on working with the compiler to produce faster code), and on real-time signal-processing.
C++ is what happens when you take a simple langauge like C, that is very close to the hardware, and add a bunch of features that allow you to abstract away from it... But coding in C often makes me wish I could use C++ features. So the solution would be to code in C++, but only use the C++ features you want. That's fine if you're the only programmer, but if you're in a team? You're opening the floodgates of incomprehensible code.
The problem is that we're at a point where not all C code is valid C++ code anymore, and I feel like at that point the language just fails at what its purpose was
That's why you enforce linters and static analyzers in your cicd pipeline to make sure the team follows the standard. This shouldn't be too much of problem since you should always have that pipelined whether it's C++ or any other language.
@soyel94 int main() { char* xs = malloc(128); return 0; } This compiles in C but not C++, because you can’t simply concert pointer types without explicitly casting.
Abstraction is the name of the game though. In a well written program, you should be able to tell *what* is being done, but you don't need to know *how* for most of it. The less implementation you have to keep in your head, the more space you have for other ideas. Abstraction lifts the burden, and makes it much much easier to write incredibly complex programs without needing to understand every nuance of complexity all at once.
You can achieve a lot of that with libraries, though. Python is actually a good case study here: If you listen to some of the developer's talks or read through their PEPs, you'll notice that in it's basic form, Python is not much more complex than C. Python's developers have added a lot of well thought out syntactic sugar to the language though upon which it's interpreter/JIT compiler can pick up (e.g. notice how Python's class methods always require you to give a "self" parameter while most other languages don't). That combined with it's vast standard library ranging from common data structures to full-on HTTP networking and multiprocessing however has made the language incredibly convenient to use, even if the base language is pretty weird compared to most others. If C had a standard libary as expansive as Python's, it would probably be a lot more popular. If you added Python's absurd amount of syntactic sugar to it... you'd basically get C++.
@@nezbrun872 It could also be the opposite and make things more secure. If you are making a custom pointer type that does memory management with reference counting you can effectively eliminate memory leaks by abstracting away the internal implementation of when heap memory is deallocated, whereas it would be harder to do that in C Plus you can overload operators to make the custom type syntactically operate like a regular C pointer, so you can do something like *ptr instead of dereference(ptr) or ptr->obj instead of dereference(ptr).obj
Dude, I learned C before even college, when it was still considered a “high level language”and is my favourite. I never managed to learn C++. College was the last time I was able to use it. Since the first job I got, it was Java, PHP, JSP, C#, Javascript. I got fired last year but can’t get a job anymore ‘cuz I wasn’t using Python, Node, Spring boot, Angular, or React at my last job. Now there’s so much abstraction it seems they just want people to feed programs to a damn language model rather than actually develop software. I’d rather deal with C++ abstraction at this point.
You would probably vomit while doing ruby. I dont have this issue with c/c++ but holy shit the amount of 'magic' ruby has going under the hood its disgusting.
Well, now we really are comparing apples to coca cola, aren't we? Ruby is just a prettier python to me. If i need a hardcore text processing program, ruby is my go to language because everything I need to do that is front and center in the language syntax. Example: I used ruby to generate custom C++ template libraries and DDS interface files from xml schemas. I could have built the tool in C++, but it likely would have taken several times longer to write and the only benefit would be saving 1 second of runtime processing every 4 months or so.
I mean isn’t that the point of a scripting language? It’s for doing high level processing where you don’t care about having direct control over the OS.
I started by learning and working on projects with assembly for embedded, which pushed me to understand the instructions set, CPU architecture, ALU, memory, …etc. Then I naturally moved to C for embedded, which I found it boring after 3 or 4 years. C hasn’t improved over years, the latest standards didn’t bring much, and I always had the feeling that I was limited in the possibilities and locked to a certain design and architecture. Then I got interested in C++ and its features, SOLID principles, design patterns …etc, libraries such as Qt, OpenCV. I then understood the power of the language. You can basically do anything, in the most efficient way. I’m still using it after 10years. Of course I also learned Java/C#/JS/Python but C++ is my preferred sword. The language is not for everyone, it is particularly difficult for those who started by high level languages with garbage collections etc. I think that the language will not die soon, it is still widely used in the video games industry, banking, medical, embedded, machine learning…etc.
The worst thing is classes in 600 hundred different files which inherit methods from some parent / or abstract class that then is defined somewhere as virtual thingy somewhere else.
@@clementlebeau484 Which there is non 99% of the time + even the will not help to find which virtual interface is behind X can only give you possible options.
@@Cd5ssmffan It‘s a tool but i never said that it’s difficult to use but it’s creating code that is easily viewable without having a full indexer + IDE in it is not possible to brain compile except for extremely basic things. The Argument you make that i don’t know it seems to be inferred by simply nothing.
I understand your point, because I have seen some C++ code before and sometimes it looks like a completely different language and I always need some kind of translator to see what's going on. But, if you write C++ code like C, you get to use all the new features of C++ without having to worry about installing a third-party library or straight up building it yourself.
using a c++ compiler but pretending to write in c while reserving things like polymorphism, virtual functions and the standard library for when they are critical is my preferred approach. when working low-level like in graphics programming, oop and other random things ends up getting in my way later on. namespaces tho...
Respectable answer. I am the exact opposite. I find C++ so comforting to read and I have a better time reading all of the little macros and overloads than when I code in C
C++ being hard to read isn't much of a problem if the code you are dealing with is well written and documented. If you are having a harder time reading other people's C++ code, it's very likely that the people who wrote the code aren't very good at their jobs. C++ adds a lot of things that make your life easier, while still being lower level than something like Python or Javascript. Also "I can tell you what every line is doing in the OS"? I'm sorry, are we going to act like compiler optimizations aren't a thing? Just like any other programming language, C++ serves as a tool. If it allows you to write code faster, while still having good enough performance, then there's no reason to complain.
These languages like C++ have a context problem where you have to follow much more code to understand it. Languages like Go or C don't have this problem to the same extent because they limit their semantics a lot so that it becomes a lot clearer what is actually happening in any given place.
I think it's highly overestimated how much a programmer knows about what's happening. Even if you write C code, there are still compiler optimizations and translations from CISC to RISC instructions in the processor. On top of that, you have several optimizations happening in hardware such as out-of-order execution, branch prediction, or register renaming. Imho, the programmer has less control over the things that are actually happening than many programmers like to believe. Nonetheless, it is good to have a basic understanding of the things that are happening, but the desire to always write code where you 100% understand what's happening leads nowhere - it only leads to code which the programmer feels like being super performant and optimized. However, we don't need code where the programmer has a good feeling about performance and optimization. We need code that is actually performant for real but still readable and debuggable.
@@mycelia_ow Even if you do that, you still can't be 100% sure what the CPU will do with this at the end. Writing a few small programs in Assembly is really good idea to get a better grasp of the interaction between CPU, the OS, and your application. However, for productive use, I would recommend to avoid Assembly as much as possible.
@@turnoff7572 Of course. You can learn about CPU micro architectures and build your own CPU, emulated on FPGA. However, this really takes a significant amount of time and it's not worth it if you don't need to know the inner workings of a CPU. However, as a software developer you should always be aware that you probably know less about the things that are actually happening in the CPU than you like to believe.
It all depends on what you're doing. I prefer C++ more for games or higher level stuff because C++ is a higher level language. If you're trying to do something lower level, then you should definitely use C. Now theoretically you could do everything in either language, but using one over the other for certain tasks brings a lot of benefits. A lot of times I find writing generic code in C to be super cumbersome since using generics requires you to manually keep track of types and to typecast everything. C++ just does it for you and it works great and all your code becomes very reusable
C++ can be the same level as C: if you don't use the feature, it has no impact on your code performance. But if you ever try to write a code with multiple potential failures it is much easier to do this with C++ and with exceptions than with C and error codes - specially if there are a lot of allocated resources when the failure occurs.
At some point you'd have to get out of that shell, with code becoming more abstract it's just a matter of time, i understand your point and that's why i also want to learn low level. But at the point of wanting to know exactly how it works from the baremetal it's just overthinking...
I have the exact same issue with C++. After years without touching C++ and only dealing with C I went to look and algorithm thinking I could just apply it to whatever I was doing and I couldn't. What the functions were doing weren't clear to me. I was def weirded out
I really feel you, I tried a lot of programming languages and when I had to decide whether I stick with C or C++, I instantly choose C just because as you mentioned in C++ sometimes it’s really hard to decipher the real purpose of a specific line of code. When you think you know C++, the language just kindly presents you the fact that you don’t know anything.
"c++ abstracts away a lot of how the language actually behaves" yeah. thats. the point. of higher level programming languages. If we know all 10 ways to use pointers, we dont need 1 Million people implementing the other 90 shitty ways on accident because they didnt spend 3 years coming up with already known best practices by themselves.
extremely weird comment considering the entire point of the short is that he knows WHY c++ does these things but he just doesnt like it. i can tell 100% youre an ego coder
But isn't the point that higher level languages usually come with additional features to compliment the abstraction, like memory safety/garbage collection, etc. and C++ doesn't? C++ reads like a high level language yet acts like a low level language, whereas C reads and acts like a low level language.
You can do the same with C++, it is open source and so are most of the libraries... Your resoning is kinda deductive, where does it end? Assembly? Microcode? Designing the circuits yourself?
I started at C++ first and my god how learning other languages is so easy its not even funny. Doing C++ i feel like the codes and how I understand them just resonates with my brain and it automatically translates what I want into code. Then comes the other programming langauges like Haskell, J, JS, python, C#. It was really easy. C++ is the perfect language to start on and once you understand 80% of it sometimes its too hard but once you reach 80% then you can start learning other languages and see how fast you learn them
@@bies_moron4404 I guess my point was that in C you still have to call functions, and all this reasoning can be applied to function calls just as well: you can't tell what a function actually does just by looking at its name. Does this mean it's a dangerous abstraction? Can we even use functions if we want to "know what every line of code does exactly"? If someone writes a function that mines bitcoins and names it "calculate_factorial" is that really a language problem?
@@AxelStrem - You're kind of missing the point though. A function doing a heap allocation doesn't apply to what he's talking about, because that function would be known to do a heap allocation - you know it's explicitly calling that function, whereas the minus operator is overloaded so at a glance, you don't know what function it's calling until you look up and get the types at that location and figure out which overload of the operator it's going to use. But if you explicitly use, say, "set_sub", you know just from the call-site that it's going to do a subtraction operation on a set, and that's going to necessarily return a new set which will have to be allocated.
I graduated from a programming bootcamp and got a pretty jr job as a front end dev. It wasnt the dream job but it lets me get paid to look at code all day. And I have started to scrape some time together to work on side projects and learn some weird stuff now too. I want to understand the OS better and have a way deeped understanding of computers and the true fundamentals of how programming works in a way a 4 month bootcamp could never teach. Hopefully in a year or so i can get promoted to the job i want, or find something that checks all the boxes for me.
I like operator overloading! For example to concatenate string you can use the + symbol, which is pretty intuitive. Also for file system paths you can use / operator to concatenate paths :)
I think that works decently in high level languages like Python that are already super abstract, but in low level languages that kinda gives me the ick ngl. If I'm making a function call I wanna SEE that I'm making a function call.
@@jacksonsmith2955 I understand, but I wouldn’t call C++ particularly ‘low level’. Yes, you have access to low level functions, but does this make the programming language ‘low level’? C++ is very versatile and the developer can choose if they want to program in abstracted layers of code, or just stick to the bare bones. You aren’t forced to use these operator overloading functions at all. But why program in C++ if you aren’t taking advantage of these features? Then yes, use C. Both have their own use cases and some overlap :)
Something about this doesn't sit right with me, you've defined '/' on strings but not all strings are paths. I'm not saying it's wrong, and as long as you're comfortable with it then great, but I personally wouldn't do this. My comment also doesn't mean operator overloading is intrinsically bad either.
@@sb_dunk I might be misunderstanding, but the overloaded ‘/‘ operator only works on file path objects in std::filesystem::path. You can (and that’s the beauty of it) use this operator to concatenate a string to a path object. The library takes care care of OS specific filesystem paths (posix, windows). I strongly recommend you to take a look (and tinker) at it to understand it better, and see how intuitive and easy it makes handling file paths :)
100% agree. I personally like writing my own C++ code. But the moment you touch other peoples code, I definitely prefer C over C++ every time. The code is just much more readable even if it's more verbose.
I prefer Ada and assembly together. I *like* C++, but I must agree that the abstraction features are over used. I think the Ada community is just as significant to why I like the Ada language as the language itself. The same goes for C++ The issue is that if you don't drown yourself in C++ features, then some features can fix a few problems that C never got over.
Eh, I [generally] prefer C as well, but this complaint is just b/c he's a new developer. When you get into large C code bases they become abstract as well - they have a whole book of utility functions in their util files to work with 'primitives' in their abstracted form. This is where the operator overloading he's complaining about really comes in handy, b/c now you can [for example] just add 2 complex numbers together with the + operator instead of calling a function passing both of them. It simplifies a lot of it. Also with the massive code bases, you wind up in function pointer hell, which has the same problem is abstracted class definitions in C++. You wind up with function pointers that get set to 1 of a dozen different functions at initialization so now you have no idea which one is being called unless you step through or printf all of them. Also, see opaque pointers, for how proper abstraction is done in C. If somebody is doing crazy things with operators, that's just bad design, you can do bad design in any language. When you're dealing with simple examples like in the window C may be better b/c you don't have to look at complex class definitions. But C for large code bases is equally as abstract. My main problem with C++ is more of a problem with OO in its entirety, and that's that people are afraid to not use it because it's considered a 'best practice'. So you wind up with these goofy fuckin ownership relations or friend classes b/c somebody's trying to over-design something simple.
I would argue that function overloading in C++ is more transparent than the function pointer hell in C. If you have a good IDE, it can help you navigate the inheritance tree. However, in C it would be very very difficult for the IDE to find all the positions where the function pointers are assigned, so you are left on your own to find all the potential candidate functions which might be called, when the function pointer is called.
@@fr89k Yeah I'd agree they're generally more transparent. But as a slight devil's advocate, while function pointer assignments CAN be anywhere, they're generally all localized in terms of file structure, so you're generally not looking too deep. But yeah, not as explicit as in C++. Wish I knew what a "good IDE" is though when it comes to C/C++ parsing, haha. They're all pretty shit except for visual studio (OG, not VS Code) IMO. Never found one that could pick up on everything. Most IDE's don't account for even the majority of all basic setups in C++ (eg. inheritance), but even if one nails that down it can't account for linker externs and stuff so it'll never account for everything. That's one thing that's a real pain point for C/C++, IMO. But yea, VS was quite good with parsing. Wish they open sourced that instead of the VS Code shit we got.
C99 actually has complex numbers as a native type, so you used a bad example there 😅. But I fully agree, the C++-style of object orientation makes people overcomplicate everything. But object-orientation isn't bad in general, for example languages like Smalltalk keep it very understandable and simple. My best C++ experience has been with the Qt GUI-framework, because it manages to abstract things well enough so you really don't have to care too much about the low-level behaviors.
@@imrevadasz1086 That's fair, never seen a native complex # in the wild before. I don't think OO is bad, but I do think OO as a general concept leads to people overcomplicating things and that it's not necessarily C++ specific. There's too much stress on the possibility of extending or augmenting code that it makes people over-complicate it, like making and inheriting from some interface that will NEVER be inherited from after. We even see this at a more basic level outside of inheritance, like #defining "NUM_DAYS_IN_YEAR" as if that will change at some point. Another issue is just that not everything fits nicely into an "object". Sometimes a function just needs to be a function, and doesn't need to maintain any state. In that case, OO just becomes a burden - but nobody will ever say it b/c merely suggesting that OO can be a burden in real life is wildly unpopular. I too enjoy the inheritance hierarchy of QT. It is very well done. It's unfortunately a bit obvious when seeing some of it why it's not as performance oriented as something like GTK, but the trade-off is that it's a very intuitive framework to use. It's my go-to for GUI apps. Wish the licensing was a bit better, but it's really great. 2 thumbs up from me.
@@MrSlowestD16 True, in too many cases objects are used where just a "module" (namespace in C++) would be enough. Part of the problem in C++ programming is that a lot of people come to C++ from Java, which only offers Classes for modularizing and namespacing code, and every bit of code has to be in a class. Hence a lot of C++ code is written in Java style.
Agreed! I had to translate lines of C code into MIPS ASM in my hardware architecture class. C maps more directly to the low-level instructions. C++ tends to abstract away too much and the syntax can be weird. Personally I prefer coding in Java though.
Exactly why I like C. Another reason is coz I learnt C first, and data structures algorithms, operating systems, networking and all in C language. So everything else feels like vague. I feel uncomfortable when I don't know what the function is gonna do exactly for any change I make.
You don't really know exactly what every line of code is doing without disassembling. All modern compilers have varying degrees of voodoo, depending on platform/processor, options, your code, etc. This is orthogonal to the complexity/abstractions in the C++ ecosystem and common to most modern compilers. But, I understand your sentiment and frustration with overly-complex C++. Throw the C preprocessor in the works and both languages are very messy. A fact that influenced why they neutered the C# preprocessor.
You guys are pathetic, when I code I wanna know exactly what quarks and leptons are doing. It's fundamental to know about them if you wanna keep track of your protons, neutrons and electrons.. 😂
Yess! C is quite readable and understandable. But Cpp has so many variants and features that each project is effectively written in it's own language. At least thats how I feel about it.
C++ is great **IF** you (and the code you are working with) stick to the standard and follow best practices for modern C++ (i.e. C++11 onward). Pre-C++11 was a nightmare and people who still code like that should just stop plz
You're probably not gonna convince people who love c with this. The reason a lot of people who like c trash about c++11 onwards is because that's when it started doing a lot of things differently than just c. Pre c++11 code often feels bad to c++ devs because it feels like c code with classes added on top
@@sinom One of the biggest C++11 features to me are smart pointers. Before C++11 you had a huge problem with keeping track of the ownership of objects. Even if you dislike shared_ptr because it does one additional redirect and you don't have 100% control over the destruction of the object, you have to agree that unique_ptr is awesome. Your method doesn't take ownership? Fine, you can still use raw pointers in the method arguments. Your method takes ownership? Use unique_ptr in the arguments and move the unique_ptr in from the caller. It's perfect to track ownership.
@@fr89k C++11 has big issue with smart pointers. C++14 is much better with this case (but not perfect) but it break the compatibility - on the other side: it's not a big problem. Some features are also introduced with C++17 and C++20. But C++14 is usable.
C# is the best language I have ever used when it comes to productivity and actual enterprise level code. The code just comes out super clean and easy to understand. Performance is excellent too.
@@Michael-mr3ig not for game dev, for game dev the GC is a nightmare on performance. You end up having to use compute shaders and other tricks for performance half the time
these C lovers really hate operator overloading.. But that is the feature that I like the most about C++ and that sets it apart in freedom for creativity. Of course there's a very limited use case for it, but it is extremely helpful in my area, computational mathematics.
Yeah as a C++ dev I also didn't understand his point about operators overloading lol C++ to me is freedom, I can code really low level or really high level by building from the ground up and having a lot of features safety like smart pointers etc... When C is just stuck as a low level language, make it pretty much useless in most modern use cases tbh (I would rather use Python) bcs if I do some UI frontend for example I will use C++ and if I need stuff like memcpy, memset, reinterpret_cast, sizeof and a lot of diverse low level stuff I will still use C++ because I can do both: Low and High level at the same time, having the best of both world !
yeah. i think its really neat how in c++ i can make a vec struct template that overloads a bunch of math operators, so i can do math on them how i would with base number types. the alternative (explicitly calling functions for everything) would be much more verbose.
Exactly, STL has way too much abstractiom that you cant even begin to imagine whats happening under the hood, and Im really having trouble forcing myself to memorize the custom syntax for those layers of abstraction. I really gotta buckle down and learn it, so I can stop bothering with it, I dont ever write rust, but I know I should.
If you find C++ hard to read it's your colleagues who are to blame. You could write stinky unreadable code in any language if you really wanted to. And yes, C++ is difficult, that's why not everyone should be using it. It's not like you go design nuclear reactors after taking your physics introductory course, why is everyone thinking they can get away with it in CS? If you suck at programming just do Python and be happy its not like it pays less than C++ 🤷
You kind of need a fully featured modern ide with autocomplete and display over hover to really use C++, it sounds like, then. Which is precisely why it’s fallen face flat on linux. No such thing. CLion is close, but realistically C++ is most used on OSes with these sorts of editors, e.x. VS, VSCode, Xcode. vsc is on linux now so it could be languages that can only be rapidly used with the use of tools may expand. My theory anyway. Using C++ in anything but visual studio for me is a nightmare.
I like C++ but I'm pretty judicious in my use. Operator overloading is really nice if you're dealing with mathematical types e.g. arbitrary precision numbers
@@RetroAndChill I really don't like a lot of operator overloading I've seen for =. Part of what makes someone used to C have a hard time understanding what's happening in code
@@ic6406 If your class has a shared pointer (or even - god save us - a plain pointer) it is very unwise to use default implementation of an assignment operator - very unwise... Unless you want to keep the member object shared between all of the object of the class. So always check your class semantics.
i think c++ is better just because you can put c and asm code inside .cpp code, so you can entirely create a code in c and use c++ just when necessary without creating 2 different codes to link
I think one thing that really smacks c++ developers when they first do c++ is the implicit casting. People think string literals get implicitly casted to string in all scenarios, but that is not the case if there is boolean override. The ADL converts const char ptrs to bool and then some developers spend hours trying to figure out what is going.
When i first read about operator overloading i thought it was great. I immediately thought of things like a complex number library where it makes perfect sense to overload your basic math operations. Then my roommate started to describe some of the horror stories he'd seen where the overloaded operations don't make sense or are counter intuitive. I still think it has a place but programmers really need to make an effort to only use it when it makes sense.
I don't like C++ because in some scenarios different compilers or different language versions behave differently. To me, C++ seems like a language that was patched way too many times while trying to have backwards compatibility. Then you add on top libraries like Boost and QT that add another level of complexity. Seems like there's no real standard library, even for basic types like a string, there are way too many types. Like QString, std::string, char *, wchar_t *, etc, etc, etc. it's really annoying on a large code base.
I mean, C does that too to a much smaller degree, but I agree. The "different compilers do different things" is 99% "MSVC is doing it's own thing again and everyone else is following the C standard and building C++ on top of it as the standard intended." ISTG, MSVC supports 0% of the C changes after C89 or so.
also in C there is usually one or two ways or doing something, in C++ there's a hundred and the hardcore OOP fans will only accept one. I was just dumped into a C++ project with only C experience and I'm literally writing the same amount of logic 10x slower and its still not enough
I think C++ is as readable as C. Everything which you can't read and know what's happening on the OS is just some form of a function call just like with C. You just have to bear in mind that you can call "functions" in more ways than just func(). For example: operator overloading In C++ (t1 + t2) should be read as add(t1, t2) in C where add is some user defined function (unless t1 and t2 are primatives). Complexity is not necessarily harder to read or understand it just means you need to look at the internals of those structures to find out what the programmer is doing, which lends itself to useful abstractions.
Things get difficult quickly when you have lvalue, rvalue, pvalue, xvalue, gvalue and all the templates adding to the syntax. It is a language that’s difficult to read, understand and program(in certain styles). While in C, whatever you do you know if it is for the compiler or run time or just some macros you define, and you know what the computer is doing in memory.
@@fdc4810 It's about good practices and a knowledge of a team members. Always. I've seen a lot of very obfuscated code in C (because C allows to do many nasty things). This is a place for a code guard and peer reviews.
You can use C++ just as a better C if you like. Have to be careful not to pull in too much overhead though. Typically applications where C is the best choice want to be lean. In the end, just choose the best tool for the job at hand.
Yes. As you do not pay ANY price for not used c++ features you can use it as a better C - even on microcontrollers (of course 95% features would not be available nor reasonable, but at least you get a lot of type safety forced by a compiler).
Yeah it's a skill issue. I can spend hours looking how a new structure compiles and behaves before I start using it. You just not supposed to use in c++ something you don't understand how it compiles and works.
Sometimes you are in a codebase too big to understand before you start debugging, or it's infeasible, the last place I worked just the section of code my team handled was 8 million lines of C and C++
Have fun working on a large project with a huge code-base then. Have fun having to understand the whole code base before you make a change. You seem like a guy who's only ever worked on his unreal demo project. If a collegue gives you a hammer and it turns out to be a screwdriver you're going to waste so much time for nothing. And that time costs money for the company.
@@wiczus6102 I always understand the whole system before making changes no matter how big the codebase is, it's never more than 3 days. If your team is unable to make the right abstractions it's a skill issue. And it will result in bug fixing taking more than 5% of your teams time.
@@wiczus6102 And in this case C++ may be a great tool for responsible developers. I've spent a lot of time rescuing big and "doomed" projects by introducing correct design patterns (which took time but in the long run it gave a lot of benefits to the company).
I really like operator overloading though. In fact, that's just about the only unique part of C++ that I use. If I have a struct for a vector, I would much rather do vectorA + vectorB than something ugly like addVectors(vectorA, vectorB).
that's how i feel about a lot of more abstracted languages (i.e. python, JS) bc i can only reason about the abstractions. i can't make sense of what's really happening with the code i write.
When I was involved with software development full-time, I never made the leap from C to C++. My main issue with the whole concept of C++ stemmed from its lack of efficiency. This commentary over 25 years later is music to my ears. 😊
@@mightymalakai hmmm, then which operating systems have moved onto a C++ foundation from C? You can claim potential development efficiency gains. I’m referring to runtime performance.
@scottlivezey9479 Not every OS is Linux. Operating systems now incorporate C++ in their code. I'm sorry but your bit about runtime performance is doubtful as best, to avoid saying plain wrong. The motto of c++ is 0 overhead abstraction. You can watch quality tutorials or presentations from cppcon to get an idea of the philosophy behind c++ and how to write quality c++ code. I invite you to watch the presentation of Jason Turner in the 2016 edition of cppcon where he demonstrates to you live how added abstractions and clarity in the code will not affect the generated assembly.
C++ has its advantages. Use a bignum library with C, a = (a+1)%max; becomes bignum_add(tmp,a,1); bignum_divmod(tmp2, tmp1, max); bignum_copy(a, tmp2.modulo); I can write constructors for my structs. I can namespace my globals. I can use json without wanting to kill myself.
This is the own dck sucking issue. 99.9% of programmers don't need to know exactly how/where the memory is allocated. Otherwise go for assembly if you just want to show off. A higher level of abstraction allows the code to be understandable, and you can still look at the implementation of the language/compiler/whatever if you really need to.
you sound like you never worked on an embedded system, game or any performant software. Being able to know the flow of resource allocation does **not** reduce expressiveness. Using custom allocators you get a lot of control and a lot of convenience, C and C++ were poorly designed by having one global allocator and no defer keyword and EVEN THEN you can still reap the benefits of using one.
@@Obscurite1221 this mentality of "developers don't need to do things because it's done for them" is so lazy, why are we trying to foster an environment of developers that don't know what they're doing?
I use c++, but only for the constructors/destructors/assignment because it's useful for handling resources acquisition. I only ever overload operators when it *really* makes sense and doing it some other way makes it harder to follow.
C for low-level control, python for high-level abstraction. In my (admittedly limited) experience c++ tries to give both low-level control and high-level abstraction which leads to messy code that spans too many levels of abstraction at once
You have just as much low level control in C++ as you’d have in C. C++ can be messy, sure. But so can C be. Just enforce coding standards in your team and you’ll be fine.
i can see your experience is limited cause youre yapping absolute bs. c++ gives you a high level of low level control and good mid-level (wouldnt call it high level at all) abstraction. understand how simple continuous and non continuous memory works and suddenly understanding how a vector works isnt such a big deal
The problem with people who defend C++ often doesn't use C++ at all. They just write procedural C++ like it's C with classes and vectors. If they actually start using advanced C++ features theyd understand how error prone that code is. Now it is definitely a skill issue for me but I'd rather write simple code than debug hours of complicated code
Complicated projects in C inevitably end up having horrible, hard to read stuff in them though. Every legacy C codebase I’ve worked with has some crazy macro shit to do things that normally come working out of the box in C++, and they inevitably implement their own string library to make string handling easier and do a bunch of other redundant stuff. C can be nice for smaller projects but large C codebases can be really rough.
C++ has the worst syntax of any language not deliberately designed that way as a joke. Rust has the worst semantics of any language not deliberately designed that way as a joke.
I also like C more. Modern C++ is just a totally different approach of a language than C. C++ is solving things by adding new stuff to the language. C is solving things in code. I like C’s approach more because it makes the language itself very lean. This is good because it gives us all a common ground. This helps tremendously when maintaining packages and patching old software or making PRs.
I've learned 6502 and x86 and C before c++ (and after that ada95, java, c#, python and many more) and when I have a choice C vs C++ I ALWAYS choose C++ (even on microcontrollers). It's simple: even if I don't need (or cannot use) specific c++ feature I got it's type safety (well, maybe it's not perfect but it at least exists).
I do kinda wish that C would at least have some built in types like matrix and vectors and have some operators specifically for those, but other than that yeah
I don't mind C++ code I wrote because I only use the subset of features I like and understand. The biggest problem of C++ is that everyone uses a different subset of the language and so trying to learn a new program every is like learning a new language.
Ding ding ding ding!
Exactly this. Good C++ looks and behaves a lot like C anyway. Just with classes.
Yeah o think you're right man !
This is similar to the problem with Kotlin as well! Reading others' Kotlin is so hard lol
@@sacredgeometryIf you think that C++ is just C with classes, then you probably never used anything beyond C++89
People say you can simply avoid using the ugly parts of C++. The problem is that you still have to read and use code written by people who DO use those features.
Sadly, at this point, you literally can't even avoid those parts while writing code, either.
@@KanashimiMusicyou can, just remove the those two little p’s at the end of the file extension
@@captainfordo1 Yeah, but as soon as you access those files from cpp code you gotta deal with the same shit
Have to?
You should try not collaborating with bad programmers. It's pretty nice.
With macros, every C++ project becomes it's own programming language.
Not macros but more like templates
even without templates, ever c++ project is its own programming language because every project uses a different subset of the language.
@@homelessrobot go binary then.
@@NimerionTech binary isn't a programming language
@@homelessrobot He doesn't know about assmblers i think. Just don't bother with the guy. His soul will forever rest in heaven.
Low level is great because it feels like you understand everything but abstraction is great cause you can get stuff done quick
There is a point where abstraction goes too far. EVERYTHING in C++ can mean something else. Macros, operator overloading and numerous features makes it extremely difficult.
Hence why C hits the sweet spot for me.
Abstraction is good if you have a large code base and need to extend and modify the code. With a very good software architecture a similar convenience level can be achieved in C, but a) you have to be able to really really create such a good architecture and usually you notice too late all the oversights you made and b) if a new guy joins the team, you have to teach him a lot about how this architecture is too work. In contrast, every C++ developer knows how C++ inheritance works, so you have that covered already.
Abstraction is good, if you don't need bare metal access, but why on earth C++? It has features that don't matter if you need abstraction, but lacks features if you value it. It's like it takes the worst of both worlds: it's bad for if you need abstraction and it's bad if you need low level access.
@@powertomato In C++ you can do very low level things. In embedded systems that is important for a few things. A language that doesn't allow direct interaction with the hardware is not suitable for ended systems.
"You can tell what every line of code is doing"
*laughs in compiler optimizations*
"As-if" principle
Haha yeah man that's wild, no just kidding I got no clue or care what that means 😂
Excactly. This seems like an ego problem
You seriously overestimate how much the compiler actually does.
@@WillD-jj9kgThe compiler may optimize the code while compiling it to make it faster depending on how it's configured.
Many people told me Im the smartest guy that they ever met. So I bought an Unreal Engine C++ course, but the only thing I learned was that they lied to me.
😂😂😂
I had a friend he tried to learn that shi too and he ended up quitting after not event getting past vs code
Don't worry I'm a C++ dev myself for years, and I wanted to test Unreal Engine one day (without using Blueprints, so only using real coding with C++) and I quickly quited lol
Unreal Engine C++ is like a new language by itself, everything from the original C++ is different, UE built their own garbage collector, they have built their own smart pointers, their own defines etc...
It's liking learning a new language from scratch tbh.
@@K3rhosMan, imagine what the source code for something like Ark Survival Evolved looks like then... Pure spaghett.
@@K3rhosyou’re a piss poor c++ dev if you found unreal c++ complicated. It’s an extremely restricted subset of C++.
That one guy at every hackathon
imagine this guy talking to women. lmao
@@frederico-d3l people like this are the only reason the internet works
Do people who already know how to code go to hackathons or is that a place to learn how to code too?
I think both@@HeyIntegrity
@user-hl3qv8qg2s You would think that, but there are many women who appreciate guys like him, and how they articulate things; even if its nerdy. I have a friend who's slightly more attractive appearance wise, he's legit got a fkn harem at his college.
I don't know how tf that happened, but he's had like 4 different groups of females orbit around him.
I think being authentic is a big part of it.
This in general is a "problem" with abstraction. You trade code that is more traditionally readable and more concise for not immediately knowing low level details of what does what.
Which is better is very dependant on the use case and personal preference.
For most sub millisecond usecases I've had to deal with when writing stuff with C++ using some linear algebra library that does operator overloading it was more than fast enough for the job while making it just easier to write simple vector and matrix maths.
It literally makes everyone hate c++ in a production environment.
people forgetting they can ctrl + click to go to a class definition and use their eyeballs to see what the overload does is crazy
@@egg-mv7efc coders are a wild bunch. Them and bash scripters are the only group you'll find refusing to use IDEs in general. In reality, unless you absolutely need the best performance down to nanoseconds, you probably shouldn't be dealing with C at all. Use a modern language and develop 100x faster with infinitely easier to read code.
@@Deadmanstrolln eh c++ is great to use tbh i use it for almost everything. this dude in the vid straight up doesnt know what hes talking abt
@@egg-mv7ef this isn't reliable 100% of time in 100% of IDEs, yes you can find how the abstractions are implemented but if the abstraction wasnt necessary to begin with all it means is anyone reading that code is going through more steps than they need to to figure out what thw code is doing.
I like C++ more as long as it's used for the initial goal of "C with classes"
But, that is not the point of C++. The point of C++ is versatility, limit itself to what C does, but to expand on it.
@@jasonenns5076 No thanks.
@@AetherStreamer What disadvantage is there to use C++? If you have a good C++ compiler there is no reason you should use C.
@@jasonenns5076
1. Modern C++ syntax
2. Lack of abstraction (as in this vid)
3. Extensibility
4. C++ contributors' inability to name things correctly (see iota and range confusion)
5. The fact that I should use Rust instead of C++ in almost every instance, but the same can't be said for C, which is lower level.
6. Operator overloading 🤮
I can keep going. If you want modern language features, why not just use Rust? C is useful because it almost directly translates to assembly, while C++ is so far removed that there's no practical reason to use it. C syntax is simple, ubiquitous, and universal; C++ syntax changes between individual C++ developers because of how bloated the language is these days.
Why even bother with C++? Just write in C, because everything you can do in C++ can be done in C, just maybe with different syntax.
@@MrGriefCreep C++ is true freedom. You are allowed to choose what you want to use. Operator overloading makes iterators such a pleasure to use. C++ syntax does not change, there are just additions to the language. Structured binding is a useful abstraction that does not change anything. You can still use the "older" syntax if you so choose. If you were to complain about how coroutines are inplemented in C++ and the whole promise object thing, then I would grant you that argument, but are you ever confused how to use std::vector? It was named incorrectly, but everyone knows how to use it. So then, what is the problem with iota or range. However, your suggestion of using C instead of C++ is ridiculous. It would not just have a different syntax, but it would be more work. The implementation of virtual functions would be additional work that is not necessary. There would be no automatic destructor call as there are for stack objects. There is no boost equivalent for C. So you would have to extern "C" all the functions you might want to use. That "slightly different syntax" is a large amount of work and not very memory safe.
You're obviously correct. You read C, you know what it does, C++ not so much. But that's the thing with OOP and higher level. That's the point. You don't really care to know how a tire is made. You just wanna use a tire to swap it for your flat tire in your car. In the same way, I don't wanna build a doubly linked list in C yet again, I'd rather just use something like a C++ std::list or whatever suits my problem.
Yeah but the issue arises when you’re doing more advance stuff or debugging with those types especially on such a low-level language you need to know exactly what it’s doing which can be really difficult with C++
Edit: don’t worry guys, I was wrong. Decided to buy a C++ textbook and go back and study it a lot more in-depth. Ended up liking it a lot.
@@BigJMC if you're doing more advanced stuff, you'd wanna use libs others wrote, you don't wanna reinvent the wheel. You pretty much know what the structures you are using are doing. Most libs also have documentation. I wouldn't worry as much on debugging, most problems are likely gonna be in your code.
exactly
@@BigJMC as giannis said then you'd wanna use battletested libraries not reinvent the wheel.
@@StupidusMaximusTheFirst I would but I’m writing a game engine that sits directly on top of the Vulkan library which means it’s very time sensitive, I need to make sure my buffering and render call’s aren’t being held up by another library or it’ll cause big fps drops.
Plus I wouldn’t even know what the libraries are actually doing, they could be doing the most inefficient loop calls known to man and I would be loosing my mind for hours straight wondering why my code is running so slow.
I like c++ because I can choose how much I want to abstract if at all. And once you get experienced with it, you know what's underneath the abstractions too and can think of it in both ways.
Yes. In general C++ is just a C (except constructs which are not compatible in C++ standard with C) with many OPTIONAL extensions. You can select what suits you the best.
@@PiotrPilinkoif you do solo projects. Which most people don't.
@@bgdgdgdf4488 Solo? 20+ devs, 1mln LOC are not a solo projects.
C-lang can still do abstractions with function pointers.
@@bgdgdgdf4488 if you don't work solo you also can't just choose what Language you use.
c++ is like a continent full of countries. everybody uses a different language derived from a root language. you can kinda understand but not really
never show this man python
For real lmao. Python is the pinnacle of abstraction!
@@finalformluigilol you don’t know ruby 😂
@@julian_handpan you're correct; I did not know ruby, but I did a little speed reading and I feel like it's got a bit of that assembly flavor hidden in there so I'm gonna have to say its not zen enough for me 😜
@@finalformluigi a lot of meta programming in ruby my friend!
@@julian_handpan python has meta programming too. both languages are very similar; I was just poking some fun at Ruby's syntax.
In my personal projects I generally just create cpp files but write mostly C code and occasionally use C++ features where I need them and where I see a clear benefit over C counterparts. That's also why I really LIKE C++. You (mostly) aren't forced to use C++ features. Theoretically if someone really wanted, they could write a program in C++ but only using C features without anything from C++. Also I think there are good uses for both C and C++. For example when I'm writing more low level stuff (like drivers, internal os stuff etc) I like to use C. But for example when I'm writing code for games or stuff with UI, I prefer C++ and the OOP aproach instead of functional. This is my personal opinion, but writing game stuff or UI stuff not in OOP is pain, and on the other hand writing low level stuff in OOP is pain too, so I think everything has it's own use cases
My biggest complaint with trying to write C in C++ is the fact that MSVC doesn't comply to any _remotely_ modern C standard. So I do things that C should be able to do, and get hella frustrated as a noob because I downloaded Visual Studio because "internet said start with Visual Studio." But what you said is absolutely right, my problem is with the discrepancy between MSVC and RTFM.
@@mage3690would vim solve this?
@@mage3690just use Linux
it's possible C existed long before the idea of a closure existed, im not completely sure, but if C just had closures then i think you wouldnt necessarily need to use C++ for game development because closures on its own can accomplish many of the same things that an OOP language can but that an OOP language needs multiple separate features for. its really odd that C seems to continue to not adopt the idea of closures because it's a feature that would fit in perfectly with C and that is basically a given in any other much more modern functional-centric language.
@@Templarfreak what do you mean by a "closure"? Do you want a locally scoped variable inside a function to retain its value between function calls? That's the "static" keyword you're looking for. Do you want to call a function via dot operator? Let me introduce you to the wild and whacky world of 🌈 function pointers 🌈. It goes a little like this:
struct mystruct {
int a;
void (*printvals) (struct mystruct);
};
void printvals(struct mystruct mystruct) {
printf("d%", mystruct.a);
}
struct mystruct mystruct = {3, printvals};
Then just call it by going "mystruct.printvals(mystruct);". It's a little annoying to type "mystruct" twice at the calling point, but I have not a singular clue how one would manage it without that. I'm pretty sure C just isn't that smart. Also, unless you use a constructor function (a macro would probably work best for that), that function pointer could point to any void with a single argument of type mystruct. Not sure how many of those you have lying around, but it's conceivable that that could screw things up.
"'Do you like C or asm more?' Dude, 100% like asm more, now this gonna probably come off as a skill issue, and it might, but, I don't like C because I think it abstracts away a lot of how the computer actually behaves. The reason why I like asm is because I can tell you exactly what every line of code is doing on the actual hardware."
Do u like asm or electrically charging each transistor 1 by 1 and poking the logic gates manually
👍
Yeah that logic is so cringe.
@@EmptyJarDotocompletely sound actually. Have you used C++? It has every feature known to man.
ad absurdum.
Did a lot of C++ programming, and the first lesson I learned was that operator overloading is overrated and should be used *sparingly*. It just confuses things.
I agree! I'll usually declare a namespace and define my functions that do some special operations in it rather than overload the operators. It's much more readable that way.
I don’t need to sort through my entire T shirt thread by thread to understand it’s an article of clothing
Abstractions are great for saving time and not reinventing the wheel every day. Everything has its costs, low level is great but not a one size fits all
you should try c#. in c# not only dont you know what the OS is doing, you dont know what the program is doing on any level. It may just randomly decide because of how you spelled a variable name that it is gonna create a SQL server, or provide an API endpoint with that name.
csharp is like lego
C# code is way more easier to understand then C++.
As a C# fan, this is so accurate.
Can't mate. You need a language that compiles to machine code for low level or kernel programming. C# is like java in that sense. C/C++, Rust and Zig are a few that can do this. Yes, there are workarounds for some, like fortran. But at this point, if you're not going with Rust or Zig, you might as well stay with C/C++
I love C# for web projects. From backends to frontend. It’s great for that.
Operator overloading was a mistake.
@@andrew_ray nightmarish to say the least
Context
Operator overloading is OK, it is just that using it for streams is a horrible idea. iostream is really badly designed.
@rursus8354 I would prefer something like typeclasses (unfortunately not to be confused with types or classes) that define operators and can be implemented by a class. Haskell takes this approach: in order to make use of + - * you have to be a Num; to use / you have to be a Fractional. That way, we know that someone's not going to run off and start using + for string concentration or / for set intersection or whatever. Of course, that also ties into Haskell's type system, which is completely different from C++'s.
bruh he literally said skill issue, im dying LMAOO
I legit had a nightmare yesterday that I was sitting at my desk in my dorm in a really bad incongruous outfit, typing “word.word.word.word.word” and trying to compile it and I’d get some errors, then I’d keep adding more “.word”s only for it to keep failing. I had a C++ nightmare.
word
Even though I dropped out, a moment of my computer science course that permanently changed the path of my career is when we compiled a non-trivial C program by hand. Since then I’ve worked a lot on compilers, with low-level hot loop optimisation (including giving talks/workshops on working with the compiler to produce faster code), and on real-time signal-processing.
C++ is what happens when you take a simple langauge like C, that is very close to the hardware, and add a bunch of features that allow you to abstract away from it... But coding in C often makes me wish I could use C++ features. So the solution would be to code in C++, but only use the C++ features you want. That's fine if you're the only programmer, but if you're in a team? You're opening the floodgates of incomprehensible code.
The problem is that we're at a point where not all C code is valid C++ code anymore, and I feel like at that point the language just fails at what its purpose was
INTRUDER ALERT! A RED SPY IS IN THE BASE!
That's why you enforce linters and static analyzers in your cicd pipeline to make sure the team follows the standard. This shouldn't be too much of problem since you should always have that pipelined whether it's C++ or any other language.
Just make sure you lay down programming rules in your team, and all will be fine.
@soyel94
int main() {
char* xs = malloc(128);
return 0;
}
This compiles in C but not C++, because you can’t simply concert pointer types without explicitly casting.
Abstraction is the name of the game though. In a well written program, you should be able to tell *what* is being done, but you don't need to know *how* for most of it. The less implementation you have to keep in your head, the more space you have for other ideas. Abstraction lifts the burden, and makes it much much easier to write incredibly complex programs without needing to understand every nuance of complexity all at once.
You can achieve a lot of that with libraries, though.
Python is actually a good case study here: If you listen to some of the developer's talks or read through their PEPs, you'll notice that in it's basic form, Python is not much more complex than C. Python's developers have added a lot of well thought out syntactic sugar to the language though upon which it's interpreter/JIT compiler can pick up (e.g. notice how Python's class methods always require you to give a "self" parameter while most other languages don't). That combined with it's vast standard library ranging from common data structures to full-on HTTP networking and multiprocessing however has made the language incredibly convenient to use, even if the base language is pretty weird compared to most others.
If C had a standard libary as expansive as Python's, it would probably be a lot more popular. If you added Python's absurd amount of syntactic sugar to it... you'd basically get C++.
@@PixLgams And large chuck of python libraries are written in C
@@nezbrun872 It could also be the opposite and make things more secure. If you are making a custom pointer type that does memory management with reference counting you can effectively eliminate memory leaks by abstracting away the internal implementation of when heap memory is deallocated, whereas it would be harder to do that in C
Plus you can overload operators to make the custom type syntactically operate like a regular C pointer, so you can do something like *ptr instead of dereference(ptr) or ptr->obj instead of dereference(ptr).obj
rust can also heap allocate with the minus sign lmao
Dude, I learned C before even college, when it was still considered a “high level language”and is my favourite. I never managed to learn C++. College was the last time I was able to use it. Since the first job I got, it was Java, PHP, JSP, C#, Javascript. I got fired last year but can’t get a job anymore ‘cuz I wasn’t using Python, Node, Spring boot, Angular, or React at my last job. Now there’s so much abstraction it seems they just want people to feed programs to a damn language model rather than actually develop software. I’d rather deal with C++ abstraction at this point.
Brother, if your code structure is anything like your sentence structure... I can see why you were fired.
You would probably vomit while doing ruby. I dont have this issue with c/c++ but holy shit the amount of 'magic' ruby has going under the hood its disgusting.
I don't see any problem with my code accidentally summoning demons
it pretty 😍
Well, now we really are comparing apples to coca cola, aren't we?
Ruby is just a prettier python to me. If i need a hardcore text processing program, ruby is my go to language because everything I need to do that is front and center in the language syntax.
Example: I used ruby to generate custom C++ template libraries and DDS interface files from xml schemas.
I could have built the tool in C++, but it likely would have taken several times longer to write and the only benefit would be saving 1 second of runtime processing every 4 months or so.
I mean isn’t that the point of a scripting language? It’s for doing high level processing where you don’t care about having direct control over the OS.
Why would I care about instructions on the OS when wanting to parse a string lol
I started by learning and working on projects with assembly for embedded, which pushed me to understand the instructions set, CPU architecture, ALU, memory, …etc. Then I naturally moved to C for embedded, which I found it boring after 3 or 4 years. C hasn’t improved over years, the latest standards didn’t bring much, and I always had the feeling that I was limited in the possibilities and locked to a certain design and architecture. Then I got interested in C++ and its features, SOLID principles, design patterns …etc, libraries such as Qt, OpenCV. I then understood the power of the language. You can basically do anything, in the most efficient way. I’m still using it after 10years. Of course I also learned Java/C#/JS/Python but C++ is my preferred sword. The language is not for everyone, it is particularly difficult for those who started by high level languages with garbage collections etc. I think that the language will not die soon, it is still widely used in the video games industry, banking, medical, embedded, machine learning…etc.
The worst thing is classes in 600 hundred different files which inherit methods from some parent / or abstract class that then is defined somewhere as virtual thingy somewhere else.
Jesus christ, I hate that. It makes everything so hard to follow.
I feel like inheritance can be decently readable as far as there’s a UML class diagram to follow along with
@@clementlebeau484 Which there is non 99% of the time + even the will not help to find which virtual interface is behind X can only give you possible options.
OOP is really basic why dont you take the time to learn abstraction and inheritance?
@@Cd5ssmffan It‘s a tool but i never said that it’s difficult to use but it’s creating code that is easily viewable without having a full indexer + IDE in it is not possible to brain compile except for extremely basic things. The Argument you make that i don’t know it seems to be inferred by simply nothing.
I understand your point, because I have seen some C++ code before and sometimes it looks like a completely different language and I always need some kind of translator to see what's going on. But, if you write C++ code like C, you get to use all the new features of C++ without having to worry about installing a third-party library or straight up building it yourself.
using a c++ compiler but pretending to write in c while reserving things like polymorphism, virtual functions and the standard library for when they are critical is my preferred approach.
when working low-level like in graphics programming, oop and other random things ends up getting in my way later on.
namespaces tho...
exactly
Respectable answer. I am the exact opposite. I find C++ so comforting to read and I have a better time reading all of the little macros and overloads than when I code in C
I regret that C++ inherits macros (and plain includes) from C as this is a pure and evil cancer of a modern programming language.
@@PiotrPilinko You cannot say _C++_ and _cancer_ in the same phrase without also saying _templates._
@@AetherStreamer templates are amazing and get way too much hate
C++ being hard to read isn't much of a problem if the code you are dealing with is well written and documented.
If you are having a harder time reading other people's C++ code, it's very likely that the people who wrote the code aren't very good at their jobs.
C++ adds a lot of things that make your life easier, while still being lower level than something like Python or Javascript.
Also "I can tell you what every line is doing in the OS"? I'm sorry, are we going to act like compiler optimizations aren't a thing?
Just like any other programming language, C++ serves as a tool. If it allows you to write code faster, while still having good enough performance, then there's no reason to complain.
These languages like C++ have a context problem where you have to follow much more code to understand it. Languages like Go or C don't have this problem to the same extent because they limit their semantics a lot so that it becomes a lot clearer what is actually happening in any given place.
I didn't know I wasn't alone.
"the f**in minus sign can do heap allocations"
Preach!!
I think it's highly overestimated how much a programmer knows about what's happening. Even if you write C code, there are still compiler optimizations and translations from CISC to RISC instructions in the processor. On top of that, you have several optimizations happening in hardware such as out-of-order execution, branch prediction, or register renaming. Imho, the programmer has less control over the things that are actually happening than many programmers like to believe. Nonetheless, it is good to have a basic understanding of the things that are happening, but the desire to always write code where you 100% understand what's happening leads nowhere - it only leads to code which the programmer feels like being super performant and optimized. However, we don't need code where the programmer has a good feeling about performance and optimization. We need code that is actually performant for real but still readable and debuggable.
Can you say that in clash royale terms 😖
SO what you're saying is, I should be writing stuff in assemble to truly understand everything going on?
@@mycelia_ow Even if you do that, you still can't be 100% sure what the CPU will do with this at the end. Writing a few small programs in Assembly is really good idea to get a better grasp of the interaction between CPU, the OS, and your application. However, for productive use, I would recommend to avoid Assembly as much as possible.
@@fr89kis there a way to do it then?
@@turnoff7572 Of course. You can learn about CPU micro architectures and build your own CPU, emulated on FPGA. However, this really takes a significant amount of time and it's not worth it if you don't need to know the inner workings of a CPU. However, as a software developer you should always be aware that you probably know less about the things that are actually happening in the CPU than you like to believe.
The idea of higher level languages is to abstract all that detail away, and make it easier, safer and more efficient to write code.
It all depends on what you're doing. I prefer C++ more for games or higher level stuff because C++ is a higher level language. If you're trying to do something lower level, then you should definitely use C. Now theoretically you could do everything in either language, but using one over the other for certain tasks brings a lot of benefits. A lot of times I find writing generic code in C to be super cumbersome since using generics requires you to manually keep track of types and to typecast everything. C++ just does it for you and it works great and all your code becomes very reusable
C++ can be the same level as C: if you don't use the feature, it has no impact on your code performance. But if you ever try to write a code with multiple potential failures it is much easier to do this with C++ and with exceptions than with C and error codes - specially if there are a lot of allocated resources when the failure occurs.
At some point you'd have to get out of that shell, with code becoming more abstract it's just a matter of time, i understand your point and that's why i also want to learn low level.
But at the point of wanting to know exactly how it works from the baremetal it's just overthinking...
I have the exact same issue with C++. After years without touching C++ and only dealing with C I went to look and algorithm thinking I could just apply it to whatever I was doing and I couldn't. What the functions were doing weren't clear to me. I was def weirded out
I really feel you, I tried a lot of programming languages and when I had to decide whether I stick with C or C++, I instantly choose C just because as you mentioned in C++ sometimes it’s really hard to decipher the real purpose of a specific line of code. When you think you know C++, the language just kindly presents you the fact that you don’t know anything.
"c++ abstracts away a lot of how the language actually behaves" yeah. thats. the point. of higher level programming languages. If we know all 10 ways to use pointers, we dont need 1 Million people implementing the other 90 shitty ways on accident because they didnt spend 3 years coming up with already known best practices by themselves.
I hate C++! It makes everything so much simpler! Ahhhhh!
ye except c++ implementations suck and when you do to have performance you will throw out c++ bullshit abstractions and use c
extremely weird comment considering the entire point of the short is that he knows WHY c++ does these things but he just doesnt like it. i can tell 100% youre an ego coder
@@BigBoss0112"ego coder" woah, new phrase to be stolen
But isn't the point that higher level languages usually come with additional features to compliment the abstraction, like memory safety/garbage collection, etc. and C++ doesn't?
C++ reads like a high level language yet acts like a low level language, whereas C reads and acts like a low level language.
You can do the same with C++, it is open source and so are most of the libraries...
Your resoning is kinda deductive, where does it end? Assembly? Microcode? Designing the circuits yourself?
Obligatory skill issue
Oh god, the zoomers are starting to join the workforce
@@douwehuysmans5959 Pretty sure milienials know what skill issue is.
@douwehuysmans5959 it's much too soon ...
I started at C++ first and my god how learning other languages is so easy its not even funny. Doing C++ i feel like the codes and how I understand them just resonates with my brain and it automatically translates what I want into code. Then comes the other programming langauges like Haskell, J, JS, python, C#. It was really easy. C++ is the perfect language to start on and once you understand 80% of it sometimes its too hard but once you reach 80% then you can start learning other languages and see how fast you learn them
@@BigCobra191 there are very few people on this planet who understand 80% of C++.
and in C you'd have to call it "calculate_difference"... and it still can do heap allocations
IT IS ACTUALLY - OPERATOR IN HIS CODE AND ALL ITS DOING IS SUBTRACT SIZEOF STRUCT FROM PAGE SIZE
@@bies_moron4404 I guess my point was that in C you still have to call functions, and all this reasoning can be applied to function calls just as well: you can't tell what a function actually does just by looking at its name. Does this mean it's a dangerous abstraction? Can we even use functions if we want to "know what every line of code does exactly"? If someone writes a function that mines bitcoins and names it "calculate_factorial" is that really a language problem?
@@AxelStrem - You're kind of missing the point though. A function doing a heap allocation doesn't apply to what he's talking about, because that function would be known to do a heap allocation - you know it's explicitly calling that function, whereas the minus operator is overloaded so at a glance, you don't know what function it's calling until you look up and get the types at that location and figure out which overload of the operator it's going to use. But if you explicitly use, say, "set_sub", you know just from the call-site that it's going to do a subtraction operation on a set, and that's going to necessarily return a new set which will have to be allocated.
@@KingBobXVIand you would know that that particular overloading does a heap allocation. It’s a function like any other, it’s not rocket science.
I graduated from a programming bootcamp and got a pretty jr job as a front end dev. It wasnt the dream job but it lets me get paid to look at code all day. And I have started to scrape some time together to work on side projects and learn some weird stuff now too. I want to understand the OS better and have a way deeped understanding of computers and the true fundamentals of how programming works in a way a 4 month bootcamp could never teach. Hopefully in a year or so i can get promoted to the job i want, or find something that checks all the boxes for me.
I like operator overloading! For example to concatenate string you can use the + symbol, which is pretty intuitive. Also for file system paths you can use / operator to concatenate paths :)
I think that works decently in high level languages like Python that are already super abstract, but in low level languages that kinda gives me the ick ngl. If I'm making a function call I wanna SEE that I'm making a function call.
@@jacksonsmith2955 I understand, but I wouldn’t call C++ particularly ‘low level’. Yes, you have access to low level functions, but does this make the programming language ‘low level’? C++ is very versatile and the developer can choose if they want to program in abstracted layers of code, or just stick to the bare bones. You aren’t forced to use these operator overloading functions at all. But why program in C++ if you aren’t taking advantage of these features? Then yes, use C. Both have their own use cases and some overlap :)
@@emstallz1781C++ better be low level if it wants to excuse that template syntax imo, doesn't have much else going for it
Something about this doesn't sit right with me, you've defined '/' on strings but not all strings are paths.
I'm not saying it's wrong, and as long as you're comfortable with it then great, but I personally wouldn't do this.
My comment also doesn't mean operator overloading is intrinsically bad either.
@@sb_dunk I might be misunderstanding, but the overloaded ‘/‘ operator only works on file path objects in std::filesystem::path. You can (and that’s the beauty of it) use this operator to concatenate a string to a path object. The library takes care care of OS specific filesystem paths (posix, windows). I strongly recommend you to take a look (and tinker) at it to understand it better, and see how intuitive and easy it makes handling file paths :)
100% agree. I personally like writing my own C++ code. But the moment you touch other peoples code, I definitely prefer C over C++ every time. The code is just much more readable even if it's more verbose.
i usually prefer c but sometimes i write some damn fine c++ that feels pretty nice
I prefer Ada and assembly together. I *like* C++, but I must agree that the abstraction features are over used. I think the Ada community is just as significant to why I like the Ada language as the language itself. The same goes for C++ The issue is that if you don't drown yourself in C++ features, then some features can fix a few problems that C never got over.
Eh, I [generally] prefer C as well, but this complaint is just b/c he's a new developer. When you get into large C code bases they become abstract as well - they have a whole book of utility functions in their util files to work with 'primitives' in their abstracted form. This is where the operator overloading he's complaining about really comes in handy, b/c now you can [for example] just add 2 complex numbers together with the + operator instead of calling a function passing both of them. It simplifies a lot of it.
Also with the massive code bases, you wind up in function pointer hell, which has the same problem is abstracted class definitions in C++. You wind up with function pointers that get set to 1 of a dozen different functions at initialization so now you have no idea which one is being called unless you step through or printf all of them. Also, see opaque pointers, for how proper abstraction is done in C.
If somebody is doing crazy things with operators, that's just bad design, you can do bad design in any language.
When you're dealing with simple examples like in the window C may be better b/c you don't have to look at complex class definitions. But C for large code bases is equally as abstract. My main problem with C++ is more of a problem with OO in its entirety, and that's that people are afraid to not use it because it's considered a 'best practice'. So you wind up with these goofy fuckin ownership relations or friend classes b/c somebody's trying to over-design something simple.
I would argue that function overloading in C++ is more transparent than the function pointer hell in C. If you have a good IDE, it can help you navigate the inheritance tree. However, in C it would be very very difficult for the IDE to find all the positions where the function pointers are assigned, so you are left on your own to find all the potential candidate functions which might be called, when the function pointer is called.
@@fr89k Yeah I'd agree they're generally more transparent. But as a slight devil's advocate, while function pointer assignments CAN be anywhere, they're generally all localized in terms of file structure, so you're generally not looking too deep. But yeah, not as explicit as in C++.
Wish I knew what a "good IDE" is though when it comes to C/C++ parsing, haha. They're all pretty shit except for visual studio (OG, not VS Code) IMO. Never found one that could pick up on everything. Most IDE's don't account for even the majority of all basic setups in C++ (eg. inheritance), but even if one nails that down it can't account for linker externs and stuff so it'll never account for everything. That's one thing that's a real pain point for C/C++, IMO. But yea, VS was quite good with parsing. Wish they open sourced that instead of the VS Code shit we got.
C99 actually has complex numbers as a native type, so you used a bad example there 😅. But I fully agree, the C++-style of object orientation makes people overcomplicate everything. But object-orientation isn't bad in general, for example languages like Smalltalk keep it very understandable and simple.
My best C++ experience has been with the Qt GUI-framework, because it manages to abstract things well enough so you really don't have to care too much about the low-level behaviors.
@@imrevadasz1086 That's fair, never seen a native complex # in the wild before. I don't think OO is bad, but I do think OO as a general concept leads to people overcomplicating things and that it's not necessarily C++ specific. There's too much stress on the possibility of extending or augmenting code that it makes people over-complicate it, like making and inheriting from some interface that will NEVER be inherited from after. We even see this at a more basic level outside of inheritance, like #defining "NUM_DAYS_IN_YEAR" as if that will change at some point. Another issue is just that not everything fits nicely into an "object". Sometimes a function just needs to be a function, and doesn't need to maintain any state. In that case, OO just becomes a burden - but nobody will ever say it b/c merely suggesting that OO can be a burden in real life is wildly unpopular.
I too enjoy the inheritance hierarchy of QT. It is very well done. It's unfortunately a bit obvious when seeing some of it why it's not as performance oriented as something like GTK, but the trade-off is that it's a very intuitive framework to use. It's my go-to for GUI apps. Wish the licensing was a bit better, but it's really great. 2 thumbs up from me.
@@MrSlowestD16 True, in too many cases objects are used where just a "module" (namespace in C++) would be enough. Part of the problem in C++ programming is that a lot of people come to C++ from Java, which only offers Classes for modularizing and namespacing code, and every bit of code has to be in a class. Hence a lot of C++ code is written in Java style.
Agreed! I had to translate lines of C code into MIPS ASM in my hardware architecture class. C maps more directly to the low-level instructions. C++ tends to abstract away too much and the syntax can be weird. Personally I prefer coding in Java though.
So basically you prefer what you know. As most people does.
No, he prefers sanity. Do you even code ? 😂
Listening comprehension zero. You.
Exactly why I like C. Another reason is coz I learnt C first, and data structures algorithms, operating systems, networking and all in C language. So everything else feels like vague. I feel uncomfortable when I don't know what the function is gonna do exactly for any change I make.
Everytime i hear someone say C is better then C++, i want to see a project where they don't use C++.
@@suoyidl2654 the linux kernel ain't enough?
linux kernel source code
Can projects made using C along with the Raylib library be considered a C-based project?
@@suoyidl2654 I did
You don't really know exactly what every line of code is doing without disassembling. All modern compilers have varying degrees of voodoo, depending on platform/processor, options, your code, etc. This is orthogonal to the complexity/abstractions in the C++ ecosystem and common to most modern compilers. But, I understand your sentiment and frustration with overly-complex C++. Throw the C preprocessor in the works and both languages are very messy. A fact that influenced why they neutered the C# preprocessor.
I don’t like assembly either. I like to exactly know what bits are getting executed in the machine.
I dont really like machine code either. I like to know where my electrons are, I need to see what my electromechanical transistors are doing!
@artemis4771atoms are too abstract...I like elementary particles more...
You guys are pathetic, when I code I wanna know exactly what quarks and leptons are doing. It's fundamental to know about them if you wanna keep track of your protons, neutrons and electrons.. 😂
I love watching the wave functions.
That's what the rip register on x86 asm is for you dingleberry
Yess! C is quite readable and understandable. But Cpp has so many variants and features that each project is effectively written in it's own language. At least thats how I feel about it.
C++ is great **IF** you (and the code you are working with) stick to the standard and follow best practices for modern C++ (i.e. C++11 onward). Pre-C++11 was a nightmare and people who still code like that should just stop plz
Modern C++ makes me want to vomit.
You're probably not gonna convince people who love c with this. The reason a lot of people who like c trash about c++11 onwards is because that's when it started doing a lot of things differently than just c. Pre c++11 code often feels bad to c++ devs because it feels like c code with classes added on top
Modern C++ is pure crap.
@@sinom One of the biggest C++11 features to me are smart pointers. Before C++11 you had a huge problem with keeping track of the ownership of objects. Even if you dislike shared_ptr because it does one additional redirect and you don't have 100% control over the destruction of the object, you have to agree that unique_ptr is awesome. Your method doesn't take ownership? Fine, you can still use raw pointers in the method arguments. Your method takes ownership? Use unique_ptr in the arguments and move the unique_ptr in from the caller. It's perfect to track ownership.
@@fr89k C++11 has big issue with smart pointers. C++14 is much better with this case (but not perfect) but it break the compatibility - on the other side: it's not a big problem. Some features are also introduced with C++17 and C++20. But C++14 is usable.
100%. Plus every time I am looking at a new c++ project I have to look at multiple classes just to have a clue what is going on.
I wonder if this guy would have a stroke if asked about C#?
c# is easier than c++ and c . so what a stroke ? idk
@@Phantom-lr6cs C# is DIFFERENT. Not really easier than C, as it has a lot of features which are not present neither in C nor C++.
C# is the best language I have ever used when it comes to productivity and actual enterprise level code. The code just comes out super clean and easy to understand. Performance is excellent too.
This dude has a "stroke" every time someone mentions C
@@Michael-mr3ig not for game dev, for game dev the GC is a nightmare on performance. You end up having to use compute shaders and other tricks for performance half the time
That's the beauty of cpp as well! Do whatever you want. If someone's code is unreadable it's not a language fault
it's not a language's fault, it's a segmentation fault.
these C lovers really hate operator overloading.. But that is the feature that I like the most about C++ and that sets it apart in freedom for creativity. Of course there's a very limited use case for it, but it is extremely helpful in my area, computational mathematics.
Yeah as a C++ dev I also didn't understand his point about operators overloading lol
C++ to me is freedom, I can code really low level or really high level by building from the ground up and having a lot of features safety like smart pointers etc...
When C is just stuck as a low level language, make it pretty much useless in most modern use cases tbh (I would rather use Python) bcs if I do some UI frontend for example I will use C++ and if I need stuff like memcpy, memset, reinterpret_cast, sizeof and a lot of diverse low level stuff I will still use C++ because I can do both:
Low and High level at the same time, having the best of both world !
yeah. i think its really neat how in c++ i can make a vec struct template that overloads a bunch of math operators, so i can do math on them how i would with base number types. the alternative (explicitly calling functions for everything) would be much more verbose.
Exactly, STL has way too much abstractiom that you cant even begin to imagine whats happening under the hood, and Im really having trouble forcing myself to memorize the custom syntax for those layers of abstraction. I really gotta buckle down and learn it, so I can stop bothering with it, I dont ever write rust, but I know I should.
Hard agree, c++ is difficult to read, i hate having to constantly pull up manual pages
If you find C++ hard to read it's your colleagues who are to blame. You could write stinky unreadable code in any language if you really wanted to.
And yes, C++ is difficult, that's why not everyone should be using it. It's not like you go design nuclear reactors after taking your physics introductory course, why is everyone thinking they can get away with it in CS? If you suck at programming just do Python and be happy its not like it pays less than C++ 🤷
Lol and you don’t have to do that with C? Have you never dealt with Linux code? Or any library or API whatsoever?
@@cd2320 excuse me, why would he need libraries for all of his "hello world" variations
You kind of need a fully featured modern ide with autocomplete and display over hover to really use C++, it sounds like, then.
Which is precisely why it’s fallen face flat on linux. No such thing. CLion is close, but realistically C++ is most used on OSes with these sorts of editors, e.x. VS, VSCode, Xcode. vsc is on linux now so it could be languages that can only be rapidly used with the use of tools may expand. My theory anyway.
Using C++ in anything but visual studio for me is a nightmare.
I like C++ but I'm pretty judicious in my use. Operator overloading is really nice if you're dealing with mathematical types e.g. arbitrary precision numbers
For me the only operators I typically overload are = and ==.
@@RetroAndChill I really don't like a lot of operator overloading I've seen for =. Part of what makes someone used to C have a hard time understanding what's happening in code
@@RetroAndChilloverloaded = operator is evil, I don’t see any reasons to use it
@@ic6406 Move semantics is a good reason to
@@ic6406 If your class has a shared pointer (or even - god save us - a plain pointer) it is very unwise to use default implementation of an assignment operator - very unwise... Unless you want to keep the member object shared between all of the object of the class. So always check your class semantics.
i think c++ is better just because you can put c and asm code inside .cpp code, so you can entirely create a code in c and use c++ just when necessary without creating 2 different codes to link
At that point just use assembly then
what a beginner dev thing to say
@BobrLovr what is sufficiently low for you? All thresholds on this matter are arbitrary.
I think one thing that really smacks c++ developers when they first do c++ is the implicit casting. People think string literals get implicitly casted to string in all scenarios, but that is not the case if there is boolean override. The ADL converts const char ptrs to bool and then some developers spend hours trying to figure out what is going.
im gonna wait for him to learn about languages with implicit type conversion
When i first read about operator overloading i thought it was great. I immediately thought of things like a complex number library where it makes perfect sense to overload your basic math operations. Then my roommate started to describe some of the horror stories he'd seen where the overloaded operations don't make sense or are counter intuitive.
I still think it has a place but programmers really need to make an effort to only use it when it makes sense.
I don't like C++ because in some scenarios different compilers or different language versions behave differently. To me, C++ seems like a language that was patched way too many times while trying to have backwards compatibility.
Then you add on top libraries like Boost and QT that add another level of complexity.
Seems like there's no real standard library, even for basic types like a string, there are way too many types. Like QString, std::string, char *, wchar_t *, etc, etc, etc. it's really annoying on a large code base.
std::string
I mean, C does that too to a much smaller degree, but I agree. The "different compilers do different things" is 99% "MSVC is doing it's own thing again and everyone else is following the C standard and building C++ on top of it as the standard intended." ISTG, MSVC supports 0% of the C changes after C89 or so.
@@__Brandon__std::string_view
struct String
{
char *str;
u64 len;
}
Char* and wchar_t* are classic C strings.
Wchar is 2 byte Unicode or something like that.
There's also std::wstring if you need Unicode.
also in C there is usually one or two ways or doing something, in C++ there's a hundred and the hardcore OOP fans will only accept one.
I was just dumped into a C++ project with only C experience and I'm literally writing the same amount of logic 10x slower and its still not enough
I think C++ is as readable as C. Everything which you can't read and know what's happening on the OS is just some form of a function call just like with C. You just have to bear in mind that you can call "functions" in more ways than just func(). For example: operator overloading
In C++ (t1 + t2) should be read as add(t1, t2) in C where add is some user defined function (unless t1 and t2 are primatives).
Complexity is not necessarily harder to read or understand it just means you need to look at the internals of those structures to find out what the programmer is doing, which lends itself to useful abstractions.
Things get difficult quickly when you have lvalue, rvalue, pvalue, xvalue, gvalue and all the templates adding to the syntax. It is a language that’s difficult to read, understand and program(in certain styles). While in C, whatever you do you know if it is for the compiler or run time or just some macros you define, and you know what the computer is doing in memory.
@@fdc4810 It's about good practices and a knowledge of a team members. Always. I've seen a lot of very obfuscated code in C (because C allows to do many nasty things). This is a place for a code guard and peer reviews.
You can use C++ just as a better C if you like. Have to be careful not to pull in too much overhead though. Typically applications where C is the best choice want to be lean. In the end, just choose the best tool for the job at hand.
Yes. As you do not pay ANY price for not used c++ features you can use it as a better C - even on microcontrollers (of course 95% features would not be available nor reasonable, but at least you get a lot of type safety forced by a compiler).
Yeah it's a skill issue.
I can spend hours looking how a new structure compiles and behaves before I start using it.
You just not supposed to use in c++ something you don't understand how it compiles and works.
Sometimes you are in a codebase too big to understand before you start debugging, or it's infeasible, the last place I worked just the section of code my team handled was 8 million lines of C and C++
Have fun working on a large project with a huge code-base then. Have fun having to understand the whole code base before you make a change.
You seem like a guy who's only ever worked on his unreal demo project.
If a collegue gives you a hammer and it turns out to be a screwdriver you're going to waste so much time for nothing. And that time costs money for the company.
@@wiczus6102 I always understand the whole system before making changes no matter how big the codebase is, it's never more than 3 days. If your team is unable to make the right abstractions it's a skill issue. And it will result in bug fixing taking more than 5% of your teams time.
He can tell you what each line does, but he'll have to stare at the code for an extra 6 hours to figure out what the program itself is doing.
@@wiczus6102 And in this case C++ may be a great tool for responsible developers. I've spent a lot of time rescuing big and "doomed" projects by introducing correct design patterns (which took time but in the long run it gave a lot of benefits to the company).
I really like operator overloading though. In fact, that's just about the only unique part of C++ that I use. If I have a struct for a vector, I would much rather do vectorA + vectorB than something ugly like addVectors(vectorA, vectorB).
skill issue :/
As someone who writes C++ comercially... yeah I guess I agree
I just write straight to the transformer with a pin
Yup. I manually drag the electrons through the circuitry of the board to run all my programs.
that's how i feel about a lot of more abstracted languages (i.e. python, JS) bc i can only reason about the abstractions. i can't make sense of what's really happening with the code i write.
When I was involved with software development full-time, I never made the leap from C to C++. My main issue with the whole concept of C++ stemmed from its lack of efficiency. This commentary over 25 years later is music to my ears. 😊
C++ is very efficient
@@mightymalakai hmmm, then which operating systems have moved onto a C++ foundation from C? You can claim potential development efficiency gains. I’m referring to runtime performance.
@scottlivezey9479
Not every OS is Linux. Operating systems now incorporate C++ in their code.
I'm sorry but your bit about runtime performance is doubtful as best, to avoid saying plain wrong. The motto of c++ is 0 overhead abstraction. You can watch quality tutorials or presentations from cppcon to get an idea of the philosophy behind c++ and how to write quality c++ code. I invite you to watch the presentation of Jason Turner in the 2016 edition of cppcon where he demonstrates to you live how added abstractions and clarity in the code will not affect the generated assembly.
C++ has its advantages. Use a bignum library with C, a = (a+1)%max; becomes bignum_add(tmp,a,1); bignum_divmod(tmp2, tmp1, max); bignum_copy(a, tmp2.modulo); I can write constructors for my structs. I can namespace my globals. I can use json without wanting to kill myself.
This is the own dck sucking issue.
99.9% of programmers don't need to know exactly how/where the memory is allocated. Otherwise go for assembly if you just want to show off.
A higher level of abstraction allows the code to be understandable, and you can still look at the implementation of the language/compiler/whatever if you really need to.
@@Xevion You will never need to know what the operating system is doing unless you're working on optimization or drivers/onboard software.
you sound like you never worked on an embedded system, game or any performant software. Being able to know the flow of resource allocation does **not** reduce expressiveness. Using custom allocators you get a lot of control and a lot of convenience, C and C++ were poorly designed by having one global allocator and no defer keyword and EVEN THEN you can still reap the benefits of using one.
@@marcs9451ah yes, that only one allocator in C called operating system
@@Obscurite1221 this mentality of "developers don't need to do things because it's done for them" is so lazy, why are we trying to foster an environment of developers that don't know what they're doing?
@@OverruledDood Are you a developer? Or are you yet another person who has no actual idea what they're opinionating on and just spew out words?
I use c++, but only for the constructors/destructors/assignment because it's useful for handling resources acquisition. I only ever overload operators when it *really* makes sense and doing it some other way makes it harder to follow.
C for low-level control, python for high-level abstraction. In my (admittedly limited) experience c++ tries to give both low-level control and high-level abstraction which leads to messy code that spans too many levels of abstraction at once
You have just as much low level control in C++ as you’d have in C. C++ can be messy, sure. But so can C be. Just enforce coding standards in your team and you’ll be fine.
i can see your experience is limited cause youre yapping absolute bs. c++ gives you a high level of low level control and good mid-level (wouldnt call it high level at all) abstraction. understand how simple continuous and non continuous memory works and suddenly understanding how a vector works isnt such a big deal
Python is one of the shittiest languages out there
@@martijn3151 "Just enforce coding standards"
YES. This is the correct way of handling mess in teams.
The problem with people who defend C++ often doesn't use C++ at all. They just write procedural C++ like it's C with classes and vectors. If they actually start using advanced C++ features theyd understand how error prone that code is. Now it is definitely a skill issue for me but I'd rather write simple code than debug hours of complicated code
Complicated projects in C inevitably end up having horrible, hard to read stuff in them though. Every legacy C codebase I’ve worked with has some crazy macro shit to do things that normally come working out of the box in C++, and they inevitably implement their own string library to make string handling easier and do a bunch of other redundant stuff. C can be nice for smaller projects but large C codebases can be really rough.
C++ has the worst syntax of any language not deliberately designed that way as a joke.
Rust has the worst semantics of any language not deliberately designed that way as a joke.
Loved overloading as a beginner but like the same can be done with a function which will make it clear what is happening, compared to overloading
Language readability is only one aspect of several factors you should consider when choosing a language.
yes, but it is a pretty important one.
I also like C more.
Modern C++ is just a totally different approach of a language than C.
C++ is solving things by adding new stuff to the language. C is solving things in code.
I like C’s approach more because it makes the language itself very lean. This is good because it gives us all a common ground. This helps tremendously when maintaining packages and patching old software or making PRs.
His c++ problems sound more like a skill issue. Like if the first learnt c++ instead of c, he would be saying the exact same thing but about c
Nah. I've used C++ for a long time and just started using C. I like C a lot better. Sure, I miss some C++ features, but C makes much more sense to me.
I've learned 6502 and x86 and C before c++ (and after that ada95, java, c#, python and many more) and when I have a choice C vs C++ I ALWAYS choose C++ (even on microcontrollers). It's simple: even if I don't need (or cannot use) specific c++ feature I got it's type safety (well, maybe it's not perfect but it at least exists).
100%. I won't write c++ unless I absolutely have to and even then I use the bare minimum of features.
i thought he was talking ab bra size
This man knows nothing of the sorts
Even A can be pretty nice, you could think GGs are good but they are way too impractical!
I see the value in object oriented programming but my brain just has a much easier time wrapping itself around procedural code.
No offense but this is probably your worst take.
A man can't prefer one language because it has less abstractions than the other? I don't get why this discussion is so controversial
jr. dev ah comment
I do kinda wish that C would at least have some built in types like matrix and vectors and have some operators specifically for those, but other than that yeah