I Tried C++, here's what I learnt...
HTML-код
- Опубликовано: 22 май 2024
- Signup for Codecrafters for free: app.codecrafters.io/join?via=...
Grep Repository: github.com/conaticus/grep-clone
Traffic Lights Repository: github.com/conaticus/traffic-...
Discord: / discord
Github: github.com/conaticus
Twitter: / conaticus
Join this channel to get access to perks:
/ @conaticus - Наука
Signup for Codecrafters for free: app.codecrafters.io/join?via=conaticus
no
actually looks like a good sponsor, might check it out
The amount of "Code Crafters" phrase he said in this video is insane.
Yeah we're in the age of most youtube videos are ads first before they are content people need to see
It’s unbearable
@@slimxshady6111 Exactly
@@AntonioDoesMetalNot most, small amount
Fr every 2 damn seconds, literally just an ad
Tbh I thought you were gonna trash the language to death as most people do, it's nice to see a more balanced opinion of it.
C++ is great if you’re working on your own, in fact it’s fantastic, but as soon as you’re working with others it becomes a nightmare due to everyone having their own ‘accent’ of C++, accents you sometimes can’t understand at all even though it’s still the same language. I can’t read most Cpp20+ code, but C-like C++ is easy for me. Both are legal C++, everyone just does their own thing so you feel like you have to learn a new language just to understand someone else’s code. The flexibility is sooo powerful on your own though and like you mentioned, the C-like freedom to do what the fuck you like is great for quickly prototyping and just getting shit working without caring about safety.
By "accent", do you just mean version syntax?
@@juanmacias5922 Far more than just that... syntax is barely scratching the surface.
Here is how I would interpret "accent" as:
using namespace std; vs. not
Using auto vs. not
Using C++11 compiler settings vs. not
Using fancy algorithms vs. not
Using lambdas vs. not
Don't even get me started with object oriented stuff... vs. not
Using class vs struct
Using templates vs. not
Using utilizing inheritance vs. composition
Using std::string vs. const char * (std::string is IMO superior, but again... accents)
Using trailing return type function declaration style vs. traditional
Splitting stuff into multiple files vs. not
Coding all of your program in a header file and slapping `inline` before each function so the compiler doesn't complain about it (I do that btw), vs. not
Using some third party library vs. implementing your own
Using fancy features from the latest unfinished C++ standard (C++26 maybe?) before they are refined, vs. not
Using modules and `import` stuff vs. not (I am honestly still waiting for some major C++ company to start using that and surprise the entire world that `import` is now a keyword in C++)
There are more but I am lazy to think about them at the moment...
Did my reply just got deleted or did youtube not register it at all.... glad I had message text in a file so here it is:
@@juanmacias5922 Far more than just that... syntax is barely scratching the surface.
Here is how I would interpret "accent" as:
using namespace std; vs. not
Using auto vs. not
Using C++11 compiler settings vs. not
Using fancy algorithms vs. not
Using lambdas vs. not
Don't even get me started with object oriented stuff... vs. not... yeah let's get started:
Using class vs struct
Using templates vs. not
Using utilizing inheritance vs. composition
Using std::string vs. const char * (std::string is IMO superior, but again... accents)
Using trailing return type function declaration style vs. traditional
Splitting stuff into multiple files vs. not
Coding all of your program in a header file and slapping `inline` before each function so the compiler doesn't complain about it (I do that btw), vs. not
Using some third party library vs. implementing your own
Using fancy features from the latest unfinished C++ standard (C++26 maybe?) before they are refined, vs. not
Using modules and `import` stuff vs. not (I am honestly still waiting for some major C++ company to start using that and surprise the entire world that `import` is now a keyword in C++)
Don't even get me started on coding style differences: clang.llvm.org/docs/ClangFormatStyleOptions.html (I don't want to talk about that)
There are more but I am lazy to think about them at the moment...
I don't care anymore about different coding styles, because once you've learned like 3 or more languages everything feels the same. I think the problem is more about bad code than "coding accent" or "learning a new language" in most cases.
@@diadetediotedio6918allegedly
Bro has become an full time employee now, sponsored video after sponsored video
1:03 That quote sums up C++ perfectly
Conan plugin with CLion makes dependency management fairly straight forward
TL;DR: i want to break free
A header file is just copy paste tool, literally, we don't need to use header files but because you have to declare in the source file every variable, function or class that you use, specially if they come from other source files(.cpp), than header files are a must to not having to write all those things on each source file. Header files just literally copy and paste their content inside the source file as if we had writen ourselves.
C/C++ is like my very old friend, still living in punk-rock past times thanks to which I'm a programmer today. My first programs I developed at elementary school with this bastard gave me pureblood knowledge about how everything works under the hood. Programmers who tried this should be branded so everyone knows they survived the main boss.
Hey there! Im still in elementary school and going to highschool next year, i learned lua with love2D, and i wonder is there any good sites or videos to learn courses about lua or love2D framework utils? I already watched some steve teacher videos but i didnt feel comfortable with his video style, challacade is a good channel for giving out examples of how things works like enemy movement towards player, talks about love2D useful tools, but i cant really understand anything that doesnt have a code example, i cannot just understand a concept without code and implement it in my game, and i also suck at communicating with people on any platform so people cant really help me either!
On unix systems. You can install libs like sdl and just include them in your code. No need to copy paste the hole lib thing
I've been learning C++ and every time I compile I just pray I don't get an error.
as someone who tried to learn Rust, I totally get what you mean lol
It's great that the errors are caught at compile time. That's the point of modern C++.
without address sanitizer you don't know if you had UB 😆
Undefined behavior sanitizer is for that
@@ohwow2074 LMFAO
Nice tutorial again!
Yeah it does. I actually agree with your first point about compilers and libraries, but that's the price you pay for having a well-defined ABI
, Microsoft's CL is nice because ot uses language extensions to the `#comment` pragma that allows you to define lib paths in files...
You will eventually have to use pointers, however the STL [standard template library] std:: unique_ptr and std::shared_ptr That abstract the allocation and deallocation away so they're basically equivalent to using references.
I love C++. I love Rust even more. I love low-level languages!
Same, I just switched to rust recently and it's awesome not having to deal with compiling and awful looking C++ legacy syntax, rust is super clean and well thought out
I rate it C+++++/C++
Could you make a video about you making these compilers and operating system projects in C/C++ that'd be really helpful.
You should use std::span and std::string_view for passing "reference" to array types like std::string and std::vector.
this is just one long ad
would like to see u trying assembly (:
I'm making a compiler in C++ for my own language and it's been fun :)
I would recommend meson instead of Cmake or make. It integrates with Cmake and has Python like syntax and uses ninja as a back-end for compilation which is the fastest C++ build system.
Not to be rude or anything, but I feel like I have to mention this. Actually at 4:48 that error message tells you the problem, and literally 1 min of googling can help with understanding it.
This is not a bad error message, because even if you don't know anything about what it exactly means, reading the words "undefined reference" to sg. may help you start thinking about what could be happening in the background.
Make sure to use Address Sanitizer if present
Is that font Jetbrains Mono ?
Such a good observation on writing code freely. It's one of the reasons I still reach for C/C++ instead of Rust at times.
Great video, dude!
Real question. Why do you couple C and C++ when they are two completely different languages?
@@Maagiicc Mainly because I'll reach for either C or C++ at times, depending on what I'm looking to do.
Thank you man ❤
C++ is like Gambling, There are no losers Only Quitter
heh, yeah the c++ gcc stl is a bugpile, so if you get a template error, that error message is virtually unreadable
I learned more about codecrafters than c++ in this video!
I did c++ a while back and honestly it’s not anywhere near as bad as people always make it out to be. Zig is still cooler
Explore other paradigms other than OOP. You will realise how sometimes OOP isn't required, plain functions are more than sufficient.
Actually depends, for example virtual inheritance is more scalable for UI interfaces then the functional approach, (hence why almost every widely used UI solution will take advantage of virtual inheritance directly or indirectly) and funny thing is that in C++ virtual function calls don't by themselves even have notable performance implications, (if you benchmark virtual function calls its literally a 50/50 chance whether any direct function call will be slower then the virtual function call version, even on the same compiler, compiler flags, and CPU you won't get deterministic results for any run) the inheritance and OOP is absolutely a valid tool, use the right tool for the job and sometimes they are the best solution.
@@Spartan322 I meant to say, don't complicate things when you know it's just a simple function that you need to write, don't create a class only to have static public functions..
So you are right in the way it depends on the use case.
i am a C++ programmer for past 3 years,i dont understand much ,yet i use it anyway and love it
How can you use a language for 3 years and not understand much? I think you should try a bit more advanced projects to gain deeper knowledge
@@aboliguu1168 you need to learn more about C++ and then talk to me .....
@@aboliguu1168 or read the docs lol
Just say you understand it decently now, if you try to appear way too humble considering it's been 3 years then it either sounds fake or it sounds like you put in no effort at all.
@@aboliguu1168 Some people really like to prefer the C way of doing C++ (aka not using fancy C++ and C++ standard library features even though they exist)
I think it's all fine, it can make up for some verbose code that you can easily edit... Unless your name is performance
Yes someone shares my pain with installing SDL
Now do it with no low level knowledge and on an old version macos
SDL is always painful to use, unless you use the big Visual Studio for it
C++ is not made for programmer, it’s made for Mathematician Programmer. Yeah i forget to tell you C/C++ isn’t for lazy people.
I'm learning that coding hurts my brain.
Yes it does, especially when the project gets long to like 300 lines of code and all the syntax, all the languages, it gets confusing.
C++20 Concepts actually solve type debug crap stupid easy, it tells you why it failed and it doesn't spit a thousand lines of useless junk at you.
Personally C++ is my favorite language and toru be honest I just gave up on trying to compile on windows. When I use linux I just use pkg-config and I'm done
Why do you use Windows 10?
Siento que no existe razon alguna de ir con C++ que no sea exclusivamente el rendimiento o por pura necesidad, o porque no existe otra herramienta para el trabajo. Durante muchos años estudie C++ porque queria hacer un motor de juegos, y porque lo disfruto, por ser de bajo nivel y todo eso, aprender mas sobre la computadora, y le tengo cariño, pero a su vez entiendo que de alguna manera es la evolucion natural de lenguajes mas antiguos, y es el resultado de un comité muy politizado por necesidades de grandes corporaciones mas que un diseño que sabe lo que quiere, pero que se adapto sorprendentemente bien a las necesidades modernas, bueno, quiero decir... no se resigno a morir. Creo que no tiene salvacion, pero la humanidad depende de el. Mmm, no lo se... lo siento asqueroso pero no tenemos algo mejor supongo
I love C++, and hate it at the same time.
2:40 yes, because you aren't using an IDE... 👨🏭
I highly prefer C, C++ is full of verbosity and things that feel rather useless. About Rust, the borrow checker is annoying 999,99% of the time, but at least you don't have to deal with segfaults that give no clue of what happened (besides a core dump, which you need to configure in your os to actually get useful info), and allocations are better handled in rust. You can clearly see that a Box or a Vec performs an allocation, but in C++ any class can do this->field = new Value(); in the constructor (yeah, in rust any struct can still have box fields, but a box is clearer than a pointer, and i think that writing unique_ptr is a bit too verbose)
oh, so you THINK you didn't encounter UB
Great
Compiling and linking are such a pain because you are using Makefiles instead of CMake. Using CMake is modern C++ best practice.
Thanks, but friendship ended with C++ now Odin is my best friend
thinking C or C++ is pure skill issue. The true negative of C is that there are a million ways to write the same line of code, so understanding other's code sometimes can be challenging or be utterly Impossible. I wish people just sticked to writing C-Like C++, at the end of the day it is supposed to be an improvement/modern iteration of C.
I’ll be trying C++ to C…
XDDD
Had to stop the video cause of the constant light mode flash bangs, hurting my eyes at night.
Finally got 10 minutes after posting
To me references are just pointers where you don't have to explicitly dereference them and without pointer arithmetic.
Otherwise they are the same thing under the hood. I don't get why people overexaggerate things like pointers.
4:48 Dude, just READ it. It literally says "undefined reference to ...". It's a linker error. You are probably not providing it with the .cpp file that contains definition for that function.
C++ experience on windows is absolute garbage, unix based operating systems (including macos) are way better in terms of libraries, build systems, compilers etc. On windows, you are often faced with weird msvc stuff (even outright bugs…) and switching to other compilers is not frictionles.
Even cmake is bs because you are very strongly pushed to use it as a visual studio pre-step (absolute fucking shit, works as intended like 20% of the time), while on mac and linux, it just creates a makefile. (Easy, fun, simple)
cool
Live coding videos
Make longer videos.
No I can't hear "code crofters" for another 3 minutes
2:50 Buddy, you can do OOP (of Smalltalk fame) and class oriented programming (modern OOP) in C++. No one is gonna bite you if you don't give in to the C gods and make everything a struct.
You'll just have to silently judge yourself on why OOP code didn't maximize cache utilization for ultimate performance compared to data oriented design. BTW none of these paradigms should be ham fisted into your design because "they say so". If it's solved better and it runs faster with OOP compared to the same code written in DOD principles, that's fine. ;)
Cache utilization is also overhated most of the time. UI applications and the majority of code will not make such a performance difference if you are or not correctly using cache and making your code predictive, so OOP is not the one to be judged here: most of the performance problems in large software usually comes from extremely misusing memory and relying hugely on I/O operations.
So I like DOD more (generally) because it induces better composition and reusability of software rather than because it maximizes cache utilization.
@@diadetediotedio6918 So you're telling me there's zero performance difference between:
struct oopcoord { int x; int y; int z; };
struct oopcoord coords[5000];
// data init here
for (int i = 0; i < 5000; i++)
coords[i] += 8;
// same for Ys and Zs
And:
struct dodcoord { int *x; int *y; int *z; };
struct dodcoord coords;
// data init here where we have 5000 Xs, Ys, and Zs
for (int i = 0; i < 5000; i++)
coords.x[i] += 8;
// same for Ys and Zs
I'd love to see your benchmarks on why these two produce the same performance so 10+ years worth of DOD talks regarding performance superiority over OOP are finally proven wrong 🤣
@@diadetediotedio6918 I'd love to see your benchmarks A/B testing DOD code vs OOP code just so you can prove 10+ years of DOD talks asserting superior performance using DOD wrong 🤣
@@diadetediotedio6918 Any benchmarks we can see proving your performance statement (DOD vs OOP) and exactly why they're equivalent in performance behind your assertion of heavy IO usage or UI framework code being a mess in general?
@@SimGunther
I'll correct the misunderstanding here right away. Obviously there is a performance difference* in using DOD from OOP if we are talking about how fast algorithms structured in either way would run in a computer, I'm not disputing this fact.
What I'm disputing is about perceived performance, and that's why my examples were UI applications and most of normal code paths. I'm talking that in this specific sense, the perceived performance will not differ significatively, dot.
C++ is kinda cool. I prefer c but of your fine with not doing too many weird stuff its nice
try c
If you don’t, know C/C++, too much thing…..
I enjoy C++ and its all STL features
6 minute ad
1 view in 20 seconds
C# does not compare to C++ / Rust. It's not a serious competitior, as you cannot even code drivers for most Microsoft's toy.
First, guess what? :D
no
@@moonyl5341yes
no ur not i was first
@@TheRealMangoDev it said uploaded 1s ago when I opened
@@Faraday2122 youtube isn't consistent on which comment is first, so.....
//First comment
no
Under 1 hour gang
👇
at this point change your channel name to code crafters -.-
Sad to see. Get your money up bro but just fekt like code crafters ad
19 likes in 4 minutes bro fell off 🧀
bruh r u kidding me rn
This video is basicaly an Ad... Thumbs down 👎