https://www.youtube.com/watch?v=K3z7Ymx4UWY
无作者
intro
What’s up, guys?CJ here.Guys, in today’s video,I want to focus on the worst programming language of all time.This is a recent video that dropped,has received a lot of controversy, and a lot of views in a very.
namespaces
short amount of time from a relatively, unknown channel.Now, this is not going to be a takedown video.Instead, I want to focus on the highlights of this video,the lowlights, and the points that I think need more explanation.Now, this is all coming from the perspective of a C++ software engineer,somebody that’s worked with C++ professionally, for around 5 years now with a background, in the space of quantitative trading.So, let’s take a look.>> Aesthetically,the worst thing about namespaces, is that they incentivize programmers to choose the shortest names possible,typically two or three letters.Obviously,if a language forces you to write namespace prefixes everywhere all the time,you’re going to end up picking obscure shorthand names for your namespaces.The end result is that C++ code bases are riddled with
be ˈriddled with sth
to be full of sth, especially sth bad or unpleasant 充满;充斥
His body was riddled with cancer.
恶性肿瘤遍布他的全身。
Her typing was slow and riddled with mistakes.
她打字很慢而且错误百出。
Okay,so this is a little disingenuous,and I say this because, the most, nesting that I’ve ever seen is three to four levels of namespace nesting, in like a third-party library such as Boost.
Most companies, when you write code,people are going to start looking, at you funny if you have four, to five levels of namespacing.Most people have two at most, the company name and the library name.But even then,even if you find yourself working with a third-party library, that has a tons tons of levels of nesting,you can always just use a using directive.Using namespace some aesthetic name equals some unaesthetically long namespace.And that’s all you need to do.So, here he ends up dedicating an entire segment,
Modern C++?
maybe around 5 minutes, to modern C++.Let’s see what he says about it.Language has evolved so much and just keeps continuously, evolving that it’s hard to truly know what modern C++ even is.Did you mean to learn modern C++ or modern er C++ or modern erist C++, or post-modern C++?What are we even talking about here?So, this is really easy to solve.And that’s why I also feel like this was a weak point of his of his video.The only reason we have the term modern C++, is because C++ has such a long history.We can solve all of this by simply asking what version of C++ we’re using.14, 17,you know, 20,23, 26.That’s the question here.You don’t need to add the the ambiguity of the version with the word modern,right?Imagine I ask you, uh what is modern Python?Are you using modern Python?What is that?That’s equally ambiguous, right?Is it 2.7?Is that modern?Is it 3.1?Is it 3.7?Is it 3.12.2?Right?What’s modern Python?I can apply the exact same reasoning to any other language.
It just so happens that C++ has a very long history,and that’s why we can reference it relative to modern or not modern,older versions of C++ or newer versions of C++.
beginners confuse C with C
But the answer is a resounding no.Idiomatic C looks very, very different from idiomatic C++.They’re different languages.And one of the first things that the C++, community, tries to hammer down into beginners’ minds is that you shouldn’t write C++, like C.Don’t use C-style strings, use standard string.Don’t use C-style arrays, use standard array or standard vector.Don’t use enum, use enum class.Don’t use union, use standard variants.There’s a whole list of things that you need to remember on, You don’t need to worry about any of this if you don’t start with C.If you’re a beginner and you’re looking to learn a low-level language,and you’re debating between C and C++,and you’re thinking of using C as an on-ramp to C++, just don’t.Then all these troubles go away.It’s like somebody that wants to come and learn Python and he says,should I learn Python 2 or should I learn Python 3?Should I learn type Python 2 before Python 3?No,
just start with Python 3 and pick a version that you’re most comfortable with.There’s a lot more versions of Python than there are C++,but you don’t see people running around with their heads cut off saying,which version do I start with?What’s modern Python?Which one should I use?You’re taught that returning a pointer to a local variable is dangerous.
understanding how the OS interacts with your code is bad?
because the memory is deallocated, when the function returns.But then it turns out that this doesn’t apply to string literals, because they have static storage, duration and exist for the entire, lifetime of the program.I don’t understand why that’s a downside.Like,why understanding that string literals are stored in the initialized, read-only data section of a program is a bad thing.Like,why is understanding how your software interacts with the hardware a bad thing?Additionally, some optimizations behave differently across compilers.
compiler optimizations can cause bugs
This makes cross-platform development more frustrating.The various optimization levels can also dramatically change program behavior,sometimes introducing subtle bugs that only appear with certain optimization, levels,but not with others.That’s actually a really good point,and I wanted to highlight, that point here because it’s something that I, found with one of my community members.So, there’s this problem here on my platform called getcrack.io.And I told her that money laundering it hints at the solution.Let let me show you where optimization, here, actually impacts things really differently and and what the solution for it is.So,if you look at this piece of code, and you assume that the compiler optimizes aggressively,maybe pause and think, about what you think the result, of X and Y being printed to the screen should be.Is it 1 1, 1 2,compilation error, undefined behavior?So,what we’re doing here is we’re creating an object of type A, and we’re passing a pointer, to that object to call,right?
This A object has a V-table pointer, and because the V-table pointer is const,and so is the V-table,it’s set up once and it never changes throughout the lifetime of the application, or or the runtime of the application,the compiler can do some pretty aggressive optimizations, here that in this case actually result in a bug.So, what we do is we say that an object of type A exists at this memory address,and we pass that address to call.Call here will return one.It’ll print one.Now,what we then do is we repurpose A’s address, to create an object of type B pointer,and then we pass B to call.Now, this should in theory print two or return two,but it actually prints one.And that’s where the bug exists.And it does that because the compiler is under the assumption, that the address associated with a object allocated on the stack of type A, will always have a A V-table pointer.But now, we’re repurposing that A address and putting a child there or a B.And the compiler, being none the wiser,
has still optimized to a point where it thinks that that V pointer is const.So,it still references A’s, V pointer even though A no longer exists at that address.Okay?A solution to actually fix this, so if I was to give it the right answer here,is to use std::launder, when we’re creating the object of type B at A’s address, to tell the compiler, to ignore all previous assumptions it’s made about A’s address.So, this point he is right on.You know, certain optimizations can introduce some bugs.This isn’t only a this person’s wrong video,but I I did want to highlight an actual example, which I think he missed out on.Building a C++ project is a genuinely insufferable experience.
you need to read 800 pages before you write hello world
The core issue is that there’s no standard compiler, no standard build system,no standard package manager, and no standard ABI.The result is a deeply fragmented ecosystem, where every piece is incompatible by default,every setup is a bespoke Rube Goldberg machine,and even the simplest task demands an exhausting amount of boilerplate,configuration, and tribal knowledge.CMake has become the de facto meta build system for modern open-source projects,but developers really hate it.It’s a horrible build system, that was in the right place in, the right time and just happened, to gain enough momentum to become, widely adopted.If you really want to learn CMake, you have to read the 700-page textbook.This is just to learn how to build your application.We’re not even at hello world yet.This is a bit ridiculous in my opinion.You don’t need a 720-page textbook on CMake to get started.Just like any tool, there are tutorials online,there are videos online,there are people out there that have built projects.
that you can go and look and read up upon, on GitHub,on other places.And what’s more is that 95% of professional C++, they’re not writing CMake almost at all.There are entire organizations at companies that are focused on build, CI,and CD.So, unless you are an engineer that focuses on the build system or CI and CD,if you’re a C++ developer, 95% of the time you’re writing C++ code,you’re not tinkering with the CMake.Maybe if you want to add another file or remove a file, or change some flag for build configuration,you might be doing that.If at all, right?But most of the time, you’re not going to be focusing on any of this.The way I see it,having a diverse lineup of build systems or build system generators, is a good thing.You can play around with each one of them, see which ones you like,which ones work for you,and the one that is most user-friendly is going to come out on top.It’s a free market in terms of allowing the consumer to choose.
what they want to go with and what they want to work with.And that’s not a bad thing or something to be afraid of.
cpp doesn’t have intuitive one liners
Functions are difficult to search for and use in comparison to class methods.In JavaScript, if you want to transform items in an array,you just call dot map on the array itself.It’s such a nice, simple,intuitive one-liner.But in C++, there’s no corresponding equivalent.Instead,you need to call the free function standard transform and insert numbers.begin, and numbers.end, in a standard back inserter and in a lambda with the ugly lambda syntax.It’s really verbose and unsightly,and developers have all kinds of different ways to format it,but it never fits on one line.Modern languages have a way to express this in a single line, and I wish C++, did,too.And comp-, So, C++ does,but you kind of ignored it.So, for the sake of amending that point that you just made there,here’s an example using ranges, right?Now, this isn’t maybe as beautiful as Python,but this can definitely be a one-liner if you’d like it to.So, here’s an example of a vector with three elements,1 2 3,
and I’m using views introduced in C++ 20, to run a filter to take only the odd numbers,right?Then multiply them all by two, then take the first five,and drop the first, and then reverse the container,right?If I wanted to do something like Python, that slicing sort of syntax,well, I can do that in one-liner in C++.It’s not too difficult.I just use drop and take, and that does that all for me.Now, I also use the namespace here,so in theory I don’t even need this, so I can make it even prettier.But yeah, you get the point.C++ is definitely moving towards having cleaner syntax,easier to understand code, and so that was a miss,in my opinion.
vector of bool is different
When you create a vector of string, you get a vector of string.When you create a vector of int, you get a vector of int.But when you create a vector of bool, you don’t actually get a vector of bool.The vector has a weird specialization case for bool,where it stores each bool as a bit instead of a byte.So, it’s not really a vector of bool,it’s a kind of dynamic bitset.This saves space,but it doesn’t offer all the capabilities, and interface of a normal standard container that you’d expect.For example, you can’t take the address of a bit within a byte.And when you try to access elements with square brackets,it doesn’t return a normal boolean reference.It returns a proxy object for the bits in question.It also comes at a great performance cost.The whole thing is just so weird and unnecessary.There should have been a separate, data structure for this called, standard dynamic bitset or standard, bit vector.It’s such a terrible design mistake.
So, I both have both a teaching moment here and a retort to to this point.So,he’s right that the template specialization of bool for vector, operates a little differently.The teaching moment here is that yes, it returns a proxy object.It doesn’t return T reference.It doesn’t return a boolean reference.But, as long as you don’t use auto,or you might use auto with a combination of static cast, then you’re fine.You don’t need to worry about the return proxy object.In fact, you can even be a lot simpler and not use auto,and simply index into the vector,but make sure the type that you’re explicitly asking for is bool, and not auto,so you don’t get the proxy object.Instead, you get an implicit cast from the proxy object to bool.Then you’re safe.Now, let’s also bring up the retort.So, later on in this video,this content creator brings up Rust as this panacea, right?As this very promising language that solves a lot of C++‘s problems,and it might really do that.
It might solve a lot of C++‘s problems.But I think it’s a bit disingenuous, to not bring up the issues that Rust has as well.So, yes,vector in C++,or at least the boolean specialization here that we’re talking about,has an issue.If I try to sort an array or a vector of integers in Rust,I will get a sorted vector.So, I have this problem here.25% of people have tried it, and there’s a 28% success rate.It’s almost a guessing success rate.Right?So, what do you think will happen if you try to sort this vector?Well, it actually doesn’t compile,and that’s a unintuitive result for a noob,just like the template specialization of bool for vector, might have an unintuitive, result for a noob if they try to return a reference to the underlying object, by using the indices operator,right?You can read more about why this is the case here.It’s because there are certain floating point values in Rust, like NaN,that don’t have a total ordering.But, you know,C++ isn’t the only language that has its nuances.
Every language does, and that’s okay.As long as you’re willing to put in the time to learn the language,you are going to encounter these sorts of things.Let’s say I have a function that takes in an int and prints it to the console.
templates are confusing and bad
If I wanted to make one for a double and string and float,I’d have to write out three more functions.But templates,you can write a single function and instruct the compiler to automatically, generate all the others for you.They’re like blueprints for generating code.This is one of the key advantages of C++ over C.In C,you need to re-implement, each data structure for each type you want to use it with.Whereas in C++, you can generate them with templates.Templates are incredibly powerful in ways that I can’t even begin to explain.But there are a number of problems.First of all, they can get extremely complicated.There’s an 800-page textbook solely on C++ templates.Second of all is that they produce enormously long,cryptic error messages that are incredibly difficult to decipher.This was a miss, as well,because he never actually mentioned that C++ 20 introduces concepts,and concepts allow you to restrict the template type,
which also therefore allow you to produce much clearer errors and warnings.I’m going to be throwing that up on the screen,so you can see an example from before and after.You may need to pause the video, but this is an outdated critique,in my opinion.
templates can only be in header files?
Heavy code significantly increases build times,since the compiler needs to generate specialized, code for each template instantiation.This, of course,can lead to an increase in binary size.There are also rules around templates,like how generally they must be implemented in header files.In other words,you can’t separate the interface and the implementation, like how you can with regular functions.Also, historically,That is actually wrong, as well.Now, I what I’m only hesitating to say it was wrong because he said generally,so I’m not sure if he’s familiar with the case where you can,but you can have the declaration, in the header file and the definition in the CPP file.All you have to do, if you choose to go down that route,is at the bottom of the CPP file,list out the explicit template specialization, of the actual type you’d like the compiler to generate a template for.I think he also misses a lot on the benefits of templates.The fact that, yeah,a template can cause, you know,
a larger compilation times, but templates also are just blueprints.You don’t actually generate template code for code that you don’t use, right?So, you can have 1,000 lines of templates,10,000 lines of templates, but as long as the templates aren’t used,then they don’t lead to any bloat in your in your binary.And let’s be real, binary sizes aren’t really an issue nowadays,right?Nobody’s producing a terabyte-sized binaries, right?We all have at least 2 terabyte hard drives.You know, what’s a 100 megabyte binary?Even a 1 gigabyte binary.Nobody’s crying over binary size nowadays.Yeah, let’s go back to this.Nobody’s writing code like this at any company.Or nobody that wants to keep their job is writing code like this.This is probably the most extreme example of template code you will ever see,and to me, that’s a bit deceptive,especially to a new viewer that might not be familiar with C++,to just throw this up on the screen and say this is how templates look.
99% of templates don’t look anything like this.So, I didn’t like that he did that.Templates are also used for template metaprogramming.
pretends metaprogramming is required
This is one of the most powerful, but also challenging aspects of C++.It’s a technique used to perform computations, at compile time rather than run time,by acting as a sort of functional programming language within C++, that executes during compilation.All the problems with templates apply doubly so to template metaprogramming.The learning curve is incredibly steep,because the recursive style which it is written in is fundamentally, different from normal imperative C++.Not to mention, its syntax is even more verbose and obscure than normal C++.The code is often so complex that it becomes difficult for even experienced, developers to maintain and modify,and it’s a debugging nightmare, because it executes at compile time,so traditional debugging techniques don’t work.And of course, just like raw templates,it can dramatically slow down compilation times.One really big flaw with templates and template metaprogramming in general-, Okay, I’ll pause there.
I have more to say, but this point kind of feels like a cheap shot,and you do not need, to know template metaprogramming to be a proficient C++ developer.So, diving into this point and focusing on it for,I don’t know, what is this?An entire segment, well,I guess half a segment, is to me a bit of a waste of time.Um we’re also going to get into something that he got wrong just right now,so let’s take a look.
can’t limit the types of a template?!? Concepts?!
is that they don’t have a built-in, direct way to limit which types, are allowed to be used with the, template.So, for example,maybe you have a template that’s only supposed to be used for numeric types.We need a way to limit the user from using it with non-numeric types.To solve this dilemma, developers came up with a technique called SFINAE,which stands for substitution failure is not an error.This is probably the most poorly named thing in the whole language.It’s basically just a pattern for writing templates in a way that should only, Okay,so this pattern, this SFINAE pattern,is I’m not going to say dead in C++ 20, but it has been significantly hamstrung.Um with the introduction of concepts in C++ 20,if you would like to bind T to be an integral type, for example,or some other interface type that you’d like to, you know,write yourself, you don’t need to know more complicated SFINAE.You just use concepts.You use requires clauses, right?
C++ has already solved this, but this person is harping on it for a long time,and not even mentioning that concepts does address this.
c++ concepts is hard to google for
There’s also a new feature called C++ concepts,which is meant to replace SFINAE, and help templates provide more helpful error messages,but this is a terrible name, because it’s hard to Google for.The term C++ concepts,which refers to this specific C++ feature for template type constraints,can easily be conflated with the English word concepts,which refers to ideas or Okay,this is this is dumb because he spent an entire template segment, talking about how horrible templates are for reasons, that can be alleviated by the introduction of concepts.And so he spends 10 seconds saying, “Oh,by the way, concept solves a lot of this,but concepts are dumb because they can be confused with another word.We need to we need to re we need to reinvent, English to add a new word that hasn’t been, occupied by a word that already exists.”, That’s like saying the Rust programming, language is dumb because there’s, a game called Rust that’s, probably more popular.So,you need to find the variant definition.
c++ doesn’t have pattern matching
to check the types and then switch, back and forth to reference them, while you type them out manually.In contrast,Rust has excellent ergonomics and auto complete support for pattern matching.When you’ve tried pattern matching in Rust,you’ll never want to go back to using standard visit in C++ ever again.So, this isn’t per se a disagreement with you know,C++ shouldn’t have match and I I disagree with you and Rust’s match sucks,but once again,a a general theme that’s being brought up here is how much of a panacea, Rust is and how great it is,but even things like match in Rust can confuse a lot of new people out there.And so it isn’t per se the, golden bullet that this content creator makes it you know,appear to be.Let me give you an example.So, I have this question,the exact same variables that he had with match match A,and there’s really three options.And this question has been tried only 31 times, let’s be fair,but it only has a 29% success rate.So, match also has its quirks in Rust.
Now, Python can get even worse.This one has a much higher first attempt count and a much lower success rate.This is worse than a guess.Okay?And this is a match statement in Python.So, yeah,match is cool, but it doesn’t come without its you know,quirks,and I don’t want to oversell, or I don’t want this content creator rather to oversell Rust as a solution, to, really, a language that doesn’t have anything equivalent at the moment to compare.He mentioned stood variant and he showed that in his case it can be messy,but match isn’t some golden bullet.Editing Jesus here, guys.While this creator did, to give him credit,talk about the pros and cons of Rust near the end of his video,I still just think it was a little too front-loaded with how great Rust is, and how horrible C++ is relative to Rust.C++.
noexcept as the default?!
also has a keyword noexcept, for indicating that a function won’t throw an exception.Some developers think that everything should be noexcept by default.Java has the opposite where you indicate Okay, so he brought up two things here.One is that it indicates that a function won’t throw an exception.And two is he said that it should be the default.Now, noexcept doesn’t say that an exception will not be thrown.And that’s why when he said it should be the default,I knew that he wasn’t too familiar with noexcept.What noexcept says is it’s a promise that if an exception is thrown, that the program will be terminated with a call to std::terminate.Okay?Noexcept functions can still throw.If it’s caught within the scope of the function,then everything’s fine and dandy.If that function propagates outside of the scope of that function,then std::terminate is called.So, no,I don’t think it should be the default, because exceptions are used liberally in some industries,not used at all in others.
But be a little careful in the way that you word this.And with all the constructors in C++,
constructors are confusing
it can be hard to figure out, if a line of code is invoking, a default constructor,a copy constructor, a move constructor,or conversion constructor, or something else.Sometimes you end up with multiple constructors being called in succession,and it all happens behind the scenes without you being aware of it.In cut It’s funny because I actually thought of a question, that helps developers train their eye,and I called it 96% of you will fail this.And it ended up just being the case that 94% of people failed this problem.So, this problem has been tried 812 times.And as you can see here, there are only three operations.There’s a default constructor, a copy constructor,and a copy assignment operator, right?Now, the return type isn’t part of the function signature,so I didn’t need to write out object reference, but you guys get the point.So, there’s three operations here.You can either print one, two,or three.And then, I wrote a couple of different ways that I may or may not be initializing.
this object.And I asked people to tell me what the result was.I got some funny responses in the comment section here, but questions like this,if you’re interested, are free,and they will help you train your eye to be able to tell exactly, what’s going on.
operator overloading is bad
Another weird thing you can do is overload the ampersand symbol operator,which is meant to give you the address of the object.You can overload it and just return a random number.Now,anybody who uses the ampersand symbol, thinks that they’re getting the memory address of the object,but they’re just getting the number two every time.And if they try to dereference it,they’ll probably get a segmentation fault or something.So, if you want the real address of an object without any tricks,you shouldn’t use the ampersand operator.Instead, use the function std::addressof.So, what he’s saying here is two things.One, C++ shouldn’t allow you to overload operators.It’s stupid.Java doesn’t do it.And he’s also saying that you shouldn’t be allowed to overload the ampersand.So, let’s let’s let’s talk about those individually.For the first claim,it’s weird that he relies on the fact that other languages, don’t allow you to do XYZ, when in this case there are some holes in that reasoning because C#.
allows for operator overloading.So, if operator overloading was not useful at all,why are other languages allowing for it?The second point, is that everybody learns about the ampersand operator, before they learn about operator overloading.So, naturally,if they have some level of intelligence, they’ll come to the conclusion that,“Hey,that might be dangerous and not a good idea.” You have the freedom to do it.That’s the philosophy of C++.C++ assumes that you’re correct until you prove that you’re cooked,while other languages prove you know,assume that you’re cooked until you prove that you’re correct, right?So, yes,you can overload it.You probably shouldn’t, but if you decide to,C++ has still provided you with a utility, to get what you may have thought you needed to begin with,which is the actual address of that object.
member initialization list ordering is confusing waaaaaaa
Two,C++ has a unique way of assigning constructor arguments to member variables.In contrast to Java,where this assignment happens in the body of the constructor,C++, uses member initializer, lists that appear between the constructor’s parameter list and body.But there’s a weird caveat.Members aren’t initialized, in the order which they appear in the member initializer list.They’re initialized in the order which they’re declared in the class definition.If you initialize the variables in the wrong order, and some variables depend on other variables,you may end up using an uninitialized variable,and that can lead to undefined behavior, which you definitely want to avoid.Three.Okay.Two points about that.The first is if you have warnings enabled, you’ll be notified.The second is if you’re starting a new project,you probably want to have treat warnings as errors, but regardless,as long as you have treat warnings as errors on,the compiler will halt you in, your tracks and it will tell.
you that the order of your member, initialization, list is inconsistent, with the order of the member variables as declared in the class.So, this isn’t as big of an issue as you’re making it out to seem.What I do think is a bigger issue is the contradiction, between LIFO and FIFO destruction order in other languages like Rust.So, let’s take a look.We have this problem here, that was tried almost a thousand times, and the success rate is as good of a is as good as a guess,right?An only 25% success rate.So, we have this struct with two objects,both strings, A and B.And the question is very simple.What’s destroyed first, A or B?Is it a random order?Are they simultaneously destroyed?Reverse order?They’re actually not destroyed in reverse order like you would expect,for example, in stack unwinding.They are destroyed in declaration order,which is extremely unintuitive to new developers, and even to me as a seasoned C++ developer.What’s even more confusing is, well,
C++ restricts something that I think it should restrict that Rust allows.So,C++ has a concept of shadowing where a variable defined in a nested scope, can shadow that declared in a global scope or a outer scope.But in Rust,you can declare the same variable as many times as you want in the same scope.And to me, that’s unintuitive and that’s really confusing,especially to a newbie.And this isn’t only my personal experience and my opinion because, around a thousand people have tried this problem,and a good 70% of them have no idea what the answer is.
static initialization order fiasco doesn’t have a solution ?!?
Four,there’s no real way to know what order static variables, are initialized across different CP files.So,if you have one static object, that depends on another one in, a different translation unit,there’s no guarantee that they’ll be initialized in the correct order.This is a notorious issue called the static initialization order fiasco,and it can lead to subtle non-deterministic, bugs that are difficult to detect and even harder to diagnose.Okay,that’s a miss, because C++ 20 fixes that and addresses that issue specifically, with a keyword called constinit.And also, pre-C++ 20,you can also still address that issue.It’s not of as elegant as a solution, but instead of having X depend on Y,you can have X depend on a method, that has a static local Y and just initializes it in its method call, the first time it passes through that method and returns Y.It’s honestly flabbergasting.
HoW dO I TeSt pRiVaTe mEtHoDS?!
to see all the different hacks that developers, use to test private member functions.There’s simply no consensus, on how to do this or whether you should even do it at all.In programming languages that have reflection like Java,you have the flexibility, to reach into the guts of an object if you really need to.But, in C++,I’ve seen people use preprocessor macros to turn the keyword pri-, Okay, this is just ridiculous because this is undefined behavior.So, all bets are off in that case.If you do this, you probably shouldn’t be writing C++.Also, using reflection to grab the internals of the object just to test it,in my opinion, is bad design and not the solution.Um this is actually addressed in detail in Effective C++ item 23.There’s a very compelling argument made by Scott Meyers to prefer non-member, non-friend functions, to member functions, that might be private in a class that would test some sort of, private member variable that is currently gone untested.So, there’s definitely solutions to this.
I don’t understand why he’s claiming there aren’t,and they’ve been discussed in length online and in books.C++ Software Design, right?It does It has an entire section on just this issue.So,to pretend that this is a uniquely C++, issue that hasn’t been addressed anywhere,to me is a bit bogus.And perhaps the biggest issue with its performance.
compiler devs do all the work ??
is how heavily it relies on compiler optimizations.C++, is a poorly designed language that leads heavily on compilers, to compensate for its shortcomings.To say that compilers optimize C++ is an understatement.Compilers literally rescue C++ from its poor design.The most basic example of this is copy elision.This is a compiler optimization to eliminate redundant copying of objects.The reas-, It’s so ironic that he brings up copy elision while mentioning that compiler, devs are saving, the C++, standard for from itself, because compiler devs and those working on the standard,they work hand in hand to improve the language.The same people that are working on the compiler, are often times writing papers for the standard.So, there’s a lot of crossover.There’s a symbiotic relationship between both parties.And he actually gave you a great example, copy elision.Compiler devs implemented uh RVO, return value optimization,pre-C++ 17.And I mentioned pre-C++ 17 cuz in C++ 17 it became part of the standard, right?
So, as you can see,compiler devs are learning how to make things really cool and fast,and they’re teaching it to the people that write the standard,and in many times they are the people that write the standard, right?So,the language is evolving, and being modified to allow compilers to optimize better,and the compilers are being used to formalize concepts into the language itself,to formalize those optimization techniques, and embed them in the language.So,to say that C++ the C++, standard or C++, is some lazy language and compiler, devs are doing all the work is to not understand, that they work hand in hand.Web development can pay pretty well, too,
you’re locked into one field with C++?!
and there are more job opportunities than web dev.It’s also easier to hop from one job to another.In contrast, if you have a computer vision role in C++,you can’t just switch to a completely different domain like high-frequency, trading.So, you sort of get pigeonholed into a particular specialized field.I think that’s overblown.Um yeah, sure,web devs have more companies to work at,but they’re also the ones being targeted by AI and automation the most.So, it’s not just a which one is more versatile,it’s which one has more longevity as well as being versatile.And as somebody who’s worked in quantitative trading,there is really no bias or concern about candidates, that come from other fields that write C++.That’s an overblown fear.As long as they are strong C++ developers,people don’t care where they learn their C++.So, let’s talk about who should learn C++.
should you learn C++ as a newb?!
First of all, I would absolutely never recommend it as a first language.It’s way too inhospitable and unforgiving to beginners and experts alike,but especially to beginners.If you have Okay, uh that’s a hard disagree for me,and I guess, you can expect that as a C++ developer who learned C++ as his first language.What’s great about C++, is that it teaches you how the software interacts with the hardware.How the code that you write changes, the actual internals of your computer, right?It teaches you about concepts that aren’t just related to, how do I center a div or how do I write this for loop in Python.It’ll introduce you to important concepts like computer architecture,operating systems, uh concurrency,right?These are all concepts that are going to be critical for you to learn early on, if you’re interested in any role that’s related to performance.I get it.If you’re just interested in front-end web design,those concepts are not important for you,
and you probably shouldn’t learn C++ as your first language,but even just doing a basic foray into learncpp.com, or watching a couple of tutorials,I think will really help you gain an appreciation, for computer science, and, all the work that other languages like Python do to abstract, a lot of the complexity, away from you.Now, when this video drops and I end up watching his video a fourth time,I’ll probably end up kicking myself in the butt thinking to myself,“Oh I missed talking about that point.” Or, “Oh,I really should have brought, that up in this bullet point, that I mentioned.” But,for now, these are really my biggest qualms that I have with this video.I think, overall,I respect the amount of time and attention he put into this video.You need to have some degree of proficiency, to understand things that he brought up,and some things that he didn’t even bring up like the most vexing parts,which I saw in some of the AI, you know,pictures the that he had on the screen.
Thank you for watching this video, guys.If you are interested in learning the nuances of C++,
how to become a cracked c++ dev
you still want to become a C++ developer after watching this video,then consider joining get correct.io.It’s free.There are hundreds of free problems.Some of them are problems that have come up in interviews.Others are problems to help you skill up.There’s an entire coding section, on there to help you understand, how to write proficient, C++ code that isn’t leet code,that isn’t contrived toy puzzles.And if you want to support the channel, consider becoming a patron.You also gain Discord access with that.