Forbidden C++

Ғылым және технология

The unimaginable evil of C++ is unleashed. Be afraid. Global Variables, Macros, Void*, Goto, Namespace STD, New & Delete, all the tools every C++ programmer needs... right?
Patreon: / javidx9
KZread: / javidx9
/ javidx9extra
Discord: / discord
Twitter: / javidx9
Twitch: / javidx9
GitHub: www.github.com/onelonecoder
Homepage: www.onelonecoder.com

Пікірлер: 2 600

  • @javidx9
    @javidx94 жыл бұрын

    Hello! During these miserable times, I hope this raises a few smiles. Anyway, take care of yourselves, and don't forget those that may need some additional help. Keep washing those hands!

  • @festiveFurry

    @festiveFurry

    4 жыл бұрын

    I care about old processors and processor architecture

  • @Gizego

    @Gizego

    4 жыл бұрын

    @@festiveFurry I do too. I just wouldn't like programming for their limitations.

  • @chair547

    @chair547

    4 жыл бұрын

    Isnt the "dark side of c++" all of it?

  • @PJBonoVox

    @PJBonoVox

    4 жыл бұрын

    It did raise a smile. Enjoyed your attempt at thespianism :)

  • @eformance

    @eformance

    4 жыл бұрын

    I find it ironic that it takes 14 days to show symptoms and 14 days to recover...28 days later...

  • @veda-powered
    @veda-powered4 жыл бұрын

    intro is clearly fake... everyone knows programmers don't go outside.

  • @alphaforce6998

    @alphaforce6998

    4 жыл бұрын

    That was his basement.

  • @Kirides

    @Kirides

    4 жыл бұрын

    @@alphaforce6998 How could he not know. Programmers are so wealthy, we buy hundreds of yards of land to create a huge basement that looks like its outside, but without other people.

  • @NilesBlackX

    @NilesBlackX

    4 жыл бұрын

    @@Kirides "outside, but without other people" Those are the best five words I've ever seen put together

  • @mikekrow

    @mikekrow

    4 жыл бұрын

    He is a programmer, so he can afford to hire an actor

  • @Xorberax

    @Xorberax

    4 жыл бұрын

    Can confirm. I haven't left my house since the Coronavirus started. Neither have I left it a month before.

  • @mr649001
    @mr6490014 жыл бұрын

    "Sir, why are you walking around with a hoodie and a shovel in the middle of the night?" "Uhhh umm uhhh just making a programming video"

  • @PhilBoswell

    @PhilBoswell

    4 жыл бұрын

    I would be more worried about his better half's reaction to him digging up her plants 😵🥴🤬

  • @engineerbot

    @engineerbot

    4 жыл бұрын

    Phil Boswell can you restate that in terms most people can understand?

  • @WillCrawford0

    @WillCrawford0

    4 жыл бұрын

    @@engineerbot his spouse might take exception to his desecrating the vegetable patch.

  • @dazhenghu4956

    @dazhenghu4956

    4 жыл бұрын

    bravo

  • @thomasdalby3567

    @thomasdalby3567

    4 жыл бұрын

    he coulda said his toilet was bogged up …..

  • @codeman99-dev
    @codeman99-dev3 жыл бұрын

    14:47 Way back when I first learned C++ (in college), I wrote an assignment with a goto for clean-up. My professor forced me to re-write it even though there was absolutely nothing wrong with my usage (he admitted so himself). So, I re-wrote it using a recursive function. He hated that even more. :)

  • @jeffspaulding9834

    @jeffspaulding9834

    3 жыл бұрын

    My school jumped from C++ to Java halfway through my time there, so many of my upper level classes used Java for everything. I learned that my professor didn't actually check our homework by doing all my assignments for our Data Structures class in Clojure. (Gotta say though, a different professor actually laughed and gave me an A for a Numeric Methods assignment I did in Fortran 77.)

  • @cezarcatalin1406

    @cezarcatalin1406

    3 жыл бұрын

    Jeff Spaulding I wrote some text parser in Cobol in my first year of university and both young teachers and colleagues thought I was some kind of wizard.

  • @absurdengineering

    @absurdengineering

    3 жыл бұрын

    @@cezarcatalin1406 “Can read books/other resources and learn new stuff = wizard” - because so many people can’t learn stuff on their own, or have no drive to pursue anything “intellectually hardcore” outside their realm of experience. And also because so many students just do the minimum needed to get by - I swear that teaching sometimes must feel like being dumbed down by all those souls in the classroom that only want a grade and move on…

  • @thomaspearson3698

    @thomaspearson3698

    3 жыл бұрын

    Oh, recursive functions? *Pulls out pepper spray*

  • @jeffspaulding9834

    @jeffspaulding9834

    3 жыл бұрын

    @@thomaspearson3698 After you program in Scheme long enough, you start to feel that way about while loops.

  • @Archimagus
    @Archimagus3 жыл бұрын

    I appreciate this video a lot. Because it doesn't just parrot "Don't EVER do these things" but actually gives examples why, but also gives a case or to where they actually make sense.

  • @tappineapple3381

    @tappineapple3381

    3 жыл бұрын

    I agree, I hate when there are youtubers who say "never do {this}" when there is always a time when it's justified.

  • @typowyjnn2300

    @typowyjnn2300

    3 жыл бұрын

    Global variables are a sin and programmers who use it burn in hell

  • @tappineapple3381

    @tappineapple3381

    3 жыл бұрын

    @@typowyjnn2300 they are more of a problem in JIT languages rather than compiled ones.

  • @VivekYadav-ds8oz

    @VivekYadav-ds8oz

    2 жыл бұрын

    @@typowyjnn2300 Embedded?

  • @nikkiofthevalley

    @nikkiofthevalley

    Жыл бұрын

    @@typowyjnn2300 I use them fairly regularly in game dev, you have to have some kind of global state, and global variables are the easiest and simplest way of doing that. You can also use classes to make it so they cannot be modified without using the methods of the class itself, meaning you don't have the problem of global state being able to be modified at random. I also use a "glbl" namespace so I don't pollute the global scope. (and thus local scope as well)

  • @Digidan5
    @Digidan54 жыл бұрын

    who else expected one of their github repos to come out of the box XD

  • @ekremdincel1505

    @ekremdincel1505

    4 жыл бұрын

    Lol

  • @Wersjon

    @Wersjon

    4 жыл бұрын

    You got me :d

  • @graphitic5578

    @graphitic5578

    4 жыл бұрын

    An experienced user that joined 12 years ago and has no content, goddamit why wouldn't you.

  • @TahasYouTubeChannell

    @TahasYouTubeChannell

    3 жыл бұрын

    I love this comment so damn much because i relate

  • @ArIyan_yt

    @ArIyan_yt

    3 жыл бұрын

    😂

  • @thepuzzlemaker2159
    @thepuzzlemaker21594 жыл бұрын

    "...And within lies the most heinous and evil forms of C++ code ever known. Would you like to look inside?" *Cut to my C++ code*

  • @inigo8740

    @inigo8740

    4 жыл бұрын

    I was watching this video while coding and immediately moved my global variables into int main... At a good time too, since it was right when the errors were gonna pop up.

  • @aaronwise1089

    @aaronwise1089

    3 жыл бұрын

    @@username6338 he has various alternative options in no particular order being Unity Unreal engine Lumberyard Ogre Game Maker Studio 2.3 Construct 3 Gamesalad Clickteam Fusion 2.5 Buildbox 001 game creator RPG Maker Dreams PlayStation 4 Scratch Stencil Visual Basic

  • @aaronwise1089

    @aaronwise1089

    3 жыл бұрын

    @@username6338 technically those programs can also create Apps and software

  • @StepDub

    @StepDub

    3 жыл бұрын

    I’m no longer a programmer, merely a data monkey, but my years as a programmer were perfect training for lockdown. In fact, I’ve quite enjoyed it.

  • @plutosutton6059

    @plutosutton6059

    3 жыл бұрын

    felt that...

  • @chrisbartlett9930
    @chrisbartlett99304 жыл бұрын

    Me opening my IDE at 3am without a dark theme 1:05

  • @Luca-sz5uy

    @Luca-sz5uy

    3 жыл бұрын

    underrated comment

  • @gustavofernandes7598

    @gustavofernandes7598

    3 жыл бұрын

    Made me laugh, got my like

  • @jeshuruncarlos6649

    @jeshuruncarlos6649

    3 жыл бұрын

    True !!! 🤣🤣🤣

  • @Hackanhacker

    @Hackanhacker

    3 жыл бұрын

    OHhohhoh shit i feel that right in my eyes !!!

  • @ytivarg5371

    @ytivarg5371

    3 жыл бұрын

    cries in codeblocks

  • @BerkaySoyluoglu
    @BerkaySoyluoglu3 жыл бұрын

    2:07 Global Variables 8:11 Macros 12:40 Goto 16:27 (void *) 22:23 using namespace std 27:31 new & delete

  • @usmanahmed3035
    @usmanahmed30354 жыл бұрын

    Probably the greatest intro I'll ever see for a coding video

  • @javidx9

    @javidx9

    4 жыл бұрын

    Thanks Usman, I like doing the sillier stuff XD

  • @ir2001

    @ir2001

    4 жыл бұрын

    javidx9 That's why I love this channel and you are one of the few coding channels I'm subscribed to :)

  • @xtdycxtfuv9353

    @xtdycxtfuv9353

    4 жыл бұрын

    javidx9 yes your intro is deemed kek. expertly done.

  • @Kaltinril

    @Kaltinril

    4 жыл бұрын

    I completely agree!

  • @manuelesparza5321

    @manuelesparza5321

    4 жыл бұрын

    you should see cs50 lectures intro

  • @subcivil-youtubechannel7283
    @subcivil-youtubechannel72834 жыл бұрын

    #define true (rand() % 100 This is just pure evil

  • @orocimarosay1447

    @orocimarosay1447

    4 жыл бұрын

    Quantic physics ;)

  • @ke5uq1we8h

    @ke5uq1we8h

    4 жыл бұрын

    Interesting to note, that if you initializing random generator with a static value, you would be getting consistent behaviour with that define. Wild, but consistent.

  • @kaushikrishi2779

    @kaushikrishi2779

    4 жыл бұрын

    Don't forget srand(time(NULL)) this will make it more evil

  • @whythosenames

    @whythosenames

    4 жыл бұрын

    Володимир Герасимчук No you don't initialize it like if you would do variable = (rand()%100

  • @ke5uq1we8h

    @ke5uq1we8h

    4 жыл бұрын

    @@whythosenames srand(42); // no, I DO initilize it like this

  • @BG-qv5xj
    @BG-qv5xj3 жыл бұрын

    Me, who's only been coding in c++ for 2 months now: "I like your funny words coding man"

  • @cinnybun739

    @cinnybun739

    3 жыл бұрын

    Bruh, I don't even know CPP.

  • @danielesquivel3155

    @danielesquivel3155

    3 жыл бұрын

    ;(

  • @Skraeling1000

    @Skraeling1000

    3 жыл бұрын

    I think his main problem is that he hasn't numbered the lines. Like, yanno - 10 20 30 etc

  • @pietverver8194

    @pietverver8194

    2 жыл бұрын

    This comment made my day😂👌🏼

  • @VivekYadav-ds8oz

    @VivekYadav-ds8oz

    2 жыл бұрын

    Me who knows Rust: *elitist smirk** _look what they need to mimic a fraction of our power_

  • @OnboardG1
    @OnboardG13 жыл бұрын

    “Processors from the 80s, no one is going to be interested in that surely?” *cries in embedded hardware*

  • @unknownsoldier4156

    @unknownsoldier4156

    3 жыл бұрын

    Felt that deeply

  • @petergamache5368

    @petergamache5368

    3 жыл бұрын

    ... on a Z80

  • @thomaspearson3698

    @thomaspearson3698

    3 жыл бұрын

    Truly a blow as low as the hardware's processing speed.

  • @spicybaguette7706

    @spicybaguette7706

    3 жыл бұрын

    Programming on a TI-84 belike

  • @rishabhrawat7856

    @rishabhrawat7856

    3 жыл бұрын

    Cries in fossilised hardware

  • @renhoeknl
    @renhoeknl4 жыл бұрын

    Timestamps: 2:00 Global variables 8:00 Macros 12:36 Goto 16:20 Void * 22:17 Using namespace std 27:19 New and Delete

  • @1889990

    @1889990

    4 жыл бұрын

    thanks you saved me from wasting 33 minutes

  • @Drqonic

    @Drqonic

    4 жыл бұрын

    @@1889990 "Wasting" That's a funny statement. Watching this video through to the end without skipping will benefit YOU significantly.

  • @The-Cat

    @The-Cat

    4 жыл бұрын

    @@Drqonic It wont benefit that person. He's got a busy life.... Idk, just assuming... whatever...

  • @Drqonic

    @Drqonic

    4 жыл бұрын

    @@The-Cat and there are 24 hours in a full day. 33 minutes won't take shit from him.

  • @Drqonic

    @Drqonic

    3 жыл бұрын

    @かわいいreo Not really. 33 minutes is nothing.

  • @jimfcarroll
    @jimfcarroll4 жыл бұрын

    Best macro ever: #define private public

  • @brilletjuh2

    @brilletjuh2

    4 жыл бұрын

    even better: #define public private

  • @brilletjuh2

    @brilletjuh2

    4 жыл бұрын

    @@djordjermus4082 or why can't i access this function, is it clearly public?

  • @rauldragu9447

    @rauldragu9447

    4 жыл бұрын

    cease, demon

  • @aperson4051

    @aperson4051

    4 жыл бұрын

    This is actually very handy at the right times

  • @unstableslayer9662

    @unstableslayer9662

    4 жыл бұрын

    #define protect delete Now all your variables are safe

  • @easyaspi31415
    @easyaspi314153 жыл бұрын

    TL;DW: The C++ community's failing attempts to erase the C from C++.

  • @sodiboo

    @sodiboo

    3 жыл бұрын

    just start from scratch lmao

  • @easyaspi31415

    @easyaspi31415

    3 жыл бұрын

    Why Scratch? Can you even call that a programming language?

  • @easyaspi31415

    @easyaspi31415

    3 жыл бұрын

    @k je Au contraire. #include #include int main(void) { int c = 'c'; int cplusplus = c++; if (c == cplusplus) { puts("See? I told ya!"); return 0; } else { puts("Clearly this compiler is broken); abort(); } }

  • @easyaspi31415

    @easyaspi31415

    3 жыл бұрын

    @k je what are you talking about? That was C++ I wrote. It just happens to be perfectly valid C by coincidence.

  • @easyaspi31415

    @easyaspi31415

    3 жыл бұрын

    @@sodiboo I can't believe this guy is serious

  • @NXTangl
    @NXTangl3 жыл бұрын

    "The most heinous and evil forms of C++ ever known" So, like...literally any production C++ for a video game?

  • @billgatest7563

    @billgatest7563

    3 жыл бұрын

    This comment reminds me of the fast inverse square root

  • @metagen77

    @metagen77

    3 жыл бұрын

    Whats wrong with games and c++

  • @itap8880

    @itap8880

    3 жыл бұрын

    @@metagen77 Well... I don't know either.

  • @regeneric928

    @regeneric928

    3 жыл бұрын

    @@billgatest7563 That was done back in the 90s. In modern times leave the thinking to the compiler and just use sqrt() and others, it'll handle it much better than most of the programmers.

  • @danielesquivel3155

    @danielesquivel3155

    3 жыл бұрын

    el que explique no es gey

  • @addvert_br0009
    @addvert_br00094 жыл бұрын

    2 minutes in and i just want a whole series like this.

  • @javidx9

    @javidx9

    4 жыл бұрын

    lol, If im kept at home any longer, that may happen XD

  • @addvert_br0009

    @addvert_br0009

    4 жыл бұрын

    @@javidx9 that would be perfect

  • @gregfletcher2360

    @gregfletcher2360

    4 жыл бұрын

    Yes, please!

  • @dickheadrecs

    @dickheadrecs

    4 жыл бұрын

    here here

  • @DerKaktusAvant

    @DerKaktusAvant

    4 жыл бұрын

    @@javidx9 well the lockdown is here sooo

  • @SelyHaudy
    @SelyHaudy4 жыл бұрын

    the c++ dark side "box" is actually very bright when opened

  • @thescreemregular5168

    @thescreemregular5168

    4 жыл бұрын

    🤔?Coincidence?🤔, I Think Not

  • @natoisnazi

    @natoisnazi

    4 жыл бұрын

    White IDE

  • @Cyberspine

    @Cyberspine

    4 жыл бұрын

    it's called the dark side because once you gaze into the box, everything will become dark

  • @garrusarchangel4562

    @garrusarchangel4562

    4 жыл бұрын

    There should have been red light like in Hell :))

  • @The_Pikaboi

    @The_Pikaboi

    3 жыл бұрын

    its all made in light mode IDE

  • @Gastell0
    @Gastell03 жыл бұрын

    "Eventually I will consume all of the memory in my system" - Wait, it isn't the goal?

  • @petergamache5368

    @petergamache5368

    3 жыл бұрын

    You're thinking of Java.

  • @Gastell0

    @Gastell0

    3 жыл бұрын

    @@petergamache5368 Java is just easiest of them all to get there xD

  • @patrickgono6043

    @patrickgono6043

    3 жыл бұрын

    100% memory speedrun

  • @Gastell0

    @Gastell0

    3 жыл бұрын

    @@patrickgono6043 Now that sounds like a worthy challenge!

  • @C_Corpze
    @C_Corpze3 жыл бұрын

    This seems very interesting, you actually cover the bad and good usecases for methods as well, I love that.

  • @Nytra_
    @Nytra_4 жыл бұрын

    As a programmer who is quite inexperienced with C++, this was an extremely informative and easy-to-understand video. I'll definitely be coming back to your channel in the future. Thank you. :)

  • @chosesomething

    @chosesomething

    3 жыл бұрын

    @Marcelo Rocha Any more you may know of ? Please put them here :)

  • @Hyrtsi

    @Hyrtsi

    3 жыл бұрын

    Oh my. There's a lot of weird c legacy in cpp. And all of these 'evil' tools are still tools after all. One just should use them correctly. This is the most difficult thing in programming. I remember my first year - I came across all these and the situations where they are a pain and the ones where they are the best

  • @clarissagun5581

    @clarissagun5581

    3 жыл бұрын

    As a programmer who is quite inexperienced with C++, this was an extremely informative and easy-to-understand video. I'll definitely be coming back to your channel in the future. Thank you. :)

  • @garthor
    @garthor3 жыл бұрын

    You can also put your "using namespace" inside a function I believe, which is even better than leaving it outside in the global space, because it goes out of context when the function ends rather than when the file ends... =D

  • @BernardBernouli
    @BernardBernouli3 жыл бұрын

    Void* brings up bad memories for me. In one of my classes we had to finish programs to implement various algorithms, but the person who wrote the pre-written parts loved to use void*, even when the type was very clear and essentially always the same. This lead to all kinds of casting problems.

  • @acasualviewer5861

    @acasualviewer5861

    Жыл бұрын

    void* was typically used in C programs because they lacked OO features. C++ introduced better ways to do the same.

  • @frans.8906
    @frans.89064 жыл бұрын

    I actually laughed at the redefinition of "true" to a probability of being true. Nice video!!

  • @kalesantosh

    @kalesantosh

    4 жыл бұрын

    +1

  • @Damaniel3

    @Damaniel3

    4 жыл бұрын

    That was the first time in this video that I actually said out loud 'now *that* is evil'!

  • @MrCh0o

    @MrCh0o

    4 жыл бұрын

    I assume this... gift will work on anyone who decides to blindly trust and include your code into their program? This could result in a catastrophic hair loss

  • @inigo8740

    @inigo8740

    4 жыл бұрын

    @@MrCh0o seems like an awfully evil way to enforce good habits, I love it

  • @yowie7169

    @yowie7169

    4 жыл бұрын

    @@fabricatorzayac lmao

  • @GrandHighGamer
    @GrandHighGamer4 жыл бұрын

    My takeaway from the beginning of this is that the briefcase in Pulp Fiction actually contained a void pointer.

  • @gabrielmansano
    @gabrielmansano3 жыл бұрын

    22:05 "I'm impressed, well done you've made this far, not many people have a stomach like you" me with a confused face watching the video understanding like only 20% of those cursed techniques

  • @MrHatoi
    @MrHatoi4 жыл бұрын

    1:20 POV: You are just regaining consciousness after having been kidnapped by javidx9 and being taken to his dungeon

  • @mohammade.8770
    @mohammade.87704 жыл бұрын

    1:23 is where the iconic "Hello" strikes.

  • @javidx9

    @javidx9

    4 жыл бұрын

    iconic eh? XD

  • @sebastianschneider9383

    @sebastianschneider9383

    4 жыл бұрын

    Mohammad E. It’s just what I thought. His “Hello” is so iconic. xD

  • @rickjohnson1719

    @rickjohnson1719

    4 жыл бұрын

    Thanks, thats what im here for

  • @z0mbiebanana9891
    @z0mbiebanana98914 жыл бұрын

    Remember in my first year of uni I was learning C++, my first proper programming language, and for my first assignment I filled my program with goto's nearly everywhere where I could have used a while loop. 1 week before submission I showed my progress to my teacher and he ripped me a new one. I learned quick that day, a goto is a no go xD.

  • @WorBlux

    @WorBlux

    4 жыл бұрын

    The assembly produced would be almost identical. The sanity of the next person to touch your code... not so much.

  • @alphaforce6998

    @alphaforce6998

    4 жыл бұрын

    What they never teach you in any college is that the stuff you are taught won't translate to marketable skills. People who can't learn programming on their own just by doing it with self-motivation will likely end up doing customer service or tech support... but hey, look at that degree. Makes them feel special!

  • @magnuscoles5010

    @magnuscoles5010

    4 жыл бұрын

    @@alphaforce6998 I'm learning c in my first year of uni, the exams are in a month, and I still don't know how to properly program in c, I have finished watching several toturials and still I can't seem to grasp it, what I'm I doing wrong?

  • @MultiTrickster121

    @MultiTrickster121

    4 жыл бұрын

    @@magnuscoles5010 if you want to learn c++ have a look at The Cherno's KZread channel. He has a whole playlist of great c++ tutorials

  • @derrickmelton5844

    @derrickmelton5844

    4 жыл бұрын

    @@alphaforce6998 idk I learned C++ from the ground up all on my own and it hasn't helped me land a job...the reasons are all self inflicted like a lack of confidence to apply places, worry that i don't have the qualifications needed, etc...so a degree is the confidence boost some individuals need, not to mention it helps you make connections to get your foot in the door somewhere.

  • @iMCOCOarmy
    @iMCOCOarmy4 жыл бұрын

    define int float; define true (98% of the times) lmao I died laughing so hard

  • @OskarAriaAttar
    @OskarAriaAttar3 жыл бұрын

    After years of programming, I think this video made me finally fully understand the static tag. Your explanations are really clear and concise

  • @trolleyproblem4318
    @trolleyproblem43184 жыл бұрын

    Bjarne is clear: There are only two kinds of languages: the ones people complain about and the ones nobody uses.

  • @ccgb92

    @ccgb92

    4 жыл бұрын

    Ritchie > Bjarne

  • @frydac

    @frydac

    4 жыл бұрын

    Ritchie and Bjarne sat at the same lunchtable for 16 years or so (Bjarne said in some interview), and Bjarne is a big contributor to C and thinks C is a great language (why else would he take it as a basis). While this is no argument against the '>', it would indicate they probably have very similar views on things.

  • @sea-ferring

    @sea-ferring

    3 жыл бұрын

    @@ccgb92 troll

  • @ccgb92

    @ccgb92

    3 жыл бұрын

    @@sea-ferring Ritchie > Bjarne easily. If it wasn't for Ritchie's C, C++ wouldn't even exist.

  • @mvisperas

    @mvisperas

    3 жыл бұрын

    I wonder if Ritchie's keyboard is broken. Why he used * for pointers instead of @ just like in Assembly? It's much more intuitive to use @.

  • @pako_powr
    @pako_powr4 жыл бұрын

    The Halloween special we never knew we wanted..

  • @swiatek7

    @swiatek7

    4 жыл бұрын

    MindSpyke we surely did need one though.

  • @Kaltinril

    @Kaltinril

    4 жыл бұрын

    Exactly!

  • @solaireofastora5212

    @solaireofastora5212

    3 жыл бұрын

    Hello there.

  • @gameprogramme
    @gameprogramme3 жыл бұрын

    Professional software engineer with 20+ years experience here (a good portion of that in C++). As others have already said, this is an excellent video for any C++ developer of any experience level. I especially like how you show both problematic and acceptable uses (or alternatives) for each of these techniques. I did feel you made ONE MAJOR OMISSION in your discussion of new and delete, and I mention it because you have yourself such a great opportunity discuss it, before side-stepping the issue, and jumping straight to the “correct” solution. I really wish you would have covered how exceptions interact with new and delete, because that is where I see many developers get into trouble. The more obvious case would be where a thrown exception prevents a delete from being called, would have been a great place to start. The more subtle situation (and the primary reason for make_unique() to exist) is an exception thrown within a constructor. These leaks can be particularly tricky to track down. Again, thanks for the great video.

  • @JG-og3qy
    @JG-og3qy3 жыл бұрын

    Great work, Javid! Nice clear explanations, concise, well-spoken.

  • @MichaelRichardson-bw5xh
    @MichaelRichardson-bw5xh4 жыл бұрын

    2 minutes in and it's already the best thing I've seen all week.

  • @javidx9

    @javidx9

    4 жыл бұрын

    Thanks Michael!

  • @MichaelRichardson-bw5xh

    @MichaelRichardson-bw5xh

    4 жыл бұрын

    @@javidx9 my friend, thank you. I've been programming for 20+ years and watch every one of your videos. They are all fantastic and I have suggested them to anyone that mentions to me that they're interested in learning programming. I think the knowledge you're providing is enough to change life trajectories for people out there if they're looking to learn and better themselves.

  • @erykaemilien77
    @erykaemilien774 жыл бұрын

    You explained dynamic memory and the use of "new" and "delete" in a few seconds than an hour and a half Comp sci lecture. 😮

  • @ytltqsoft

    @ytltqsoft

    4 жыл бұрын

    std::audio developer: Making an audio adapter work as expected is very difficult bla bla bla. game programmer: just give me this and everyone will be happy: std::audio_source::play();

  • @EmilParkour

    @EmilParkour

    4 жыл бұрын

    Error: expected a 'better', instead you typed 'in'.

  • @CottidaeSEA

    @CottidaeSEA

    4 жыл бұрын

    @@EmilParkour I think your compiler has a bug. That's not where the error is located.

  • @Stoney3K

    @Stoney3K

    4 жыл бұрын

    "You don't own your memory, the operating system does." Well,. the receipt I got here from the computer shop tells me otherwise, SO I"M NOT GONNA DELETE.

  • @xybersurfer

    @xybersurfer

    3 жыл бұрын

    i don't think that's completely fair. without the CS lecture, this probably wouldn't be so easy to you

  • @andreyzolotykh9005
    @andreyzolotykh90059 ай бұрын

    This is one of the best C++ video tutorials I've ever seen. Clear and accessible presentation, special effects and artistic dramatization. Absolutely super! Thank you!

  • @felixmerz6229
    @felixmerz62293 жыл бұрын

    Favourite programming video right here, thanks a lot. Also got me in the Halloween mood that is quickly approaching!

  • @THExRISER
    @THExRISER4 жыл бұрын

    12:38 Ah yes,Goto, I'm glad I stopped using it early when I started learning to code, thanks of course to all those C++ Discord users who would completely neglect the problem I was asking about and start pestering me about why I used a Goto as opposed to a while/for loop while simultaneously spamming pepelaugh emotes all over the place, classic! They were right though, even though I was still writing simple programs at the time, simply replacing Goto with some loop did solve the problem in some cases,so to any C++ Discord users present here, you guys are dicks, but also thank you!

  • @CottidaeSEA

    @CottidaeSEA

    4 жыл бұрын

    Yeah, a GOTO loop is the same as a while loop, but the while loop is easier to recognize due to the encapsulation and naming. It's not like GOTO is necessarily bad, but it does introduce unnecessary complexity. I actually quite like GOTO, but it should be used carefully.

  • @garychap8384

    @garychap8384

    4 жыл бұрын

    goto's are never strictly necessary. Usually they're a sign of very sloppy thinking. I've used them, rarely, in some driver code where the alternative would have been far less readable. But only EVER forwards to simplify complex logic ending in common wrap-up code. The backwards goto, on the other hand, is truly evil and I've never seen a valid case for it. Any time you feel the need to use a goto... you should wrestle with the decision. If it doesn't cause you, at the very least, a sleepless night or a re-factor... then you've really not thought it through properly ; ) Using goto is something you need to agonise over and try to make peace with.

  • @DFX2KX

    @DFX2KX

    4 жыл бұрын

    @@garychap8384 there *might* be the fringe case in working with a system that has VERY little RAM to work with (such as an Arduino), but I'm not a good enough programmer that I can use GOTOs any better then the compiler would.

  • @Bistai949

    @Bistai949

    3 жыл бұрын

    Funnily enough, I didn't even know GOTOs were supported by C++. I assume it's a holdover from C because object oriented languages were still relatively new at the time C was developed. It gave me a good chuckle, and reminded me of my Assembly class in college.

  • @THExRISER

    @THExRISER

    3 жыл бұрын

    @@Bistai949 Yeah I sometimes forget how old C/C++ actually is.

  • @englishmotherfucker1058
    @englishmotherfucker10584 жыл бұрын

    I didn't know about goto, seems useful.

  • @javidx9

    @javidx9

    4 жыл бұрын

    XD What have I done??!!

  • @Invalid571

    @Invalid571

    4 жыл бұрын

    @@javidx9 You've opened the gates of bug hell. XD

  • @MrEdrftgyuji

    @MrEdrftgyuji

    4 жыл бұрын

    The Linux kernel runs off of goto

  • @EngineeringVignettes

    @EngineeringVignettes

    4 жыл бұрын

    @TBit - Nope, use a do { ... } while (false); and in the 'guts' (...) use break; to drop out of the loop when you need to. As it is false, it will never loop more than once. Behold the "DDW" (Doug's Do-while) (never mind the name... long story) Cheers,

  • @hqqns

    @hqqns

    4 жыл бұрын

    goto is from "c"

  • @simaesthesia
    @simaesthesia4 жыл бұрын

    Absolutely marvellous! I love the humorous approach to what are very real issues.

  • @KG4JYS
    @KG4JYS3 жыл бұрын

    Thank you for the suggestions. I will try to use these techniques in all my code going forward!

  • @cpu_UP
    @cpu_UP4 жыл бұрын

    Woe to you, on Earth and Sea. From the devil sends the beast with wrath, because he knows you will use global variables.

  • @kevinhansson2177
    @kevinhansson21774 жыл бұрын

    That epic, scary... (Also well done) intro. That lead into... the... "Oh, Hello!" XD

  • @sonnenhafen5499

    @sonnenhafen5499

    4 жыл бұрын

    spoiler alert

  • @kevinhansson2177

    @kevinhansson2177

    4 жыл бұрын

    @@sonnenhafen5499 oh, sorry :(

  • @sonnenhafen5499

    @sonnenhafen5499

    4 жыл бұрын

    @@kevinhansson2177 no problem haha, but this was really inavoidable since yours was the top comment at the time and the only thing visible as comment preview in the app xD i really needed to get this off my heart

  • @kevinhansson2177

    @kevinhansson2177

    4 жыл бұрын

    @@sonnenhafen5499 LMAO XD That's acctually kinda funny. Still sorry btw :)

  • @doublegdog
    @doublegdog3 жыл бұрын

    Love your videos man! I think you are the best youtube programming channel. You actually provide useful information and tell it how it is.

  • @BalancedEarth
    @BalancedEarth3 жыл бұрын

    Very cheeky to see this in my recommended a few days before Halloween. Very cool video though and has so much good production for a video any old youtuber would have just made a run of the mill top ten list with minimal detail. I approve!

  • @oracleoftroy
    @oracleoftroy4 жыл бұрын

    Me while watching the video: Err, I don't think _inline_ works that way. You: The meaning of inline has changed over the years... Me: better double check before embarrassing myself with a snarky comment. C++17: Make Inline Great Again Me: Neato! I learned something new today!

  • @shukterhousejive

    @shukterhousejive

    4 жыл бұрын

    After seeing how you use the goddamn bit shift operator to write to stdout I thought I'd stop being surprised by how C++ mangles its own syntax, but here we are!

  • @kneesnap1041

    @kneesnap1041

    4 жыл бұрын

    @@shukterhousejive Same. C++ is probably the most bizarre language evolution I've seen.

  • @tetsuoiiii

    @tetsuoiiii

    4 жыл бұрын

    @@kneesnap1041 more like de-volution

  • @kneesnap1041

    @kneesnap1041

    4 жыл бұрын

    @@tetsuoiiii lmao I'm with you there.

  • @oracleoftroy

    @oracleoftroy

    4 жыл бұрын

    @Michael Deloatch Yeah, it's a great change. I'm not sure why others are using my post to hate on C++, it keeps getting better and better.

  • @whynotanyting
    @whynotanyting4 жыл бұрын

    Him: "I commend you for making it this far." Me, not fully understanding it: "Thanks."

  • @brianhourigan
    @brianhourigan4 жыл бұрын

    After years of dicking around with Python with an inane fear of C++ I have started to delve into C++ and my god am I learning so much from this channel!

  • @derekmont
    @derekmont3 жыл бұрын

    This is just such good content. You have truly changed my way of looking at progamming. Thank you.

  • @nerdudi5745
    @nerdudi57454 жыл бұрын

    When my professor told us that we should never use global variables, someone asked why. He said that global variables are evil and didn’t explain any further. Thank you for sharing the dark bits of C++ and explaining them, I finally know what not to do

  • @alphaforce6998

    @alphaforce6998

    4 жыл бұрын

    Sounds like a bad/lazy teacher and you probably paid too much to have him not teach you anything.

  • @michaeldegans1354

    @michaeldegans1354

    4 жыл бұрын

    Because it's harder to test is one good reason. Units needs to be isolated to behave predictably. Applies in any programming language. He should have given reasons like this however.

  • @edgeeffect

    @edgeeffect

    4 жыл бұрын

    If your professor couldn't or wouldn't tell you why, they shouldn't be teaching.

  • @alexandrubragari1537

    @alexandrubragari1537

    4 жыл бұрын

    I remember my professor starded explaining when a friend of him wich liked to use global variables fked up a whole program (it was a big project imo, like scientific research) for a redefinition of a global variable on some file and they had to debug for 3 days and lost a huge time and money due to that e evil behavour

  • @absurdengineering

    @absurdengineering

    3 жыл бұрын

    Isn’t it clear, though? Imagine I had a light switch in my bathroom that controlled the light in your bathroom. That’s the first thing that should come to mind when you look at the concept of a global variable! Good luck figuring out the switch is in my house :) Of course today we have IDEs that let you find all uses of a variable at a press of a key combo, but you also need to be paranoid enough to think of inspecting that variable. And any “protocols” people agree to with respect to globals always break down.

  • @natevb9901
    @natevb99014 жыл бұрын

    I got a _"Tales from the Crypt"_ jive there at the end and at times throughout. This could totally become a new series worth accumulating some "horror stories" for sharing over time. As always, thanks for sharing!

  • @cowviolater
    @cowviolater4 жыл бұрын

    I like the change of pace, I see you changing up your production style javid, sick video!

  • @lmttn
    @lmttn4 жыл бұрын

    Standard namespace was taught to us week one in my Intro to Programming I class. I changed majors after two semesters so I had no idea it was so contentious.

  • @azaria_phd

    @azaria_phd

    2 жыл бұрын

    std namespace is obviously great. The "using namespace std" statement is the evil thing.

  • @johnjackson9767
    @johnjackson97674 жыл бұрын

    I think you've got another hit series on your hands. Can totally extend this to other languages as well.

  • @utf-238e8
    @utf-238e84 жыл бұрын

    That's one hell of an intro

  • @marcovalentinoalvarado3290
    @marcovalentinoalvarado32903 жыл бұрын

    system("pause"); you should talk about exploitation some day, i really want to hear you talking about such a beautiful topic

  • @numbdigger9552

    @numbdigger9552

    3 жыл бұрын

    i use that all the time...

  • 3 жыл бұрын

    @@numbdigger9552 Here is why you shouldn't: Imagine someone making a program called "pause" (which, apart from just pausing, also executes some malicious code) and put it in the same directory as your program. Or even worse, in any directory that is in the path environment variable. In other words, when you use system(some_program) you have no control over what some_program does, and what it does could be different on different systems. Obviously, when you're just writing an example program for yourself, there is no harm in it, you're executing it on a system where you have control over any program, including pause. Just keep in mind that in production code, this can create security vulnerabilities.

  • @numbdigger9552

    @numbdigger9552

    3 жыл бұрын

    @ well since i have no plans in publishing anything, it is not a concern

  • @SerBallister

    @SerBallister

    2 жыл бұрын

    @ If you had access to a machine where you could replace pause in such a way then your program is already running on a compromised system. What would stop someone replacing a shared DLL you app uses ? You wouldn't need system("pause"); for trigger for that.

  • @zcryptxzz
    @zcryptxzz3 жыл бұрын

    I'd just like to say I learned a lot from this video. Very informative, thank you!

  • @MatthijsvanDuin
    @MatthijsvanDuin4 жыл бұрын

    8:55 The double-evaluation issue aside, that macro declaration is also missing parentheses around each occurrence of a parameter in the macro body :P

  • @SirRebonack

    @SirRebonack

    4 жыл бұрын

    Yes! I thought he was going to mention it. This can really screw you over when using macros.

  • @Stoney3K

    @Stoney3K

    4 жыл бұрын

    You can do some really evil things with arithmetic operators in those macros and just completely jumble up the order of operations.

  • @xybersurfer

    @xybersurfer

    3 жыл бұрын

    yeah. i thought it was going to be an operator precedence issue

  • @daishi5571
    @daishi55714 жыл бұрын

    10 print "This is a test" 20 goto 10 I believe this was the 1st program I wrote.

  • @manuell3505

    @manuell3505

    3 жыл бұрын

    You had to do a mkdir x and chdir x in between to reach the fat16 directory nest limit.

  • @frankstern5270

    @frankstern5270

    3 жыл бұрын

    Pretty sure it was gw basic

  • @abj9121

    @abj9121

    3 жыл бұрын

    @@frankstern5270 To me too but it does not run though.. 😷

  • @billkeithchannel

    @billkeithchannel

    3 жыл бұрын

    HELLO WORLD! HELLO WORLD! HELLO WORLD! HELLO WORLD! HELLO WORLD! HELLO WORLD! HELLO WORLD!

  • @Nikarus2370

    @Nikarus2370

    3 жыл бұрын

    Honestly. Having started out using basic on one of those old "kids computers" that they had in the 90s that could run basic... I pulled a lot of aggro from my college C++ professor for using gotos here and there.

  • @darriusbeleiu1377
    @darriusbeleiu13773 жыл бұрын

    The voiceover at the beginning of this was downright impressive!!

  • @josephmay1255
    @josephmay12553 жыл бұрын

    loved this whole video but i especially love that little comment you have about system("pause"). When i took my first c++ course, our instructor did not explain at first that we would need this. This was the first language I ever used so Imagine the dejection i felt when i couldn't even get a hello world program to run properly (as far as I knew) because I didn't have system(pause)

  • @giladreich810
    @giladreich8104 жыл бұрын

    Thanks for the video! It was fun watching and you made it really entertaining! :) I specifically liked the "goto" use-case. I personally never had the need to use it by now, but I think there is a good reason why they kept it in the language. Although many programmers tend to have really extrem negative opinions about it, behind the scene when everything is compiled and translated into assembly, there are goto/jump instructions in our program all over the place.

  • @javidx9

    @javidx9

    4 жыл бұрын

    Thats right Gilad, to the CPU & Memory, everything is global, and the JUMP is everywhere in programs... Its just us strange humans that require limitations in order to understand things XD

  • @PetrPss

    @PetrPss

    4 жыл бұрын

    @@javidx9 It reminds me some video about genetic algorithms. There was simulation in which 100 objects roam some field, eat "food" and attack each other to survive. And after certain time top 10 of them provide code for next generation (with slight random gene mutations). Genes of the objects were program instructions by which they "live" (32 or 64 operators, I don't remember). First generation gene programs of the objects were random. And after thousands of generations if you look at those programs all you can see is enirely undecipherable goto-gibberish. But this objects moved to the "food" in quite short paths, attacked other weak objects and survived till end of the simulation. Just based on their strange unreadable gene programs. Makes you think about how our brains work.

  • @michaelmahn4373
    @michaelmahn43734 жыл бұрын

    "It's quite a modern one:" *pause video, try to guess* "New & Delete" XD

  • @cezarcatalin1406

    @cezarcatalin1406

    3 жыл бұрын

    Modern... is ancient computer history still deemed modern ? I mean, phenom processors aren’t considered “modern”.

  • @joshlovesfood
    @joshlovesfood3 жыл бұрын

    Great video! Great approach to teaching C++, I am enjoying!

  • @mrbrown6421
    @mrbrown64213 жыл бұрын

    Thanks for the flashback! After college (1984), my first 10 years were spent on embedded systems in which we wrote assembler and did not have any underlying Operating System. I thought in terms of hardware and memory. I somehow managed to sustain employment in C++, but I never felt comfortable with it, and now....I repair small engines. Abandoned the software engineering career with glee!

  • @RyanVasquez6089
    @RyanVasquez60894 жыл бұрын

    This is great! As someone who writes firmware in C++, this is always great to sharpen my skills. I'm primarily an electronics engineer though....most electronics need good code to run!

  • @DFX2KX

    @DFX2KX

    4 жыл бұрын

    darn right they do. Part of what made Ardunio into Arduino was the firmware that made it less daunting.

  • @GingerGames
    @GingerGames4 жыл бұрын

    The criticism for why global variables are bad is not inherent to global variables and only really a concern for beginners. Yes global state has a lot issues but the concept is not inherently bad and extremely useful in many problem domains (e.g. games are a good example since there is a lot of shared state). Some people may prefer passing the global state around everywhere, but sometimes that is much more cumbersome than before. It may be wise to tell a beginner to C++ (or C) to try to not to use global variables if possible, but they should not be forbidden. Macros are not a replacement for templates, and macros are fine when you are trying to add functionality which templates cannot do. C-style macros are unhygienic and can cause issues because of this, but they are not inherently bad. For beginners, they should be used with a lot of caution and the user of them must know the issues with them. This wisdom comes with experience. The statement that "`goto` will, not might, cause spaghetti code" is only true for beginners. There are perfectly valid use cases for them in C++ which produces _cleaner_ code than not using them. This is because of C++'s lack of structured features, such as named scopes for the ability to break out of parent control structures or defer/scope-exit (the latter of which can be implemented quite easily). `void *` is fine, and the complaint main is that `void` is not typed, which is the entire point of `void`. `std::any` is pure evil in C++ (because C++'s RTTI is dreadful). The example to replace `void *` with `std::any` is actually much more bug prone than before because if a pointer is passed rather than the value, the value of the pointer will be written rather than the value that the pointer is pointing to. And that use of `std::any` is incorrect. I completely agree that `using namespace std;` is evil and I would actually go further and say `using namespace` is evil in C++ always. P.S. If people like C++ style namespaces, they should keep to one level deep any way because heavily nested namespaces do not aid in readability, refactoring, organisation, and more. `new` and `delete` are bad but not for the reasons stated, which is just a complaint about _manual memory management_. (P.S. Placement `new` is good if you like constructors). `std::unique_ptr` is not a replacement for `new` with automatic memory management; brings along a new concept called "ownership/move semantics". They are __not__ the same as reference counted pointers, nor an alternative. C++ is not meant to be an automatic memory managed language, please don't try to treat it like one. This is does not mean you should try to use loads of small and manual memory allocations but rather keep the allocations to a subsystem, and let that handle it if necessary.

  • @brkr78

    @brkr78

    4 жыл бұрын

    Ad global variables: If you have a single threaded application then you can, with care and a lot of shifting around of that gray mass in your head anticipate in what state a specific variable is at any given time. In debugging you can stop and then backtrack how you got there. But once you start writing multithreaded code all bets are off. Using global variables in concurrent code is just suicide. Ad macros: Macros are a two-sided sword. On the one hand they can be very powerfull when used correctly. At the same time that is the reason why they are dangerous. As long as you write programs for yourself and keep track of what you are doing ... more power to you. But beginning with a certain size of project those macros tend to throw off people if they have to maintain the code somewhere down the line. Ad goto: What you are saying kind of echoes what has been said in the video. There are SOME edge-cases where goto might make sense. But only then. If you start to code C++ with gotos like you code good old BASIC-code then you will run into spaghetti code. Ad void* : The usage of void* is, IMHO, nowadays realy limited. Or at least it should be. The problem is that it is sometimes used in ways that are ingenious when first implemented but nigh impossible for anyone else to maintain afterwards. I agree that std::any isn't the be all end all and that you have to be just as carefull. However, pointer to pointer logic is IMHO slowly disappearing in favor for structured types. Ad namespaces: There are instances where additional levels of namespaces make sense. It kind of depends on the size of the project. But I have to agree that it also tends to get out of hand pretty quickly, and suddenly you have a three or four layer deep namespace. Ad memory management: Not much to add there, except maybe: He's using MS C++, and that actually CAN be written with both manual and automatic memory management. And again - concurrent programming and memory management are a whole different can of worms. I'd like to say it all boils down to preference, but that is not quite true. It realy depends on whether the company you write code for has coding guidelines to which one has to adhere, be it as a freelancer or as an employee. Even in large OSS-projects you usually can't do whatever you want - at least if it is managed properly. If there is a code review and those guidlines are in place then you need a realy good reason why you should be allowed to circumvent them. And then you need to document it. It might look like harassment, but it usually is something needed to keep the code maintainable. I speak from experience. The team I'm part of is currently tasked with reimplementing old legacy code. The oldest programs are 20 years old, the newest about 5. It's a hodgepodge of styles, of techniques, of proficiency in the language, and nothing is documented. At first we thought we might be able to salvage at least parts of the code, but alas, it 'grew organicaly', meaning that one functionality got expanded by plopping a wrapper around it and then doing semi-rand stuff with it. There is no spearation between data-, business- and presentation-layer. The underlying database breaks every form of normalization in every conceivable way, the primary keys are all over the place, the naming of ... anything realy ... is inconsistent and half of the stored procedures are using indices instead of names which leads to some ... intresting issues. On the other hand we have SQL-queries within what could be considered the presentation layer if you realy want to strain you imagination. It is pure chaos. No documentation. Only very, very sparse lines of comments that usually do not help at all with trying to explain what was inteded to happen in wherever they are found. But on the other hand there are methods that are thousands of lines long. And somtimes there are pages upon pages of code that had been commented out. Variable names are random and more often than not have nothing to do with whatever value is stored in them. Hell, we have an application where the buttons are called "Button1" to "ButtonXX", the methods are literally called "function_1(int a, string b, SomeClass* c)" to "function_XX(char a, int b, void* c)", the variables are really called "a, b, c, d ... aa, ab, ac ...", half of them are literally names. Like "Jake", "Thomas", or "Martin". I'm not joking. I whish I were. The source code repository is contaminated with dead files, dead data, dead cache data, random shit and a boatload of features and images no one ever uses anywhere. Checking out the full repository takes an eternety as there are 250.000 files checked in - most of which are trash. At first we thought we might be able to untangle that mess, but we pretty soon gave up on that idea and started to re-implement everything. Every now and then we still have to put on our gloves and dig through that pile of dung - when we have to apply absolutely necessary bugfixes or when we are not 100% sure on how a specific feature had been implemented. It's always something that takes way too long for what is gained from it. The reason it got so bad was because the ones who came before us had free reign, they were spitting out features fast and everybody did whatever the f'k he wanted. Mind you, some of them were seasoned developers, but that didn't stop them from creating that monstrosity. Now every one of them has moved on to greener pastures, and we are left with their legacy. When I came on board they had been gone for over a year and my current teamleader had put the current guidlines in place. Yeah, we are not as fast when we start a project, as we need to set up a lot of shit for later, but once everything had been set up changes can be made rapidly, bugfixes usually take half an hour at most, the code is reviewed so everyone is on the same page and the guidelines are upheld and we document our code.

  • @suokkos

    @suokkos

    4 жыл бұрын

    @@brkr78 I have used global variables with threads is easy if you can make them std::atomic. But I still would prefer not to use globals unless it is clearly the easiest solution for problem. But even in this case it is likely global variable makes more sense as static member variable because it is often related to the class implementation. But multithreaded globals are quite a lot more restricted than single threaded globals because order of execution is chaotic in many cases.

  • @kered13

    @kered13

    3 жыл бұрын

    std::any does not use RTTI. It actually uses a very clever type-erasure trick: It instantiates a function template for the type that you construct it with, then stores a function pointer to that instantiation. That function can be invoked to get information it needs about the stored type, like how to cast it back.

  • @GingerGames

    @GingerGames

    3 жыл бұрын

    @@kered13 That is a form of RTTI. It might not be the same as the "normal" C++ RTTI with dynamic_cast, but it is still RTTI. A "clever" "trick" but insane.

  • @kered13

    @kered13

    3 жыл бұрын

    @@GingerGames It works with RTTI disabled, it doesn't use the RTTI and any of it's drawbacks at all. In fact the only drawback it has is requiring a dynamic memory allocation to store the actual object. It's hardly "insane".

  • @AirforcLuckyThirteen
    @AirforcLuckyThirteen4 жыл бұрын

    You are a really swell fellow, the video is informative and newbie friendly, I'm happy to subscribe :)

  • @frovis7426
    @frovis74263 жыл бұрын

    Thank you so much, new sub. Trying to learn c++ and you are really good at explaining the program. :)

  • @chbrules
    @chbrules4 жыл бұрын

    I stopped programming in C++ almost a decade ago. Since I'm stuck in self quarantine until god knows when, I may as well pick up programming again and have fun. This was a great video, and it made me remember a lot of C++ I learned back in the day.

  • @syfp4769
    @syfp47694 жыл бұрын

    Templates would also be a good alternative to void* in that example.

  • @ccgb92

    @ccgb92

    4 жыл бұрын

    eww

  • @deepdark8192

    @deepdark8192

    4 жыл бұрын

    Depends. Once I did a vector that could receive any variable. For instance: the first element could be an int, and the second one a double. I'm almost sure that you can't do something like that with Templates.

  • @syfp4769

    @syfp4769

    4 жыл бұрын

    @@deepdark8192 Vectors are implemented with templates.

  • @deepdark8192

    @deepdark8192

    4 жыл бұрын

    @@syfp4769 I did my own vector. From scratch. I don't think you can receive different variable types in the same vector when you use the std::vector.

  • @syfp4769

    @syfp4769

    4 жыл бұрын

    @@deepdark8192 I don't know the context you wanted that for, but that sounds like it belongs in the box of forbidden C++. I think a cleaner solution would be defining a union of the values/types you might want, and making a std::vector of that union.

  • @koalawombatkangaroo
    @koalawombatkangaroo3 жыл бұрын

    This looked like sooooo much fun to make! I'm getting some "The Mighty Boosh" vibes from this too!

  • @Khantia
    @Khantia3 жыл бұрын

    1:04 The dark side of C++ was surprisingly bright! However, this video was extremely helpful for someone rather new to the language (and programming in general). I didn't know about the "any" cast, as well as the macros (#define). And I finally understood what namespaces are and how/why they're used. I haven't had the need to use global variables yet (outside my "main.cpp"), as my projects are still quite small, and are more on the "experimentation" stage, but I'm certain that it will be helpful in the future. I've actually been using the void* to research how variables are saved into memory, by reading byte by byte the address of the variable through its size. However, this video gave me insight on how to do what I'm trying to achieve (and the reason I've been trying to figure out how are different variable types saved in memory)

  • @jimmyking92
    @jimmyking924 жыл бұрын

    I'm a newbie in programming (I picked C++ to learn how to code because of my masochistic tendencies) and at least I understood exactly why I shouldn't (for now) do the things you mentioned and not just "aim for best practices/build good habits". You explain everything clearly without being tiring, I understand everything even though English is my second language.

  • @javidx9

    @javidx9

    4 жыл бұрын

    Thanks and that's encouraging to hear Drop Down, Good luck with your study!

  • @eyadhisham8094

    @eyadhisham8094

    4 жыл бұрын

    well, i think it's very important to follow an updated tutorial on c++ because it will be extremely damaging to follow an outdated one. cause C++ has changed A LOT

  • @jimmyking92

    @jimmyking92

    4 жыл бұрын

    @@eyadhisham8094 I follow the lesson schedule on a site called learncpp dot com, it looks updated but I can't really tell since I'm a newbie. If you have any updated book I could look use I would be grateful, I prefer having a book in front of me while at the same time compiling code on my PC rather than following video tutorials, which most of them don't go in detail.

  • @MrCh0o

    @MrCh0o

    4 жыл бұрын

    ​@@jimmyking92 It's just an online reference site and I only ever learned C, but en.cppreference.com seems to be a pretty exhaustive source on various language features while also mentioning language versions that introduced them. It does provide a nice level of detail for everything C-related, but I can't vouch for C++ side myself. The best thing is that you can find info on just the feature you're interested in without having to sift through a load of extra info. Hope you may find it useful.

  • @jimmyking92

    @jimmyking92

    4 жыл бұрын

    @@MrCh0o Thanks for your insight.

  • @amortalbeing
    @amortalbeing4 жыл бұрын

    Great talk. I enjoyed every seconds of it :) great great job :) by the way you forgot to point out that void* is also very handy when it comes to creating wrappers in C that can then be used in other languages (creating DLLs to be used by other languages for example)!

  • @ale-lx9gp
    @ale-lx9gp4 жыл бұрын

    This is an incredible video! Thank you so much!

  • @andrewcekuta8627
    @andrewcekuta86273 жыл бұрын

    fun video. definitely helpful in rounding out C++ fundamentals. good stuff

  • @metroid031993
    @metroid0319934 жыл бұрын

    javidx9: "I hope this hasn't given you any nightmares" also javidx9: *the intro*

  • @beskamir5977
    @beskamir59774 жыл бұрын

    These "don't" videos are awesome. I learned not to use "using namespace std" the hard way when I was first learning C++ in an intro to computer graphics course. Aside from transformation functions from the glm library clashing with my own functions (ie rotate(), scale(), etc), I think I also had an issue where I couldn't make a mathematical vector type cause it conflicted with std::vector. All in all, fun times!

  • @alphaforce6998

    @alphaforce6998

    4 жыл бұрын

    So you blame the namespace feature instead of your inability to do something simple like prefixing your with "myfunc_" or the like to avoid collisions? Real men of genius here... smh

  • @groszak1

    @groszak1

    3 жыл бұрын

    So you couldn't make your own vector because it conflicted with the standard vector

  • @beskamir5977

    @beskamir5977

    3 жыл бұрын

    @@alphaforce6998 it was my first time using c++... I was a noob. Plus I would have prefered a normal name instead of myVector. I've never been fond of the my naming convention.

  • @alphaforce6998

    @alphaforce6998

    3 жыл бұрын

    @@beskamir5977 It was just an example. You can prefix the namespace however you want to. When I use namespaces I treat it like a subdirectory and name the functions/code accordingly... and in general a depth of 1 has been more than sufficient for me..

  • @coolbrotherf127
    @coolbrotherf1273 жыл бұрын

    This is really cool, as a student, I've been taught a lot of the older ways of programming by older professors. I didn't even know of the newer ways of handling memory allocation. I've just been using the new and delete.

  • @xemuth1643
    @xemuth16434 жыл бұрын

    Thanks for this video, it was very interresting !

  • @emonymph6911
    @emonymph69113 жыл бұрын

    HAHAHA that intro... forbidden code from the 1980s... how terrifying! You earned a sub for scaring the shit out of me.

  • @kalebbruwer
    @kalebbruwer3 жыл бұрын

    void* pointers are great for dealing with unknown data, like when you need to write data to TCP sockets.

  • @thetinyurlguy

    @thetinyurlguy

    3 жыл бұрын

    I think that is what my MUD used them for since that was all TCP based.

  • @noop9k

    @noop9k

    3 жыл бұрын

    void* actually provides some safety because it is explicitly a pointer to unknown type. You can’t increment/decrement/subtract/add/index/dereference until you cast it to another type.

  • @azaria_phd

    @azaria_phd

    2 жыл бұрын

    Indeed. He himself gives an example with the function he wrote. A function that writes bytes to a file, it only cares where the bytes start and how many of them there are. The function will never interact with the data so it doesn't need to ask for its type.

  • @abstractspaces8186

    @abstractspaces8186

    2 жыл бұрын

    @@azaria_phd Although there is danger in requiring the caller to pass in the size correctly and trust they don't cause an overflow. If you knew the type you'd also inherently know the size, I'd definitely use a template in that example.

  • @jbird4478

    @jbird4478

    Жыл бұрын

    @@abstractspaces8186 Using a template would result in duplicate code for every type you use it for. What you'd really want to do is use both: a template that does nothing but call the function that takes a void* and pass the correct size.

  • @edwinmartens509
    @edwinmartens5094 жыл бұрын

    Working @ home I had a good laugh at this, then shared it with my collegues... I bet some can learn something from it :D

  • @michaeledwardharris
    @michaeledwardharris Жыл бұрын

    That was really good! Very informative and interesting.

  • @MuradBeybalaev
    @MuradBeybalaev4 жыл бұрын

    "I've never experienced a problem with this approach myself." Well then, it must be evil!

  • @ghollisjr
    @ghollisjr3 жыл бұрын

    "This type here makes no sense at all" [Quake inverse square root flashbacks commence]

  • @user-sl7ie9te5r

    @user-sl7ie9te5r

    2 жыл бұрын

    Evil bit hack

  • @IndellableHatesHandles

    @IndellableHatesHandles

    2 жыл бұрын

    @@user-sl7ie9te5r What the f***?

  • @ryosaebafr2000
    @ryosaebafr20003 жыл бұрын

    Thanks a lot for this very well explained video Clear examples, clear explanations... i wish i had a teacher in programming langage that had your pedagogy :) well done sir :) Approved

  • @benjaminlum5894
    @benjaminlum58943 жыл бұрын

    this "dark side" of C++ is so unholy, that not even 2 crosses could contain it

  • @seankayll9017
    @seankayll90174 жыл бұрын

    Very useful vid, thanks. That "mostly true" macro is priceless.

  • @mokopa
    @mokopa4 жыл бұрын

    It's stuff like this where Stroustrup's personality actually shines through. His character is somewhat woven into the language, and through this, he will live as long as C++ and its descendants are around.

  • @RolandNSI
    @RolandNSI4 жыл бұрын

    I had to switch programming language from assembly / c ( with some c++ every now and then ) to c#.... and .net I really miss the "dark side" that made things so easy and straightforward !

  • @amooseinaroom1228
    @amooseinaroom12282 жыл бұрын

    great job on demystifying programming!

  • @arnaudparan1419
    @arnaudparan14193 жыл бұрын

    void* is clearly something which was very useful in C where you wouldn't have templates. Like for example, implementing collections without templates implies using void pointers, but that would lead you to typing the collection in the name of the variable in a comment or somewhere to have to cope with the lack of typing in your collection. It's a kind of nice and bad feature at the same time. I didn't know about any type though, that's a great functionnality!

  • @DoorThief
    @DoorThief4 жыл бұрын

    Ahh GOTO. I remember that back in my Windows Batch scripting days.

  • @Those2menoverthere

    @Those2menoverthere

    4 жыл бұрын

    Yep, (6 years ago) in highschool, what a time for me. :) When you had nothing better to do in your shitty ass computer-based classes. Bypassing all their stupid registry restrictions and such. Batch scripts were the way to go.

  • @lynnlo

    @lynnlo

    4 жыл бұрын

    @@Those2menoverthere First you're dabbling in VBS then you're doing full on batch.

  • @tech6hutch

    @tech6hutch

    3 жыл бұрын

    God, me too. I cringe at the thought of the spaghetti my code must have been.

  • @mingusog7036
    @mingusog70364 жыл бұрын

    My Comp Sci professor taught us to use using namespace std, even with multiple files and headers, and never told us about the determent's. I had always heard it was bad practice but never understood why until this video. Very useful information

  • @williamsli3745
    @williamsli37453 жыл бұрын

    I just start learning C++. And I love you!

Келесі