Тёмный

How C++ took a turn for the worse 

Code Persist
Подписаться 10 тыс.
Просмотров 282 тыс.
50% 1

C++ is a great language to know; however, as time goes on more features are added to the language. These extra features make it far weirder than it used to be. If you liked the video subscribe and hit that like button!
0:35 auto
1:32 STL
2:33 Package Manager
3:22 Error Messages
4:18 Backward Compatability
#programming #coding #software #computerscience

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1 тыс.   
@NithinJune
@NithinJune Год назад
which code report video was being referenced in the video? edit: I found it ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-wGCWlI4A5z4.html
@189Blake
@189Blake Год назад
Yeah, I went to look for it as well, as I remember quite well that comment 😅
@jongeduard
@jongeduard 8 месяцев назад
I have watched that video too. But seriously, code report is really a special one. I mean, actually it is a very great channel that I like to watch, but please understand that he super opinionated an is quite strictly focused on totally functional programming code only and sometimes even on languages that are actually impossible to type with a normal keyboard. 😒 I think C++ is really just not a suitable language for that kind of thing. C++ is very imperative and object oriented. The more abstractions you add to the language, the bigger the safety problems become with memory and things. Rust can actually do it, because it's designed as a functional language from the ground up and because it has a really powerful borrow checker. I think the mission of C++ ends there. It's done. Actually I now believe that C is safer than C++ because it's so simple, so that serious bugs don't get deeply hidden with all the tons of abstractions. There is a reason why kernels like those of Unix and Linux are not written in C++ but C.
@NithinJune
@NithinJune 8 месяцев назад
thanks for the pin
@NithinJune
@NithinJune 6 месяцев назад
huh. i forgot i left this comment and i can’t down here for the same question 😂
@USGrant21st
@USGrant21st 5 месяцев назад
Don't name your functions "someRandomFunction" -- it's not a c++ problem, it's an illiterate programmer problem. There is no substitute to being a competent programmer, no matter which language you chose.
@creapermann6356
@creapermann6356 Год назад
How did your initial statement "How C++ took a turn for the worse" end up in "Its still considerably better than the older versions"?
@codepersist
@codepersist Год назад
You are completely right. Its more about the code practices behind the new features rather than the new features. While the features can be overwhelming I tried to focus the video on more about how they can be weird. It's my first video so I'll try to explain the end result better in the next one!
@henriquemuccilloschumacher542
Well some new options are kind of harder to understand depending on how and where you use them, but in some places they could be better and make you write way less code, there's also some really usefull stuff from newer C++ versions like u8 literal strings and co-routines, templates are also useful if you don't want to write a version of the same thing for each type of variable, or make an macro that declares your entire function/class/struct with a different type in a #define statement (which would be the pure C alternative to templates) i mostly appreciate they are there, because you can always opt to not use them if they make your code too complex i'm more familiar with C than C++ so i mostly write "C with classes" stuff, but in some cases , templates and some C++ stuff really make my life easier and i mostly use them when they are needed But yeah sometimes C++ high level funcionalities scares me, i remember writing one line of code using some "New C++ funcionality" and my executable just got +4kb, while writing a ton of code would get me like +2kb, so a lot of stuff was being done but i didn't know exactly what
@Linuxdirk
@Linuxdirk Год назад
You just fell for a clickbait title. 😁
@r.t.5767
@r.t.5767 Год назад
He was afraid to offend some C++ programmers I guess
@hago3779
@hago3779 Год назад
Yep, just a clickbait title. Moving on boys.
@zahash1045
@zahash1045 Год назад
Wow a python developer complaining about the auto keyword.
@Phantom-lr6cs
@Phantom-lr6cs 5 месяцев назад
strange cuz in python everything is an auto by default : D a = "qweqe" b = 15 c = 1.3 def ak(): return "1111" def a3k() -> str: return "2222" print(ak()) print(a3k()) all are autos : D
@mrfli24
@mrfli24 5 месяцев назад
@@Phantom-lr6cs there isn't such an auto coz there isn't any type there.
@artoriapd
@artoriapd 4 месяца назад
​@@mrfli24 you can actually set type to variable, e.g. myAge: int = 10 Though I don't know if it's actually usable, I also can't verify it since I know it because a friend of mine tell me about it.
@skystr1ke
@skystr1ke 4 месяца назад
@@artoriapd Python does let you add type annotations but the interpreter doesn't enforce them. The main use for them is better autocompletion (at least from my experience)
@陸
@陸 3 месяца назад
​@@mrfli24there is, just not explicitly typed
@coderflowerdev
@coderflowerdev 10 месяцев назад
You lost me at "Python programmer"
@gn6691
@gn6691 3 месяца назад
😂
@salmonsushi47
@salmonsushi47 3 месяца назад
lmfao
@MorningNapalm
@MorningNapalm 2 месяца назад
I don't think "programmer" is what you call a person who uses Python, but meh.
@NineSins
@NineSins Месяц назад
Bro complaining about auto being not clear enough, when in python variable can become literally anything
@MorningNapalm
@MorningNapalm Месяц назад
@@NineSins lol!
@sergeykolesnik1171
@sergeykolesnik1171 8 месяцев назад
you: "it gives zero information where the program crashes" also you: *shows the full stack trace one line below* :SHM:
@vladimirarnost8020
@vladimirarnost8020 2 месяца назад
Technically, the call stack wasn't produced by C++ as a language but by GDB (the debugger). ANY program causing a SEGFAULT on *nix systems just prints a single line error message, preferably producing a core dump for a post-mortem analysis, regardless of the programming language used to produce the executable (C, C++, Fortran, Cobol, Python (itself a C++ program), Java VM, some database, web browser, etc.). Some programs handle such fatal errors more gracefully by printing additional debugging information like the aforementioned call stack. It's not hard to do so in C or C++.
@sergeykolesnik1171
@sergeykolesnik1171 2 месяца назад
@@vladimirarnost8020 yep, this is why you need to have a symbols file when you build in release. In debug all the symbols are embedded by default, which allows to provide a meaningful callstack error.
@zeta0590
@zeta0590 2 месяца назад
​@@vladimirarnost8020I would say python does on its own but it does it in the most obtuse way possible by dumping the ENTIRE stack BEFORE the error. I have seen my fellow college students be very puzzled by some very benign errors in hindsight.
@Georgggg
@Georgggg Месяц назад
full stack of stl+boost internals. Not helpful.
@sergeykolesnik1171
@sergeykolesnik1171 Месяц назад
@@Georgggg it is helpful after a couple of years of grinding. But never use boost and the problem is reduced almost in half. Boost is a crime against humanity. So is the C++ standard
@SuperMixedd
@SuperMixedd 10 месяцев назад
> as a primarily python developer opinion invalidated
@tusharsrivastava3523
@tusharsrivastava3523 Год назад
As someone who first learned C++ then python, I still prefer C++.
@oooooooooOoOoOo571
@oooooooooOoOoOo571 Год назад
me too! more control easy to see what is what and where is where!
@gtd9536
@gtd9536 Год назад
I did C then C++, then Python. If I rank the years using each with the highest first: C++, C, Python. But, I prefer python, then C, and lastly C++.
@tabletuser123
@tabletuser123 Год назад
This is simply because you’d rather stick with what you learned first rather than venture into new territory that makes you uncomfortable
@gtd9536
@gtd9536 Год назад
@@tabletuser123 I don't think you can come to that conclusion, alot of preference can also depend on what he does. If his experience is closer to the "metal", like embedded systems, linux drivers, etc, then that would strongly influence his preference for C/C++. I know I prefer C the lower on the stack that I go. Also, I use to write database internal engines, in particular, I use to work with parsers and compilers. And there, C++ is often preferred, but I like C. And if your experience is mostly in the areas where C/C++ and other compiled languages shine, then that can influence your opinions. But, given all that, and I've done alot of stuff in my career python is still my favorite language.... so far. (I'm going to check out python codon, looks pretty cool.) Anyways, sorry for the long reply. See you in the 'net.
@tusharsrivastava3523
@tusharsrivastava3523 Год назад
@@tabletuser123 Nope, Python is not 10% as complex as C++.
@greg77389
@greg77389 6 месяцев назад
_Python coder attempts to understand C++ challenge_ (Impossible)
@gustavobauer6543
@gustavobauer6543 Год назад
The biggest problem about segfault is that it isnt a runtime error thrown by the language, it is an OS error, so you kind of can't have good error messages. In most programming languages code that could throw a segfault either throw a runtime error or doesnt even compile
@norude
@norude Год назад
You could make a compiler flag that would include a runtime and source files in result file for the purpose of listening for a segfault, deducing where it came from, showing it and maybe providing some tips on the pattern surrounding it
@sourestcake
@sourestcake Год назад
@@norude This already exists. It's called AddressSanitizer. You can enable it in GCC and Clang with -fsanitize=address. There's also UBSanitizer: -fsanitize=undefined.
@cristiandecu
@cristiandecu 9 месяцев назад
@@norude That's what debuggers are used for and that's why you should never downplay their importance in software development. When you're dealing with a language that offers you direct access over the memory things can always go south.
@pierreollivier1
@pierreollivier1 9 месяцев назад
@@cristiandecuDebuggers are great in theory, in practice they are often quite clunky especially gdb.
@skeleton_craftGaming
@skeleton_craftGaming 9 месяцев назад
If you are using modern C++, a good 90% of what you do that would cause a segfault in theory throws a runtime error unless you have exceptions turned off
@tenthlegionstudios1343
@tenthlegionstudios1343 Год назад
Big problem for me with the one liners in C++ is they aren't as clean as they are in other languages. If someone is a functional programmer and comes into C++ looking to use similar patterns, it easily gets out of control. And each version of C++ seems to have a new syntax or name. John Carmack, creator of doom and someone who has many years of C++ experience, thinks C++ is one of the hardest languages to understand when entering a new code base. This is because each code base can be vastly different. He says these problems don't exist for him in other languages, or at least not to the same extent. For me, there is just too much unnecessary complexity in most c++ code bases.
@brdrnda3805
@brdrnda3805 Год назад
The funny thing is, that the comment above yours states it as an advantage that "It gives you ton of freedom on how you want to structure your code and allows you to use any coding paradigm you wish to use."
@tenthlegionstudios1343
@tenthlegionstudios1343 Год назад
​@@brdrnda3805 Very interesting. I think both can be true. Languages like GO that are GC'd and fairly simple put guardrails on developers. This can do wonders in large companies for improving readability and consistency. C++ on the other hand has very few guardrails. So at large companies I could see this being a downside. But great devs love the power within C++. However, I still think a more consistent API for standard library FP like primitive functions would have helped for this one liner issue. It is hard to fault C++ though, being a language with few guardrails that has been popular for so long.
@monad_tcp
@monad_tcp Год назад
@@brdrnda3805 "freedom to express whatever" is not good. If we have learned anything in computing is that everything is allowed, its code and by the end, the machine doesn't care. So we put restrictions on things, restrictions are useful to us human, to make sense of the complexity, to control it. But you can't sell that to C++ "people", they want freedom to do whatever, no matter what. The history of computing science is full of examples on restricting forms of computer code, because by the end of the day not all valid programs are useful and correct, so its a small price to pay when a compiler/language/method-restriction blocks some valid programs to be expressed. Examples such as : Assembly programming. Self modifying code. GOTO considered harmful. non Structured control flow (its either structured control flow, or data flow, you can't have "strange machines"). Global variables. State in of itself, specially mutable state.
@anon-fz2bo
@anon-fz2bo Год назад
yeap
@modernkennnern
@modernkennnern Год назад
Compare LINQ in C# - which is a somewhat similar language to C++ - to the iota/range view thing mentioned in this video. They're both "tacked on", but one is much easier to use that the other.. and it's not iota
@lombeelo8780
@lombeelo8780 Год назад
3:33 there is an address sanitizer, which is specifically designed to do runtime checks and detailed error messages (still cryptic, but much better) for segfaults. 4:19 c++ is not fully compatible with c language, c++ is fully compatible with it's library only. 4:33 "new" is a wrapper for malloc() to make you able to use custom allocators, other than malloc() more easily; smart pointers are wrappers for "new", to make you think less about deallocations (calling delete/free() or writing destructors). Overall, the whole reason why c++ is awkward (that is what i think of it) is the ABI situation: the whole standard library MUST be backwards-compatible with it's previous versions on ABI level. Maybe it will change somewhere in 6-9 years.
@siniarskimar
@siniarskimar Год назад
Like a year ago there was a push to break ABI, which unfortunately was voted against by the C++ standards committee. (And then the Carbon situation happened)
@lombeelo8780
@lombeelo8780 Год назад
@@siniarskimar Heard about it. That's where my estimations came from.
@gamerk316
@gamerk316 Год назад
@@siniarskimar Given how long-supported some codebases are, outright breaking the API is unlikely. What's more likely to happen is certain features/keywords get depreciated, and eventually generate a warning/error if used unless the compiler is explicitly told to support those features (ideally with an error telling you what to use instead).
@GGGBC
@GGGBC Год назад
@@siniarskimar C++ standard does not have ABI compatibly (but C does as far as I know). Maybe you were referring to API break?
@GGGBC
@GGGBC Год назад
I do not think new is a wrapper over malloc. I would recommend searching for free store vs heap memory on this subject. It's not mandatory for these memory zones to be overlapping.
@Webfra14
@Webfra14 Год назад
Sometimes (when nobody is watching me) I open a text editor and start writing C++ code as if it was the '90s again. I was stupid, C++ was great and nobody around to tell me I'm doing it wrong...
@mintchocolamint
@mintchocolamint Год назад
Hm... With a scalding title like "How C++ took a turn for the worse", I had expected stronger arguments. 1. "auto" isn't exactly a C++-specific problem. C# and Java both have the "var" keyword, which does the exact same thing (automatic type deduction). And in general, people have come to understand that there are places where you probably shouldn't use automatic type deduction - places where explicitly stating the type is a form of self-documenting code and reduces ambiguity. Even in Python, you can decide where you'd want to annotate a variable's type to help with readability. 2. STL is pretty verbose, I can agree with that. It uses terminologies that you don't really see often in other languages (like the iota function over there). However, it feels like your criticism of STL is a bit more focused on functional programming instead (one-liners that become unreadable a few weeks after you wrote them). Not saying STL is great, though. It has a lot of other usability issues compared to other languages' generic containers (e.g., C#'s System.Collections.Generic), though most of them can be attributed to C++ templates being hard to work with in general. 3. No "standard" package manager is kind of a problem, I can agree with you on that. But then again, in JavaScript-land, there isn't a standard package manager (it's npm vs yarn vs pnpm right now), and they're fine with it. Maybe it's not that bad of an issue, after all. 4. C++ *runtime* errors (e.g., segfaults) don't have pretty error messages because C++ is designed for performance - your program doesn't ship with a system that monitors runtime memory access for you, which would sacrifice performance. If you want runtime error messages, you should be attaching a debugger when you compile your program. Of course, one could argue that Rust is still better here because it enforces more compile-time rules to protect you from compiling a program where you can segfault, and they'd be right, but do keep in mind that if a Rust program manages to access an illegal memory address, it would also simply segfault (assuming no debugger). 5. C++ having multiple ways of doing the same thing is very much an issue, but I think memory allocation isn't exactly the best example here. The three ways you listed here all have very different purposes. - "malloc" doesn't exist purely to let you create an int on the heap, it's also a precise way to request memory from the operating system, and can be used to acquire a large, *continuous* memory pool for you to use (afaik more sophisticated game engines use a similar approach). - "new" (and "delete") implements RAII (constructor on new, destructor on delete). It exists because C++ *classes* can specify code to be run on initialization (constructor) and on deallocation (destructor). A similar (but not the same) pattern can be found in C#'s IDisposable interface, which lets classes implement a "Dispose" method that can be executed automatically once they exit a "using" block, often used for file handles. "new" can also be overridden to allocate memory from a custom memory allocator (as opposed to just using malloc), such as from a memory pool managed by your own program. (Game engines are again a good use case here) - Smart pointers exist as a **wrapper** to automatically call "delete" for you even when working with heap-allocated memory, according to a set of rules. They exist so that you can work with objects with dynamic lifetime *without* having to run a garbage collector to deal with memory leak. Garbage collectors can interrupt your program's execution every now and then to track down unused memory for you, which can be undesirable in performance-critical applications. You'll find the same flavors of smart pointers in Rust as well (but with different names). This is the kind of stuff you're expected to learn in a low-level programming language. For the record, Rust did away with new-delete and only kept the smart pointers and malloc (std::alloc, std::dealloc), basically requiring all heap-allocated objects to be protected by smart pointers to make it harder to accidentally cause a memory leak. But even then, I'm pretty sure you'd be making a lot of enemies in the competitive programming scene if you were to take the raw "new" and "delete" keywords out of C++, and force them to use smart pointers. I can understand that these aren't really familiar concepts to someone who is primarily a Python programmer. C++ is also indeed a weird language compared to other modern programming languages, with a lot of concepts that aren't seen often elsewhere. But if we are to contribute to the discussion of making C++ a better language, I think we should try to discern which parts of C++ are C++'s own problems, and which parts of it are issues in larger fields (low-level programming, functional programming, etc.)
@codepersist
@codepersist Год назад
I probably should have added more info in the video. I have been coding with c++ for a couple of years now and use most of the features that I mentioned. I think using auto incorrectly can create really messy code so the problem is not so much with auto, but the poor coding practices related to it. The STL while verbose is still extremely powerful, and I am glad they keep adding new features. Your explanation on segfaults makes sense. Personally, I haven't found any way to debug them even with programs like Valgrind, so that's why I guess I am more biased in saying they have poor error messages. You brought up some great other points! How long have you been working with low-level development as you seem to know a lot?
@mintchocolamint
@mintchocolamint Год назад
​@@codepersist Regarding C++ debugging: Common debuggers like the gdb and Visual Studio's debugger can show stacktraces from a segfault (and of course the exact line where it happened). As for my personal experience, I'm just a senior CS major, who's used C++ on applications such as a Qt-based GUI, OpenGL-based graphics programming, and lately Unreal Engine, among other things. I do more game dev stuff usually (C#), but I still keep an eye on low-level development because it helps with understanding performance a lot.
@chris52000
@chris52000 Год назад
@@codepersist If you compile with gcc, use “-fsanitize=address”. This checks memory accesses to ensure they are in allocated memory, which deals with most segmentation faults. There might be options for other compiler too, I just mostly use gcc. You can also try “-fsanitize=undefined” too
@dscmtr686
@dscmtr686 Год назад
wow, very informative answer!
@az-kalaak6215
@az-kalaak6215 Год назад
@@codepersist Hi, to debug segfaults you have 3 linux- programs: gdb (use the bt command to have a stacktrace after a segfault) valgrind (every single valgrind error can and will on some systems lead to a segfault) and a gnu program called (if I remember correctly) catchsegv, which prints a stacktrace in case of a segfault. remember that valgrind is not a tool, but a tool collection, you have memcheck (default memory checker) helgrind (basic thread checker) drd (advanced thread checker) massif (heap and stack profiler) callgrind / cachegrind (call profilers) standard library is the hardest part of cpp to learn, as is is extremely wide, and have specialized stuff used only in a few parts.
@MadpolygonDEV
@MadpolygonDEV Год назад
I think people who are really accustomed to python maybe have a hard time seeing beyond the abstraction python comes with. It seems difficult for some to grasp some things when python does alot of heavy lifting. Thats why I personally don’t recommend starting with python. I started with python in the past and it doesnt have any types and alot is very simple. This is definitely one of the strengths but also a weakness. As a new programmer or someone who never or barely used a c language, one may be quite overwhelmed how little hand holding and abstraction there is.
@codepersist
@codepersist Год назад
I should have mentioned I've used C++ for quite a few years and use basically all the things I mentioned in the video, but I just think many of the features allow developers to make bad programming choices. Both languages have their purposes. Obviously I wouldn't make an OS or something of that sort in python but would rather use C
@MadpolygonDEV
@MadpolygonDEV Год назад
@@codepersist I understand, I think C++ has its strength but also weaknesses. Like you mentioned debugging can be a nightmare
@RenderingUser
@RenderingUser Год назад
Actually, I still believe python is the best beginner language It's definitely better to go into python first and then c++ than to just jump into c++ right away. That way, the difficulty curve for learning c++ is gonna be a lot less. You'd already be aware of the basic concepts of programing before you touch c++ and that lightens your load a bit. I mean, if you're learning c++ anyway, you'd still be learning things beyond abstractions regardless of whether you learn python first or not But these days I'd probably recommend rust instead of c++ tho :P
@Bliss467
@Bliss467 Год назад
Honestly I think the best starter language is Lua. It’s incredibly bare bones but abstracts away confusing stuff like pointers and memory management.
@RenderingUser
@RenderingUser Год назад
@@Bliss467 lua is pretty cool As far as I'm aware, it's faster than python But python still has the largest collection of libraries
@MadpolygonDEV
@MadpolygonDEV Год назад
One more thing I want to say, while there is a std library and every company has its own convention, the beauty about C and C++ is, it doesnt force you to write code in a specific way. It gives you ton of freedom on how you want to structure your code and allows you to use any coding paradigm you wish to use. Do you want to structure part of the program procedurally and mix it with object oriented design? Go for it, the language allows you to be creative. You can use abstract nested code, but you dont. I think people have a misconception that c++ forces you to write code like in 1:56 but if you think its too unreadable, then you re free to write code however you like if you stay within the syntax of course :D
@what42pizza
@what42pizza Год назад
Don't most languages let you program in any way you want? I know that languages like Java force you to use OOP, but I've heard that even C# lets you mix OOP, procedural, functional, etc. So does C++ have some sort of reason why it's more free? I don't really see any difference
@ky3ow
@ky3ow Год назад
i don't think 1:56 is unreadable, iota is very strange name for range but if you know a bit about fp then this is very readable function just ignore [](){} lambda, its so ugly
@blablablablablup1
@blablablablablup1 Год назад
Although I have to say: as a beginner in cpp it's really confusing that there's so many ways of programming the same thing. Especially with memory management. There's raw pointers with malloc, new/delete and smart pointer/RAII wrapper. It's like really hard to find out what the best code practice is, when there's just too many ways to do the same thing. And when it gets to template programming or even compile time polymorphy the syntax is beginnig to get really confusing. Never quite understood when I have to describe whether i'm talking about a type or not.
@ClaymorePT
@ClaymorePT Год назад
@@blablablablablup1 That's because the language is old and has a ton of legacy code behind it. It's not a hype language created in the last ten years without legacy. It's just not possible to remove features from the language without causing havoc. If you want to follow best practices in modern C++, just check out some Modern C++ books and follow the practices for C++20.
@myname2462
@myname2462 Год назад
​@@what42pizza Yes. You can also use in C# Pointer stuff if you want to for whatever reasons.
@minneelyyyy
@minneelyyyy Год назад
Correction: auto did exist in C, however it didn't do the same thing it does in C++. It was used to define a type with automatic storage duration, it did not automatically deduce the type of a variable.
@LunaticEdit
@LunaticEdit 9 месяцев назад
The linker error you showed makes perfect sense. One of your modules (.obj/o) is requiring the function test_fn from some other object file, but that object file wasn't included in the link phase. The entire point of a link phase is to LINK the obj files together. Also that segfault shows you _exactly_ what went wrong... I feel like you are expecting C++ to be a junior developer friendly language. It is not. And those standard library things that you find "confusing"? Yeah those can end up making your apps way less error prone, and way more optimized than whatever hand crafted shenanigans you crafted in the 5 minutes you thought about that logic.
@QuickNETTech
@QuickNETTech 2 месяца назад
Linker errors are often some of the most painful, I can read and understand that it can't find X, Y or Z or that A's been defined a dozen times somehow but figuring out what caused it can be a nightmare, especially if it's a template. Most of the time, yeah I was just dumb and didn't include the thing, easy fix, but if it's not that then it's stuffed and I'm gonna hate my existence while trying to figure out how it's broken
@LunaticEdit
@LunaticEdit 2 месяца назад
@@QuickNETTech I'm not going to argue that C++'s error dumps aren't effed. They are, and it's almost always due to templates as template based errors make no sense if you don't exactly where the problem is. This is a known issue and I believe they are working to alleviate this -- and the new addition of "concepts" is also going to help a whole bunch as well!
@QuickNETTech
@QuickNETTech 2 месяца назад
@@LunaticEdit concepts are lovely yes, I love the compiler, I leverage it a lot with templates and constexpr/eval, I like programming with strongly typed generics and same goes for the powerful compile time work I can do, I can greatly assert correctness and get usually nice (for C++) error messages, and there's a runtime benefit. Compile time string literal manipulation effectively needed a macro as best as I could get it in C++ 17, C++ 20 allowed me to get rid of the macro and use a template thanks to NTTP being improved for string literals, using requires helped in places where I used static_assert previously because I refused to learn the enable_if blight lmao
@xGOKOPx
@xGOKOPx Год назад
C++ template errors are horrible because at the point in the compilation process where they happen templates are fully expanded and some of them are very long; then the way the error is worded makes the fully expanded type name be said more than once; then since the template was included in n cpp files the error likely occurs during compilation of each one of them so it gets printed n times. Yup, not a nice experience
@anon_y_mousse
@anon_y_mousse Год назад
Learn to program, then you won't have indecipherable template errors.
@negai_
@negai_ Год назад
oh, you said just in the beggining "As a python developer" and then I understood why you said that c++ is weird.
@kappaluka7532
@kappaluka7532 4 месяца назад
True hahahahahhahah
@lurgee1706
@lurgee1706 Год назад
While I wholeheartedly agree on some of points (error messages have always been notoriously horribble in c++, and package managers are not as good and standardized as in some other languages), some other points seem a bit far fetched. I don't see how auto is different from var/let/etc. If someone writes obscure indesciptive code, it's their fault. Similarly, std is simply a tool, and it's perfectly fine to write "oldschool" code with explicit iteration etc. Std just gives you a way to not reinvent the wheel when it's not necessary. For instance, in your example they solve a very simple problem, and in that case I'd probably prefer the old snippet as well. Now let's imagine something more complex and with more steps. Suddenly a dozen lines of piped code become more readable than a dozen error prone functions you need to test. Long story short, some of the tools are simply misused or are a bit of an overkill for some tasks, but it doesn't make them inherently bad.
@usrnewxnew5227
@usrnewxnew5227 10 месяцев назад
Honestly the error messages are always gonna be bad. Its an OS level error, at that level the os has no additional information available other than "is the program reading/writing anywhere else other than the areas I allowed it?"
@spacelem
@spacelem Год назад
Weirdly, I saw that same Code_Report video as a random suggestion, and it really sparked my interest in C++ again. The syntax is horrible, sure, but it's not spaghetti code (unlike the code in the video Connor was responding to), it's just FP, and I code like that in other languages all the time. Also C++20 gives you three different ways of allocating memory, but you're really only supposed to use the latest way, the older ones are just there so old code doesn't break.
@victotronics
@victotronics Год назад
There are three ways of allocating memory, but thanks to RAII and stl containers you almost never need to. While C has "pointers" (really: addresses) all over, you really don't need pointers of any type much in C++. Parameter passing? pointer -> reference. Array allocation? pointer -> no-such-thing-the-data-is-internal. String allocation? Pointer -> again no such thing. Graphs? Ok, there you can use smart pointers.
@Rosen2221
@Rosen2221 Год назад
Its wrong that you don't need raw pointers any more - take for example some model object to display data in a javascript gui. I want to create that object in c++ to connect it to backend, but I dont want that object to be owned by the c++ backend (not shared or unique_ptr) - I want it to be owned by js and garbage collected, when the gui is done with it (e.g. some data in a dialog). So raw and shared_ptr are not the same and you dont only need to use the latest. This is not npm
@victotronics
@victotronics Год назад
@@Rosen2221 Yes, well, if you need to interface between two languages. Besides I was not making a categorical statement. I was arguing that most of the C-like uses of raw pointers had gone away.
@VintageToiletsRock
@VintageToiletsRock 5 месяцев назад
I'm taking malloc to the grave!
@yjk_ch
@yjk_ch Год назад
1:18 `auto` is not really an issue. Auto parameters are not that common(TypeScript has similar feature), but other modern languages are doing something like `auto x = y`: Go: x := y Rust: let x = y Kotlin: var x = y And not only hovering on the variable on modern editors/IDEs show its type, but in these days it is also shown via inlay hints, so that you don't even have to hover on the variable name. 3:01 This is only really problem limited to Windows. In Linux, you can just use system package manager.
@roarc0
@roarc0 8 месяцев назад
yes but then you specifically need ubuntu 22.04 or a docker to build that particular library version, or cmake doesn't work for another distro etc.. with go or rust you have much nicer control over the version of library you use.
@marianaavalosarce5393
@marianaavalosarce5393 Год назад
I find c++ very logical and makes you invest time in having the data types controlled, which makes you not lose the hang of your code that soon. In big real-world problems, code needs to be fast and portable, and c++ with cmake does it. It requires practice and abstraction, but at the end of the day software is here to solve people's problems in the fastest way possible.
@vende4408
@vende4408 Год назад
in big real-world problems what matters isn't speed of code execution, but speed of writing this code
@vlad071096
@vlad071096 Год назад
​@@vende4408 only in the world where all the programs that must be efficient have already been written
@kartonrad
@kartonrad Год назад
tbh, you get the same in rust, except you don't die before you understand a new codebase though tbh i can adjust to c++, but its just so annoying to read it
@christianasch9176
@christianasch9176 Год назад
@@vende4408 lmao no if you're making anything related to HPC
@coorbin
@coorbin Год назад
My “favorite” pet peeve in C++ codebases is how each library/ecosystem/codebase has their own custom type system for numbers, pointers and strings. These are usually ancient typedefs that can never change because people rely on example code from 1996 to still work using these libraries/environments. A great / horrible example is the Windows API. Why does Windows have a custom string type all of its own? Why is it so special that it can’t just use a normal std::string or std::wstring? Why? Oh, because of legacy reasons, of course. And even more recent libraries that care less about backwards compat still have their own type system, like QT’s QString, because they can’t rely on the availability and consistent functionality of the std types. Sometimes just translating between the type systems of different libraries can be a task on its own!
@mightymalakai
@mightymalakai Год назад
maintaining backwards compatibility is a very important piece of software. Especially for something like an operating system (Windows).
@maksymiliank5135
@maksymiliank5135 Год назад
I thought that windows 32 api is just written to work both with c and c++ (though i might be wrong), so you can't really use the standard c++ features like namespaces and so on. An the string type is just an alias to a char pointer
@torphedo6286
@torphedo6286 Год назад
Yeah, and I hate how they still use "DWORD" for 32-bit integers even when a double word is no longer 32-bit on modern CPUs. Why can't they just replace it with "uint32_t" or "u32"? It wouldn't actually change any code functionality because it just changes the type alias.
@oginer
@oginer Год назад
Windows API is C, not C++, so of course it doesn't use C++ library. And about QtString: I really miss it when I'm not working with Qt. stl's string is so barebones. It doesn't even support unicode. Trying to work with unicode text using only standard c++ is a nightmare. QtString handles it all for you, and has many useful methods std::string doesn't.
@gamerk316
@gamerk316 Год назад
Not wrong. My company supports a *lot* of long lived projects that span across multiple HW platforms. We recognized very early on the problem of C/C++ types not being a fixed size (this was in the days before stdint.h), so we developed a company wide company_globals.h that we included in basically *everything* that gave us these fixed length types (plus more). We have stdint.h now, and even though there is little to no risk transitioning over, no one wants to risk a problem developing, given how ancient the codebases we support are.
@monad_tcp
@monad_tcp Год назад
1:56 That's a turn for the BETTER, because its functional programming, well, if you are like me, mathematically inclined
@blablabla7796
@blablabla7796 Год назад
You’re right about how it gets hard to figure out the type of something if you use auto to define it. Unfortunately, the problem is already solved by every modern IDE and every syntax highlighter extension for things that aren’t IDEs. I use Vim and it tells me every deduced auto type as soon as I open the file. Sure, some languages do it better as you don’t even have to type auto. And the modern “variable_name: optional_type” syntax is more uniform, but unfortunately, C++ has the baggage of being somewhat conformant to C. But besides that, I don’t see any real problem with the auto system.
@skeleton_craftGaming
@skeleton_craftGaming 9 месяцев назад
There's no way to allowed generic programming while still guaranteeing time safety..
@blablabla7796
@blablabla7796 9 месяцев назад
@@skeleton_craftGaming explain?
@yrds96
@yrds96 Год назад
There are some points that I disagree about complexity of STL: In languages like JS, you can increase the density of your code using map, reduce, filter, proxy, entries etc... It's basically the same with stl and . With smart pointers, I think which the addition of this feature there are LESS ways to worry about how to not leak a memory. About message errors I have to agree with you, some compilers(like gcc) has less cooler messages than llvm compiler, which sometimes give you no information about how to fix an error. But there are some tools like clang-tidy which improves the quality of your code. About the package managers you are absolute right: there are no simple solution, and the simplest I've used are not pointed in this video: Meson. With meson you can simple "meson wrap install [lib]" and then add two lines to your meson.build and you are already ready to use a newly installed library.
@khatdubell
@khatdubell Год назад
bazel, from google, is just as easy to use 3rd party c++ libraries.
@sergeykolesnik1171
@sergeykolesnik1171 8 месяцев назад
it is not STL. It is C++ Standard Library. STL is an ancient MACRO garbage from Microsoft
@SimGunther
@SimGunther Год назад
Progsbase has a blog entry on the usefulness curve vs the understandability curve. It turns out that C is in that sweet spot for enough language features while still creating understandable code whereas java and c++ are.... quickly shifting into incomprehensible territory with the number of features they're adding.
@pluieuwu
@pluieuwu 9 месяцев назад
C does give you an awfully big room to write spaghetti though... _stares angrily at literally anything that has to do with GTK, GObject or anything in GCC_ last time i had to hunt down a segfault in chromium, i had to wade through like 3-4 layers of implicit macro magic that concatenate random names to make them easier to write but nightmarishly hard to search for, until i arrived at the point where it's a crash within GTK3 with the wayland IM module enabled. had the code been any cleaner, i wouldn'tve needed to spend 3 hours debugging it 😂 C can be beautiful if written with considerable self-restraint, but that restraint is just missing in a lot of the biggest C codebases you'll walk into, because some people have completely forgotten the saying "just because you can, doesn't mean you should." just compare the impl of `isalnum` in glibc and musl, for example 😂
@skeleton_craftGaming
@skeleton_craftGaming 9 месяцев назад
The issue with C++ is not that it is a complex language [it relatively isn't] it is that people use bad practices in their code
@durrcodurr
@durrcodurr 7 месяцев назад
@@skeleton_craftGaming You're wrong -- C++ is the most complex programming language there is.
@skeleton_craftGaming
@skeleton_craftGaming 7 месяцев назад
@@durrcodurr not relative to its power... C++ can do a lot more than most languages...
@Frigionman
@Frigionman Год назад
With segfaults, while C++ doesn't tell you exactly what happened. You can and should look at the core dump. Usually it is enough to tell you what the hell happened, as it tells you useful things like: Stack state Register state Last function call Cause of sigsegv
@zackyezek3760
@zackyezek3760 Год назад
They’ve recently added stack traces to the STL, and on the big 3 (Linux, Windows, Mac) there are compiler flags that will let you capture errors like segfault as exceptions. So this is a problem that’s actively being fixed.
@cristiandecu
@cristiandecu 9 месяцев назад
Yes, but pythoneers that are trying to migrate to C++ don't really know what a core dump or even a debugger is; they just simply complain that the language lacks this and that which kind of makes you think how little these people know about C++.
@arixachannel
@arixachannel 8 месяцев назад
bro has never heard of the address sanitizer. all of these complaints are due to inexperience. that's understandable, but c++ is not remotely designed for beginners, just like C.
@juanma_cello
@juanma_cello Год назад
I never understood the hate behind C++, I just love it, high level abstraction capabilities, low level memory control just all in one. I know, it does not have a package manager, and it’s syntax starts to be a cumbersome, but when you get the point is awesome. I just find that some people is lazy to find performance issues or memory leaks 😂
@simongido565
@simongido565 Год назад
Package manager is useless, C++ programmers write everything themselves. :D. ( partially joke, partially true )
@samgould8567
@samgould8567 Год назад
@@simongido565Mostly true. It is such a pain to deal with 3rd-party deps in C++ that most shops avoid all but the most useful and popular libraries. It is a far cry from the opposite extreme of Node and NPM.
@khatdubell
@khatdubell Год назад
I don't see what exactly a package manager would solve. The overwhelming majority of open source libraries are on github, so its not a matter of being able to search for them. If its integration, bazel has this solved pretty well. A couple lines of bazel (just telling it where to find the project), and you're building and linking the external library. I say let the best technology win instead of trying to build some sort of official C++ package manager that may or may not get acceptance. And considering most people who complain about there being no package manager are also people who complain about the standard library and modern features of C++, chances are they would complain about the package manager too.
@cristiandecu
@cristiandecu 9 месяцев назад
@@khatdubell C++ is just a language and there's no such thing as a package manager in a language; python has a package manager because it is more like a framework rather than a language. What boggles my mind is the level of ignorance these people that are comparing apples with potatoes are showing. I mean just imagine have a package manager for C++ and another one for C. Your workstation would look like a gamer's PC bundled with a bunch of "launchers" from various companies.
@IAmNotASandwich453
@IAmNotASandwich453 6 месяцев назад
Honestly, the syntax is exactly why I fell in love with it. I love dealing with hieroglyphic stuff, passing lambdas as callabes to templates, doing stuff with typetraits and what not. If I see a template ending with 6 angular brackets, I just love this shit lol. Its so fun to dig deeper, trying to figure out which Part belongs where and assemble the pieces of complex definitions.
@KiranasOfRizon
@KiranasOfRizon Год назад
0:53 Reeeeeeee, why are test_v and auto_vec being declared as raw pointers? They should ideally be declared on the stack, and if that's not possible, should be declared as unique_ptr.
@IAmNotASandwich453
@IAmNotASandwich453 6 месяцев назад
Why would you use a pointer to a vector anyway? The point of a vector is literally to handle the dynamic stuff for you. Youre just throwing all the advantages anyway if you decide to allocate one manually.
@nyxa8734
@nyxa8734 Год назад
smart pointers are not the same thing as new, which is not the same thing as malloc... this is like saying "why have a spoon, fork, and spork when they all eat lasagna in the same way". they're not the same tool even though they do similar things.
@PiotrPilinko
@PiotrPilinko 4 месяца назад
In modern C++ "new" should be used only for a very few and specific cases - ideally, no "new" should be used at all.
@astrahcat1212
@astrahcat1212 10 месяцев назад
I like simple languages like C and Lua, they never change just the same ol thing.
@durrcodurr
@durrcodurr 7 месяцев назад
C has had several standards iterations over the decades. C does change, but it's fairly small changes most of the time (as opposed to C++).
@amitkriit
@amitkriit Год назад
Being a C++ dev I find Python so weird that I unlearned it. Python is beyond my tolerance level.
@MoolsDogTwoOfficial
@MoolsDogTwoOfficial 10 месяцев назад
I started with Python, did it for a few years and then decided to bite the bullet and learn C++. Ever since, I have not looked back. Python is just too limited compared to what C++ can do.
@dabbinghitlersmemes1762
@dabbinghitlersmemes1762 9 месяцев назад
@@MoolsDogTwoOfficial I started with BASIC and went back there from Python.
@username7763
@username7763 8 месяцев назад
Python has something really nice going for it; it integrates with C++ well. I've done Node native modules, Java JNI and FFIs with other languages. Nothing is perfectly easy, but Python is the closest. If you want a dynamic typed interpreted language, you could do much worse than python. I don't generally want such a thing, but there are times it is handy.
@Raspredval1337
@Raspredval1337 Год назад
you might think that auto is somewhat overrated, but you miss the main point about auto -- metaprogramming. It allows the programmer to just slap the keyword and the compiller would do the rest. Plus you can constrain the type, by using a concept in c++20
@firstname4337
@firstname4337 Год назад
LOL, no -- it still sucks
@MsKelvin99
@MsKelvin99 Год назад
I wanted to say the same thing, think of auto as another way to declare template parameters and you will be fine - because under the hood that is exactly what auto is - a template param with nicer syntax
@halfbakedproductions7887
@halfbakedproductions7887 Год назад
Auto saved my hair and my sanity more than once. Just couldn't figure out what the f--k the compiler wanted and couldn't make it shut up as it spewed errors like Mr. Creosote. Then just use auto and go back to your life. Particularly helpful with templates and other weird stuff. Most people aren't smarter than the compiler and the compilers are built by people much smarter than you could ever imagine. Trust the process.
@samgould8567
@samgould8567 Год назад
@@halfbakedproductions7887Compiler people are just obsessive and focused, not necessarily smarter. I appreciate them, but no need to lug out the pedestal.
@1InVader1
@1InVader1 Год назад
@@halfbakedproductions7887 or you could just use some helpful typedefs and that way your code becomes simultaneously readable, shorter and as long as the typedef has a good name, the code documents itself.
@роскомнадзор-д8я
@роскомнадзор-д8я 8 месяцев назад
2:35 python, rust and npm (node js) have only 1 actual reference implementation + pypy but cpp is g++ (mingw?), clang, msvc, intel c++, so it's a standard, not a reference implementation also creating new "one and only reference implementation" with package manager will only create "[soon] situation: there are 15 competing standards" moment
@grantrithor
@grantrithor Год назад
There's a lot that I can excuse c++ for due to its age but when you get a template explosion in the compiler that can just ruin your day.
@nurso56
@nurso56 Год назад
As a C++ professional I can understand some arguments from the perspective of Python (but keep in mind that Python is a script language while C++ is a strongly static typed and compiled language - hence difference language properties and requirements). But your first point is exactly the same as in Python except that the auto keyword is omitted. The naming of variables has nothing to do with a concrete language property, it is the 100% choice of the programmer. Use good names in C++ and there is no issue, use bad names in Python and there is an issue.
@cristiandecu
@cristiandecu 9 месяцев назад
My point exactly; it's like trying to pilot a plane after having 20 years of experience driving cars and then you start complaining that planes don't have wheels and that they are travelling at very high altitudes. C++ is simply not comparable with python and before migrating to C++ you also need to migrate your programming mindset. I am not really sure why a Python engineer would want to migrate to C++ (maybe a better job or something) but I doubt it's because they want to have better control over memory and lower level stuff otherwise they would simply not complain about "SEGFAULTS errors" not being explicit enough and they would start using a debugger right away.
@KurtisRader
@KurtisRader Год назад
I am a grey beard (I got my first programming job in 1979). I fell in love with C in the early 1980's and hand transpiled Donald Knuth's TeX typesetting program from Pascal to C. Nonetheless, I have never liked C++ and recent changes to the language have made me dislike it even more. C++ is now approaching Perl for its obtuseness and any given block of code to resemble RS-232 line noise.
@RoyBrush
@RoyBrush Год назад
First of all, I just want to say, this is a really well put together video. Just one tiny thing I wanted to mention here, is that in the example you chose there for STL in your second point, I kind of have to disagree with a little bit. I realize that it looks unfamiliar to you, but in the functional programming world, that looks very normal, in my opinion. Most people who have some time invested into a language like Haskell, or Elixir, or F#, or maybe even something like Clojure, would find that pretty readable and conventional. Words like "accumulate", "filter", "map", "reduce", and so on, are very much in the lexicon of functional programmers (iota is a little less common, but you can look that one function up, and then very quickly understand what is going on because the rest looks very familiar), and even though I personally don't like that C++ currently uses the same operator for piping and bitwise or, the concept itself of piping from one function into the next looks normal to people who use functional languages. :) It's not to say that you should use that type of syntax all the time, but, for example, if you were dropping into C++ for some reason with the intention to use it across an FFI into a functional language or something, then that type of syntax might actually be more readable to your maintainers than the alternative. Or even if your whole codebase was C++, but you had a group of people who decided on using more functional conventions, I think that the example you showed there would be really quite readable, I think it would probably be even quicker/easier to read than the alternative for such a group of developers. :) I'm not a hard-core defender of C++ or STL in particular, and we've all seen that there has been plenty of cruft in STL over the years, but in this particular case, I think the criticism isn't warranted in the way that you described it here. Contrast with the one-liner you showed in python, which I do think is complex enough that it is less readable than the alternative, and it isn't using common functional programming conventions like the C++ version is. Even the python code is not terrible or anything, but yes, I think it is harder to read than the original C++ version you showed. I think you do have a valid point in some cases with STL, but the example you chose here is, in my opinion, not the best illustration of it. Anyway, you made a very entertaining video here - I know you're primarily a python person, but it's cool that you've been branching out, and I hope you'll continue to explore other languages and paradigms and continue learning and growing throughout your whole career. I've subscribed, and I really look forward to seeing what you do next! :) And by the way, the production quality on this video is great - the fact that you only have 68 subscribers right now including me, and you're already putting out videos of this quality, is really something you should be proud of, so really, really great work. :)
@sophiacristina
@sophiacristina Год назад
Very well said, just like the error message example, i know some error messages are confusing, but the example of "'map' is not a member of 'std'" and not deducing that it lacks a header is ludicrous...
@deeplazydev
@deeplazydev Год назад
+1
@1InVader1
@1InVader1 Год назад
I completed a functional programming class in the uni with Haskell, hated every part of it. I've sworn I'd stay away from functional programming languages, and now here we are with C++ getting very ugly lambdas. This is not what I signed up for ffs.
@climatechangedoesntbargain9140
@climatechangedoesntbargain9140 9 месяцев назад
​@@1InVader1don't hate it, use the best parts to write more maintainable code
@jawad9757
@jawad9757 8 месяцев назад
​@@1InVader1 mald
@Gaelrenaultdu06
@Gaelrenaultdu06 Год назад
While i agree with most parts you talked about, you also have to consider, especially when you bring up the keyword "auto", that be able to use functionalities does not mean you HAVE to use them all, and/or use them all the time. "auto" is very useful in specific situations, such as iterators and for loops, but i would not use them anywhere else... Same case when it comes to allocate memory on the heap. To be honnest, you never should use "malloc" and "free" in C++, but in some situations, using "new" and "delete" makes more sense than using smart pointers, and it is also true the other way around.
@skeleton_craftGaming
@skeleton_craftGaming 9 месяцев назад
You should never ever use new and delete , std::unique_ptr is a zero cost abstraction over a raw pointer when the current function is its owner Note, I did not say that you should never use raw pointers, raw pointers are good for transferring a pointer without transferring its ownership.
@Gaelrenaultdu06
@Gaelrenaultdu06 9 месяцев назад
​@@skeleton_craftGaming That's debatable, because it really depends what you do and want to achieve. How do you think C programmers handle dynamic memory allocation ? Do most C programs have memory leaks and pointer ownership issues ? No. As i pointed it out earlier, being able to use functionalities do not make their use mandatory. There is no issue using new and delete operators, as long as you know exactly what you are doing and if the situation fits their use. The use of smart pointers can sometimes be complex. Let's say you have a unique pointer in your program, and for a random reason, as some point, you need to modify its ownership. You would have to either write a function to modify its ownership, or trick the compiler by using move semantics. Situation suddenly got a lot more complex and risky. Smart pointers are tailored for managing dynamic memory allocation. However, their are not always the most suitable option. We could think about resources like file handles, sockets, etc... I would put it that way : Although smart pointers should be used 95% of the time, saying they should never be used is wrong.
@thomasengland1701
@thomasengland1701 2 месяца назад
This video has to be clickbait.
@ittakir
@ittakir 8 месяцев назад
For me as C++ programmer, Python has one big red no-no flag that I cannot overcome: The Indentations. I always use {} in C++ even in one-line blocks. This makes me much easier to see the boundaries of a code block. If I copy-paste a block of code in C++ with {}, it will not lose a boundaries because of shifted indentations.
@martinjakab
@martinjakab 8 месяцев назад
Its the least of Pythons problems
@IAmNotASandwich453
@IAmNotASandwich453 6 месяцев назад
You know, at first that startled me too, but over the years I kinda started liking it, because if you care about clean Code, you should strive for clean indentations anyway. Making it a functional part of the language Force you to be clean.
@ittakir
@ittakir 6 месяцев назад
@@IAmNotASandwich453 I don’t need to be forced to write clean code. I can do it without some weird rules that contradict most of programming languages.
@IAmNotASandwich453
@IAmNotASandwich453 6 месяцев назад
@@ittakir Well, maybe, but you have probably seen a lot of other peoples Code that just dont care about it. While, in an ideal world, a formatting tool should take care of this anyway, thats sadly not how it works everywhere
@delqyrus2619
@delqyrus2619 9 месяцев назад
2:33 Because a package manager is not the responsibility of a programming language, it is the responsibility of the operating system.
@luigidabro
@luigidabro 8 месяцев назад
0:54 Why should someone ever allocate a vector on the heap?
@Jmcgee1125
@Jmcgee1125 Год назад
That initial rant about `auto` is why I hate using languages like Python where people don't typehint their code. "But it runs fine!" Yes, but I can't tell what it *does*.
@joeroeinski1107
@joeroeinski1107 9 месяцев назад
For a few points, 1) Rust is not a direct replacement for C++ (and frankly wasn't supposed to be). Carbon sounds like a possibility but it's still in heavy development. 2) It sounds like to me you're just nitpicking tiny things you hate about the language. If you're going to be such a pansy then stop using C++. 3) "Poor naming conventions of the average programmer" is one of your many statements that is highly subjective, yet you make it sound like it can't be fixed. Not every programmer is terrible at naming variables, yet you place the fault on the language instead of the developer. 4) C++ is not backwards compatible with C. C code does not ALWAYS compile in C++, especially C-special features (like mixing designated and aggregate initialization, or VLA, which are only in C++ as compiler extensions) 5) Writing fewer lines doesn't always result in cleaner code. While it's impressive to condense entire logic into a single line, just because it can be done it doesn't mean your code will be more concise and readable. 6) C++ has no package manager because nobody can decide what C++ really does. The only grasp on C++ is the ISO committee, nobody else. Thus, trying to establish a package manager will be a centralized task for a decentralized system, and the committee has no plans from what I've heard to achieve this. 7) 3:26 why the hell would you use printf in C++ anyway? std::format can print great compile-time error messages due to the compile-time type checking mechanisms. You're exemplifying C++ with C features. Overall, the video is filled with many subjective, misleading statements. Appalled by your approach to C++. You should do more research and not put so much personal opinion into these videos. 3/10
@luigidabro
@luigidabro 8 месяцев назад
Great feedback. Hope he reads it!
@joeferreti9442
@joeferreti9442 4 месяца назад
"auto" makes the most sense when used in code lines where the initializing value defines the type. Here it prevents you from repeating yourself. But if it isn't made clear in the code what type the variable will be, it shouldn't be used in most cases.
@yavvivvay
@yavvivvay Год назад
My only issue with c/c++ is that it tends to be very symbol-heavy and for some reason people insist on putting types into variable names in type-safe language (and using hundreds of preprocessor directives to redefine types into THEIR types and make pseudo-functions) which makes it a nighmare to read. Preprocessor is evil and makes reading code a nightmare.
@harleyspeedthrust4013
@harleyspeedthrust4013 Год назад
Preprocessor is not evil, it has plenty of valid and sensible uses. People are just not sensible.
@yavvivvay
@yavvivvay 5 месяцев назад
Hence the preprocessor giving too much power and too little control is an issue. Much like free pointers.
@PiotrPilinko
@PiotrPilinko 4 месяца назад
@@harleyspeedthrust4013 Unfortunately it is: compiler cannot assume that THE SAME header used in different compilation unit generates the same code, as any macro can be re-defined in any compilation unit which may give a totally different results in two different compilation units. My main complaints for big projects written in C++ is a long compilation time (in comparison to c#/java) - but Rust could be even worse...
@computhenics
@computhenics Месяц назад
I generally recommend people with no programming experience to start with Python. But, then there comes the risk that when they learn C/C++ they start questioning why things are the way they are in C/C++ compared to Python. If one starts with C or if possible Assembly, they get to live through the era and python (or other interpreted languages) seem like a natural progression from C/C++. With Python, people don't get to learn about memory layout, stack, heap etc. and then they question, "why segfault stack trace isn't as good as python?".
@balijosu
@balijosu Месяц назад
Agreed, mostly. I tend to recommend C for a first language. Python is great for some things, but it hides too much of what's really going on.
@torphedo6286
@torphedo6286 Год назад
This is why I just write all my code in C...nice and simple, far less standard library features to spaghettify my code, and it's incredibly readable while being just as fast (or slightly faster) than the crazy standard library syntax you showed an example of.
@cd2320
@cd2320 Год назад
Yeah and full of raw pointers too lol
@ME0WMERE
@ME0WMERE Год назад
C++ may be a complicated language, but it's still more maintainable and readable than C unless you're joking
@Kycilak
@Kycilak Год назад
One may also write C like code in C++ with the added benefit of using STL if one thinks it is better.
@pauldanaila1610
@pauldanaila1610 Год назад
@@cd2320 We need raw pointers. How will you describe an address to a MAC controller? On an IBM PPC you could hardware remap entire spaces, same for PCI spaces. Do you think that C++ smart pointers will protect you from hardware remapping?
@ME0WMERE
@ME0WMERE Год назад
@@pauldanaila1610 smart pointers just give you another way to use pointers - you aren't forced to use them if you don't want to (or can't)
@MadpolygonDEV
@MadpolygonDEV Год назад
A bit confused that you say you cant determine the return type of a auto variable. I think auto is for something where you dont care about the return type. I use auto for quick loops or dont have to operate on it. However, I am confused that you think its weird but you also use python? Python doesnt need you to define what type a variable is afaik, wouldnt it be okay with you then?
@codepersist
@codepersist Год назад
I use python but many times I'll use the type annotations so it's easier to debug later. It's moreso a coding style choice rather than something based on the language. I also said in the video that auto is great for small things like loops. It's my first video so I could definitely work on my explanations better 😀
@K9Megahertz
@K9Megahertz Год назад
I despise auto. I personally don't use it. I find it cumbersome to have to spend unnecessary time digging through header files to figure out what type a variable is. If it were specified instead of auto, would save a bit of hassle. Just my experience from reading/understanding code I didn't write.
@fullfungo
@fullfungo Год назад
@@K9Megahertzget a better IDE/extensions. All modern ones can deduce the “auto” type and show you what it is (except for templates, but that’s by design)
@K9Megahertz
@K9Megahertz Год назад
@@fullfungo Or I can just not use auto and not have to worry about what IDE I'm on. I really don't use most of the features of an IDE anyway. Best not to create a problem I will later need to find a solution for.
@Henry14arsenal2007
@Henry14arsenal2007 11 месяцев назад
I agree with the notion that more abstract languages like Python are absolutely harder to read than C++. Weak typing was a mistake.
@nick15684
@nick15684 Год назад
auto is definitely one of the things about C++ that I'm not really a fan of and never use. It adds a lot of ambiguity to a language that otherwise wants everything to be done very explicitly. It's something that makes more sense to exist in an interpreted language than a compiled one. I get that it's convenient, but ultimately it just adds more chaos. It's a hackish/lazy way of doing things. Not really worth it in my opinion.
@simongido565
@simongido565 Год назад
I use auto in places where it is obvious what type is behind auto.
@xGOKOPx
@xGOKOPx Год назад
> It's something that makes more sense to exist in an interpreted language than a compiled one. C#'s var and Rust's let disagree
@spell105
@spell105 Год назад
There is nothing ambiguous about it. The type is known at compile time so why write it out? Any half decent editor can show you what the actual type is.
@khatdubell
@khatdubell Год назад
In my experience, the type of people who hate auto are also the type of people who don't initialize their variables. using has nothing to do with convenience. It was introduced out of necessity, first and foremost. Modern C++ could not exist without some way of specifying a fixed type that the compiler knows, but you don't. Good luck writing a lambda in a reusable way without auto. ``` auto odd_filter = [](const int x){ return x % 2 == 0; }; ``` Can't do it. Back to my previous point, and why you should use it, which is also a reason you see it in newer languages like rust is because uninitialized locals are a source of many bugs. Too many old school developers who grew up when the "modern" thing to do was declare all your variables at the top of the function. And naturally, they wouldn't initialize them to a default value because its a wasted cycle because you'll just be overwriting it later. forcing yourself to use auto for as many things as possible actually makes you think about your code. because it makes you ask yourself if you should turn this (code a co-worker wrote literally last week) ``` int x; if (something.is_true()) x = something.value(); else x = 0; ``` into ``` auto x = something.value(); ``` where x is now optional, and we can check if x has a value if and when we need it, and a sensible default can be determined by whoever wants the value.
@tiranito2834
@tiranito2834 10 месяцев назад
@@xGOKOPx does that mean that they are correct tho? i still believe that ambiguity is not a good thing when you're in a systems programming language. If you want to use this like it's python or JS then knock yourself out, but the rest of the world would like it if we could actually use the language for a project larger than a few hundred lines of code. While the type is not ambiguous from the point of view of the compiler, from the point of view of a programmer stuck in a raw text editor in some embedded system it sure is a pain the ass.
@totally_not_a_troll
@totally_not_a_troll Год назад
Me, a java dev: > Oh c'mon, stop being a pleb, get an IDE that insn't flaming garbage and you'll see what auto that function returns OP shows auto as an input param. > BURN IT WITH FIRE!
@DynamicalisBlue
@DynamicalisBlue 3 месяца назад
A Python programmer complaining about the auto keyword? I think he’s forgotten that Python isn’t even statically typed.
@ooichu_
@ooichu_ Год назад
0:40 in C `auto` is storage class, not a type
@tordjarv3802
@tordjarv3802 Год назад
Funny how a Python programmer complains about the auto keyword. All the problems with auto you listed are 100 times worse in Python where every variable is "auto" and type hinting is not mandatory, at least in C++ the type of an auto variable is know at compile time, in Python you would have to wait until something goes wrong during runtime which could happen years down the line. The other parts I agree with, especially the weird naming of some STL functions, I guess that it is because many of the functions are inspired from array programming languages such as APL, which explains why iota is named iota and not range or sequence which would be more clear.
@managMent_
@managMent_ Год назад
The issue that I see from this video is that you don't "know" C++, or at least the arguments you make are from the perspective of a person that doesn't. I don't want to gatekeep C++ but unfortunately, it is a language you have to learn. Most of their design choices have a good reason, but they leave room for misuse. The auto keyword should NEVER be used like that. And while you can condense code heavily doesn't mean you should. Linker error messages are quite cryptic, but can be a little more readable using clang instead of g++, I agree with that issue, but if you understand how the linker works, it makes sense why these messages look bad sometimes. There are a lot of deep sitting details you need to keep in mind when coding in C++, which is why its known as a difficult language. Oh and nitpicky, smart pointers are not just a third way to do pointers. All the three ways to allocate memory on the heap have their own purpose and downfalls.
@codepersist
@codepersist Год назад
I agree C++ does need to be learned for some time as you can't just pick it up super quick. I should have worded a lot of stuff better in the video. I've been coding with C++ for a couple years and most of the issues I mentioned don't bother me as much as I just consider them weird. For example auto is a nice feature but can be made bad with poor coding choices and design. I think C++ is a language that everyone should learn and is super useful. Most of the features I mentioned are useful and nice features but like you said they leave room for misuse! :)
@managMent_
@managMent_ Год назад
@@codepersist Yeah, btw I didn't mean you were bad at C++, even if the wording was a little poor on my end. More like, a lot of C++'s weirdness has a reason that needs to be looked up. Hell, I think there is a ton I don't know about STL, even though I've been coding with C++ for many years, even professionally. I think it'll be a perpetual learning process. But this is what I love about C++, it allows you to do everything you want, even if it opens ways to really harm yourself. I'd much rather be wary while coding and have all the tools available than be restricted from "dangerous tools" by other programming languages like Java. And coding with C/C++ gives you a much better understanding of what's happening under the hood I think.
@wilsonnetoms
@wilsonnetoms 6 месяцев назад
Truly understandable but my thoughts on some of the points made: 1:05 - What is someRandomFunction? Nowadays everyone is using an IDE so it's pretty easy to check the function signature 2:10 - Transforming imperative code to functional-like code has its benefits. It is easy to read once you practice and get used to this paradigm. Just write good unit tests and rarely there's a need for debugging..
@gamerk316
@gamerk316 Год назад
I've worked with a good dozen programming languages over the years, and I OO C++ code the absolute hardest to figure out what the heck it does. There are times I question *why* we have to write several thousand lines of infrastructure to do what should be basic tasks. I just completed an OO C++ to C99 conversion project to support a new platform that didn't support C++. 100k lines were cut down to about the 5k that actually "did something", and when I was done with it the formerly 90MB executable was down to just 32k, and ran significantly faster despite running on less resources. There's something to be said about functional programming.
@marcotroster8247
@marcotroster8247 Год назад
Proper C coding is best. The only thing I miss is partial function application 😂 Why are those guys even using big libraries and frameworks in low-level codes? In hardware affine programming you wanna feel that you actually control the machine. C is just close enough to figure out which assembler code the compiler will generate 😂 I've recently programmed a neural net training to approximate sin(x) with 500 lines of C and it's twice as fast as TensorFlow already, just because I don't allocate like an idiot. And I didn't even optimize my matrix ops 😂
@username7763
@username7763 8 месяцев назад
I highly doubt what you encountered is due to C++. This is a pattern I've seen through my career. Your first-stab at something can end up being more complicated than it has to be. You are exploring the problem space, running into things you didn't think about before. The problem is that a lot of programmers just stop there when it mostly-kinda works. However, if you keep working on it, you will see patterns, you will see things that can be removed or made much simpler. I've done that with projects I've worked on. I've taken my first stab at things and cut it down way smaller and simpler than it originally was. I've seen logic patterns that could be moved into a table or handled better in a single spot. This was all without changing programming languages.
@remiwi2399
@remiwi2399 Год назад
I don't program in cpp very much, and when I do I don't use auto, but couldn't an LSP tell you the true type of any variable? The way I understand it, the types are still determined at compile time, so do they not just check the type and you can see on hover?
@jordan4220
@jordan4220 8 месяцев назад
If you have an ide setup ya. I like auto when the RHS includes information on what is being instantiated as in std::make_shared(). Why not use it in a scenario like that
@mathewkloepfer664
@mathewkloepfer664 Год назад
You know what I hate most about new versions of C++? Most companies are too lazy, stubborn, or incompetent to even try anything newer than C++11 (at best). What's the value in learning anything modern if a company locks you to a maximum version of the language?
@lukagarner
@lukagarner 4 месяца назад
This video is not a great criticism for modern C++! Bad practices of nice features will always be a thing, no matter how great something is, you will almost instantly see how it can be mishandled and that's fine. Perhaps you wanted to speak specifically about the bad practices, in which case, it would be nice to see a different title on the video.
@klimmesil9585
@klimmesil9585 3 месяца назад
Glad to see I'm not the only one. The video has a weakly supported opinion overall, and felt very messy and not thought through, as if it was impro and in the end they noticed new C++ isn't the problem, it's the users
@turolretar
@turolretar Год назад
C++ gets a lot of unnecessary hate
@mattias3668
@mattias3668 8 месяцев назад
3:00: Just install the library as normal to /usr/{lib,include} (or equivalent), preferably using your OS's package manager. What else do you need?
@exmachina767
@exmachina767 Год назад
Your criticism on error messages is spot on. It’s a nightmare for beginners when a missing semicolon generates reams of error messages.
@PiotrPilinko
@PiotrPilinko 4 месяца назад
But with a not so much experience a developer know, that in 99% cases the real problem is shown in the first or last lines of error message - what's between is usually not important.
@rosa_bot7594
@rosa_bot7594 8 месяцев назад
"auto concept_name variable_name" is such a great replacement for templates with verbose requirements and/or enable_if's. like, ex: "auto std::integral x" so simple, so readable.
@Diegovnia
@Diegovnia Год назад
This! exactly this! It's not only C++ that is now facing this issue... there is this stupid notion of going functional with every language. I mostly work with C# which is abstract enough and yet there are people who push for even more and more 'one liners' making it super difficult to read and deduce because of what? There is no benefit in it... yes you write 70 lines instead of 200 but try returning to it after a month when something breaks...
@williamdrum9899
@williamdrum9899 3 месяца назад
For the life of me I can't understand why anyone would care about "one liners" or the Fizzbuzz test in any modern language. It's all meaningless since the compiler/interpreter needs your code to look like spaghetti behind the scenes anyway. It's just a bunch of smartypantses trying to feel clever.
@jamesedwards6173
@jamesedwards6173 Год назад
Generally, I entirely agree with this content, though at 2:01 ... I don't have much sympathy if a coder---especially a Python coder (but not only Python since it's natively built into it as well as other languages)---who's wondering what "filter" is. 😝
@desmondbrown5508
@desmondbrown5508 Год назад
Yeah, I see this problem even with C# in our codebase all of the time. Everything apparently needs to be condensed down. And sure it "feels good" when you can do that... and it MIGHT even be more efficient if the standard lib does it better than you would've. But then you come back a month or more later to fix a bug... and it can take upwards of 25 mins or more just to figure out what the hell is going on. And it gets worse when we're not sure WHY something was implemented but because we've taken all these shortcuts to reduce code, there's more reliance on that shorter code, which ultimately means more rewriting if something has to change and can't use that library function.
@vitspenatek455
@vitspenatek455 Месяц назад
"I don't understand it" != "it's bad". There are always tradeoffs when signing up for a particular language. Things you complain about are done under the hood in the "comfortable" languages, but still have to be done. Ever wondered why people don't use python for low level programming? That fact that you HAVE TO do it yourself implies you CAN do it your way.
@The_Codemaster144k
@The_Codemaster144k Год назад
Does this man have less subscribers than even me? Bro get this man at least to 500k subs. How are you making such cool videos and the algorithm hasnt chosen you yet?
@tourdesource
@tourdesource Год назад
Better to initalize your smart pointers with auto, as in auto test_int = std::make_unique(20). IIRC using make_unique and make_shared allows for in-place construction.
@SvetlinTotev
@SvetlinTotev Год назад
"auto" is not an issue if you are using a normal editor. Just mouse over the variable and it tells you the type. The editor will also give you clearer compile-time errors before you even try to compile the code. And a debugger gives you everything you need for runtime errors.
@heyhoe168
@heyhoe168 Год назад
Yes, but sometimes in lambda declarations editors code model fails to analize code this deep.
@sprytnychomik
@sprytnychomik Год назад
What's a mouse?
@Megalcristo2
@Megalcristo2 Год назад
Or don't use auto when you shouldn't;
@koswag1204
@koswag1204 8 месяцев назад
2:15 the usage of lambda melted my brain
@janlanik2660
@janlanik2660 7 месяцев назад
'as it came from C, rather than being C++ exclusive'. Sure LOL. It also had completely different meaning and purpose in C....
@PiotrPilinko
@PiotrPilinko 4 месяца назад
Because it has changed it meaning (which was previously useless). C is no longer a subset of C++ - a lot of C cannot be compiled in C++ (if treated as C++): like trying to perform an incrementation of a pointer to void.
@3arabiWalBanate
@3arabiWalBanate 4 месяца назад
I agree with you, the C++ need : -Dependency management software like composer for symfony and this software need to make us agree for a general struct of C++ project. - New STL with simple syntax - GTL graphique librairie with many widgets and matériel design - Modern Editor design like figma with IA commandes proposition - of corse under MIT licence
@Raiver-of-Eridu
@Raiver-of-Eridu Год назад
This is mainly a (valid) critique of how some developers write bad code. Putting complicated constructs into one liners with filters, lambdas, transforms, etc., renders unreadable code. It is usually a developer who is learning about these new gadgets and find opportunities to stick them in his code. I would just avoid that style. You can still use perfectly modern c++ without cramming all those constructs into one line and make your code just as efficient but vastly more understandable by everyone. The best thing about auto is it makes code a lot simpler by reducing a lot of the boilerplate type specifications. Just because a feature is available doesn't mean it should always be used. As a developer, it's your responsibility to pick and choose what's appropriate.
@skeleton_craftGaming
@skeleton_craftGaming 9 месяцев назад
I mean using less code usually makes your code more readable, especially if you use well named functions, like the STL.
@LucasBikes-p2f
@LucasBikes-p2f 3 месяца назад
If I could restart my whole coding journey, I would still do the same. Which is learning C++ first, then python. Much prefer c++.
@andrejbartulin
@andrejbartulin Год назад
Well, if don't want to use particular feature, don't use it, C++ gives you a freedom to do it
@PiotrPilinko
@PiotrPilinko 4 месяца назад
But it always worth to know that function - to avoid writing your version (which in 99,99% cases is worse than in provided implementation)
@paulfloyd9258
@paulfloyd9258 Год назад
So if I only bother to half learn Python, does that qualify me to say that Python is weird and complicated?
@zdspider6778
@zdspider6778 Год назад
1:00 Well, yeah. You use 'auto' when you don't care about the return type. It's intentional. And sometimes even necessary when you dive into templates. 4:33 Smart pointers are not "a 3rd way" to allocate memory. Let's casually glance over the 'new' keyword on that 3rd line, shall we? _What 'new' keyword?_ EXACTLY! There is, however, a function called "std::make_unique" that calls 'new', but it's still using 'new'. Smart pointers were added in C++11, btw. Not a "new feature" by a long shot. They have their uses, but nobody's forcing you to use them (or any other feature).
@codepersist
@codepersist Год назад
I agree smart pointers may have been a little bit of a stretch 😅. Like I said with auto it has its places and I use it as well, but I think using it incorrectly could make the code harder to debug later.
@creapermann6356
@creapermann6356 Год назад
@@codepersist and you are saying this as a python developer? I'd argue that the existence of IDEs make this much easier, as does a static type system (which you don't have in other languages as e.g. python). There are many things to criticise about c++, but the ones you mentioned are relatively irrelevant (except the point about package managers).
@codepersist
@codepersist Год назад
I should have mentioned that I have been coding in C++ for a couple of years, I just have used python for longer. Even with python after python 3 you can put type annotation in the code for documentation purposes and I have been doing that, so I am just more used to the practice of static typing. I still stand by my point that the excessive use of auto can make code messier, but again that's more of a personal preference than an exact C++ problem.
@khatdubell
@khatdubell Год назад
Just because people can use the standard library to write "ultra condensed code", doesn't mean its a good practice. Its not. People writing bad code isn't C++'s fault. People can write bad, hard to follow code in any language.
@Inuyasha463
@Inuyasha463 Год назад
I haven't programmed in C++ since the mid 2000's, so I've never written any C++ code that uses lambdas or functional programming, but I found the functional code you showed as an example much more readable than the original nested code. Once you've used a language that supports functional programming, things like map, filter, reduce, fold, accumulate, etc. should all start to feel natural, and it's pretty easy to move between languages. I use Java and Kotlin at my job, so I see these all the time, and in many cases it makes things more readable, though I agree in some select cases it can make things less readable if you aren't careful. I suggest everyone spend some time familiarizing themselves with this stuff because it will help professionally when having to learn new languages that support it, and a lot of languages seem to be adding functional programming these days.
@ythanzhang
@ythanzhang Год назад
I think the confusion is two parted, one is being unfamiliar with functional style. The other is the way C++ uses overloaded operators to chain functions, resulting in a syntax heavy style that is quite convoluted at first glance. That video also showcased the Rust equivalent, it was much cleaner.
@theondono
@theondono Год назад
@@ythanzhang one of the biggest problems for me is how bad the naming schemes are. Even if you aren’t familiar with a particular language, with good naming schemes you can make educated guesses and get an idea of what’s happening. Such comforts are non existent in C++, were a “view” and a “range” are for some reason close analogs, or one finds “iotas” in the wild, just to name ones that appear on code reports video.
@multiHappyHacker
@multiHappyHacker 8 месяцев назад
C++ also has the killer app of free functions that aren't attached to a class.
@korigamik
@korigamik Год назад
What a cool video. I'd be very interested to know what you use to make these code animations 😊
@derlukas8182
@derlukas8182 Год назад
As someone who primarily programs in C (not C++) I don't get the complaint about segfaults. They are the easiest thing to debug and fix. I just load the coredump, get a backtrace and that usually is enough to tell me where something went wrong.
@cristiandecu
@cristiandecu 9 месяцев назад
But they never heard of SEGFAULTS in python; actually, they don't really know what SEGFAULTS are let alone using a debugger to pinpoint the culprit. That was a big red flag for me in this video; I mean when you're comparing runtime errors with compile time errors you're obviously not ready to make a video complaining about how bad C++ is.
@KilgoreTroutAsf
@KilgoreTroutAsf Год назад
when did a scripting language like pyrhon become a language someone can be a "developer" in
@colinmaharaj50
@colinmaharaj50 3 месяца назад
Been using C++ for 30+ years, so far I have not used the friend keyword, or auto. To use these are not compulsory, and coding should not be 'easy' if it makes coding unmaintainable or 'harder'. In fact, I would go as far as saying that if you can unambiguously declare a variable and assign it a value of a known type, then forgot the auto keyword altogether.
@roaddragon5015
@roaddragon5015 Год назад
Try to understand how C++ works and how it is designed before saying nonsense on it
@yyyd6559
@yyyd6559 Год назад
Wtf is wrong with you?
@yyyd6559
@yyyd6559 Год назад
Rust is better
@MrPatrickbuit
@MrPatrickbuit Год назад
@@yyyd6559 I think almost everyone can agree on that, but C++ is an industry staple and will be around for years to come. Rust is still a growing language.
@az-kalaak6215
@az-kalaak6215 Год назад
@@yyyd6559 different wouldbe a better word to use here c++ still has benefits rust don't have, and vice-versa. honestly, the more I read comments online, the more I think rust is a sect haha
@az-kalaak6215
@az-kalaak6215 Год назад
@@MrPatrickbuit not only c++ is industry-proven, but it is growing too, and quite fast. one standard every three years, three main compilers and std implementations allows for a lot of issue corrections. main downside is having to keepbackward compatibility,so it's bloated with useless junk, however you cannot have popularity with industry without backward compatibility
@ndrechtseiter
@ndrechtseiter 2 месяца назад
People in the comments are shaming you for being a Python developer, but for me, a commercial C++ dev, your takes actually make a lot of sense. I've tried a bunch of other languages in my life, and after some time with them, C++ suddenly stopped being normal. No, actually, it's not C++, but rather the Standardization Commitee. There COULD be a normal package manager (and no linking errors), but only if the Commitee decides to implement modules correctly (NOT LIKE IN F&#^@NG FORTRAN). There COULD be more readable errors, but only if compiler devs actually decide to make them readable. There COULD be consistency, but only if STL wasn't a template library. And there could be a lot less memory issues, if only this goddamn language could properly guide us through this miserable path. I'm talking about you, Mr. Segfault. Yeah, why the hell doesn't compiler tell me that there could potentially be a segmentation fault? _inb4 skill issue: commercial coding isn't about flexing, it's about making _*_zero_*_ errors in your code._ So yeah, you're totally right. Thank you for saying all these things out loud. I love this language. Stockholm syndrome, huh.
@SirWrexes
@SirWrexes 2 месяца назад
Maybe you're already aware of those, but just in case: vcpkg and libASAN are two pretty neat solutions to problems you mention. Although setting up vcpkg is a little bit of a hassle for the first times, when you got it running it's quite efficient at its job, and lets you override basically anything, to the point you can even apply your own git patches to the libs you install with it. LibASAN hooks onto your program simply by using `--fsanitize=,,...` and runs various runtime checks to make sure you're using memory and such right. Just enable the flag on debug builds, omit it on releases. 👍
@lolcat69
@lolcat69 Год назад
This is why I code with C, maybe i have to write strings by myself and a lot of stuff myself too, but i prefer that...
@julianocardarelli5106
@julianocardarelli5106 7 месяцев назад
When you know a language you know. And that's it. The most biggest mistake is compare two different technologies. If you know, you know. That's very very very simple. And if you like a language you needs to be aware about all the changes in the new versions. Today, it's very common to see babies trying to change the world/language concepts, but always without understanding why the things are as they are. Everybody wants to adapt the things for your own understanding. But, who did say your understanding is better?
@random_guy_on_the_internet69
The biggest problem for me are the templates in combination with the stl. I was implementing a templated function that takes in a message, formats it (adds time, etc.), and prints it to the console and a log file. But I wanted some easy formatting and parsing too. And since I was already using std::format() in the function, I thought I could simply make the function take in a variadic template argument and pass that to std::format() using std::forward(). But whatever I tried, nothing seemed to work. It kept giving me errors that said there was something wrong with the stl, instead ofbthe way I was passing it to format.
@spell105
@spell105 Год назад
You're just doing it wrong, you can absolutely and easily do that.
@skeleton_craftGaming
@skeleton_craftGaming 9 месяцев назад
Yeah, that might be one of the only reasons to use the printf family of functions... (And C style veriadic functions)
@Maiuna-yc2uk
@Maiuna-yc2uk 7 месяцев назад
To wrap a std::format inside your function you need to use std::format_string type as the format specifier to be used in the std::format.
@qqshutup7175
@qqshutup7175 4 месяца назад
From cppreference: "Since P2216R3, the format string must be passed in as a compile-time constant, and std::format does a compile-time check on it (via the helper type std::format_string or std::wformat_string). If it is found to be invalid for the types of the arguments to be formatted, a compilation error will be emitted. If the format string cannot be a compile-time constant, or the compile-time check needs to be avoided, use std::vformat or std::runtime_format on fmt(since C++26) instead." 30 seconds of reading
@qqshutup7175
@qqshutup7175 4 месяца назад
@@skeleton_craftGaming std::format/std::format_string resolves the formatting at compile time, determining the most efficient way to format the string and allowing the compiler to prevent compilation if the formatting is not valid, while std::vformat will throw at runtime if something is wrong, while sprintf will cause UB.
@askraskr4027
@askraskr4027 Месяц назад
As a C++ developer, I can say, that almost 90% of what you said was WRONG.
@snesmocha
@snesmocha Год назад
I went from python to c++, best decision ever. Still use python on a regular basis but my god it both improved how I think about code and how I develop.
@Bob-tx7hv
@Bob-tx7hv 9 месяцев назад
the problem with C++ is not due to backwards compatibility with C, actually C is a much sane language. C++ is a Frankenstein of programming languages
@PiotrPilinko
@PiotrPilinko 4 месяца назад
Frankenstein was a doctor, who created a nameless monster.
@ZihadJoy
@ZihadJoy 6 месяцев назад
after coding in c++ for more than 1.5 years i can say that im a beginner in c++, there's wayyyy too much to learn
@PiotrPilinko
@PiotrPilinko 4 месяца назад
After using c++ over 20 years in professional work (well, together with C, java, C# and more), I'm still aware that I need to learn a lot.
Далее
31 nooby C++ habits you need to ditch
16:18
Просмотров 786 тыс.
Ditch your Favorite Programming Paradigm
6:08
Просмотров 182 тыс.
Watermelon magic box! #shorts by Leisi Crazy
00:20
Просмотров 2,7 млн
Avaz Oxun - Turqi sovuq kal
14:50
Просмотров 889 тыс.
Naming Things in Code
7:25
Просмотров 2,1 млн
Writing a game the hard way - from scratch using C. #1
34:20
how Google writes gorgeous C++
7:40
Просмотров 886 тыс.
Skills Every Programmer Must Build (Early On!)
3:24
Просмотров 4,5 тыс.
The 3 Laws of Writing Readable Code
5:28
Просмотров 575 тыс.
Why i think C++ is better than rust
32:48
Просмотров 307 тыс.
Somebody emailed me a trojan virus
14:06
Просмотров 783 тыс.
Computer Science Is Not Software Engineering
14:55
Просмотров 107 тыс.