Why I don't "using namespace std"

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • Follow me here! ► / thecherno
    Patreon ► / thecherno
    Twitter ► / thecherno
    Discord ► thecherno.com/discord
    Series Playlist ► thecherno.com/cpp
    Thank you to the following Patreon supporters:
    - Dominic Pace
    - Kevin Gregory Agwaze
    - Sébastien Bervoets
    - Tobias Humig
    - Peter Siegmund
    - Kerem Demirer
    Gear I use:
    -----------------
    BEST laptop for programming! ► geni.us/pakTES
    My FAVOURITE keyboard for programming! ► geni.us/zNhB
    FAVOURITE monitors for programming! ► geni.us/Ig6KBq
    MAIN Camera ► geni.us/t6xyDRO
    MAIN Lens ► geni.us/xGoDWT
    Second Camera ► geni.us/CYUQ
    Microphone ► geni.us/wqO6g7K

Komentáře • 1K

  • @TheCherno
    @TheCherno  Před 6 lety +392

    Finally got around to answering this question, hope you guys enjoyed the video!
    What's the biggest issue you've had because someone stuck a using namespace somewhere?

    • @MiaWinter98
      @MiaWinter98 Před 6 lety +21

      First time i learned c++ the tutorial i watched the guy "using namespace std" and other namespaces, so i assumed it is ok. Couple of hours later, i actually added something like that in a header file, didnt mind. A bit later, everything broke. Needles to say i stopped doing this.

    • @thepdg5160
      @thepdg5160 Před 6 lety +5

      Tron I restrained from using it in a global scope, but I still use it in a local scope, because I don't see problems with that personally. But everyone has their own religion here.

    • @AJMansfield1
      @AJMansfield1 Před 6 lety +16

      In my algorithms class, the test runner that was supplied to the class had `using namespace std;` in the global scope in one of its header files, and as a result when I did the quicksort assignment I discovered minutes before the assignment was due that I'd actually been calling std::sort for everything when I'd been testing it earlier, rather than the function I'd written. Fortunately my sort function worked perfectly once I fixed that but it really could've been bad.

    • @ssjim826
      @ssjim826 Před 6 lety +7

      Im glad someone is finally addressing this. I've been helping people program in C++ for the last 5-6 years , and the one thing i notice is people always tend to use namespace std. There arent many tutorials that actually tell people not to use it because it could cause a lot of bloat. Ive actually was working with someone on a game, and it literally screwed with my custom vector class as well as custom map class.

    • @connorhorman
      @connorhorman Před 6 lety

      I write a C++ program and broke every. Worst part is that I couldn't trace the issue at all and had to actually look on StackOverflow to realize that it was because of using namespace std.

  • @roshiron1816
    @roshiron1816 Před 3 lety +870

    When he says "never ever, EVER, use namespace in a header file" you can see the culmination of several hours of debugging agony in his eyes.

    • @n000d13s
      @n000d13s Před 2 lety +30

      Thats solid advice. I can feel it.

    • @AviPars
      @AviPars Před 2 lety +18

      My college does all the time lol

    • @biqbicle4982
      @biqbicle4982 Před rokem

      @@AviPars ur college should be in hell rn tbh

    • @spaghettiking653
      @spaghettiking653 Před 8 měsíci +1

      Zooming into those eyes and flashing through a thousand memories from 2am would've been a masterful edit for sure.

  • @paul70079
    @paul70079 Před 6 lety +1980

    There a guys who start their video with an ad. And there is cherno, who shows how to make coffee in slowmo instead

    • @will8090
      @will8090 Před 6 lety +18

      Excuse me , but obviously his name is "A Jenner" according to (closed caption).Better to use subtitle options (CC button over there).

    • @ITR
      @ITR Před 6 lety +37

      As someone who has never before heard about this channel, I was very confused

    • @michaelsherwin4449
      @michaelsherwin4449 Před 6 lety +8

      I just want a list of ingredients that he puts in his latte. I want to talk that fast and type that fast and recall all the language details that fast. It must be the latte because something is giving him superhuman brain function!

    • @michaelsherwin4449
      @michaelsherwin4449 Před 6 lety +5

      Also I suggest that Cherno puts a few drops of his latte in the cactus plant every video. I suspect that the cactus will grow to be 6ft tall and form ears, eyes and a mouth and have an IQ of about 200. My IQ measured by Mensa is 145 but it could sure use a boost! lol

    • @batabatonica
      @batabatonica Před 6 lety

      ward

  • @h.hristov
    @h.hristov Před 6 lety +565

    “Never EVER use ‘using namespace’ in a header file. “ Noted.

    • @worsethanjoerogan8061
      @worsethanjoerogan8061 Před 6 lety +48

      Learned this the hard way

    • @JoseGonzalez-rt5fk
      @JoseGonzalez-rt5fk Před 6 lety +16

      You can if you don't use other libraries like he does, it would save you a bit of time. Although, it would raise a bad habit.

    • @huyvole9724
      @huyvole9724 Před 5 lety +2

      If you in contest about Algorithm (like ACM ICPC, ...) then you should use "using namespace std", else you shouldn't use it.

    • @nextlifeonearth
      @nextlifeonearth Před 5 lety +15

      @@JoseGonzalez-rt5fk You can if you know for an absolute fact that the software will never be developed upon again after version 1. If it's for a customer; don't, you don't know what they're going to do in the future.
      If it's for your company; don't, you'll be the one that has to deal with it later because they wanted to use that one feature you need a lib for.
      If it's a personal project you might open source some day, also don't.
      Like there are very few cases where you could, but probably still shouldn't.

    • @bestopinion9257
      @bestopinion9257 Před 4 lety

      Ok, but did you understand why?

  • @ScaramangaG
    @ScaramangaG Před 6 lety +1301

    You don't have to bring the entire std namespace. I mostly use:
    using std::cout;
    using std::endl;

    • @sandeepr7141
      @sandeepr7141 Před 5 lety +134

      and using std:cin;

    • @PoojaDeshpande84
      @PoojaDeshpande84 Před 5 lety +349

      lol didnt even know I could do that...
      new to c++

    • @DarkLevis
      @DarkLevis Před 5 lety +81

      You probably shouldn't use std::endl much at all

    • @zeyode
      @zeyode Před 5 lety +36

      @@DarkLevis I mean, if you're just outputting variables or something, it's easier than typing '
      '. What's wrong with endl?

    • @DarkLevis
      @DarkLevis Před 5 lety +83

      @@zeyode nothing horribly wrong just it calls std::flush after '
      ' which is often not intended.

  • @yonikeshet8691
    @yonikeshet8691 Před 6 lety +1230

    You know that you can write "using namespcae std" instead of writing std::, it will make a lot of the examples in this video clearer to read and understand.

    • @AmeshaSpentaArmaiti
      @AmeshaSpentaArmaiti Před 6 lety +32

      but the using keyword is so situational it's not really worth it. It also becomes much less clear if you "using" more than one namespace.
      ...that was a pretty clunky sentence.

    • @kristupasantanavicius9093
      @kristupasantanavicius9093 Před 6 lety +32

      The only thing that you get by "using namespace std" are broken code samples which you have to go over and add std:: everywhere after you pasted the code.

    • @farberbrodsky
      @farberbrodsky Před 6 lety +134

      It was a joke xD

    • @useraccout1635
      @useraccout1635 Před 6 lety +26

      That's not true. Any experienced c++ developer is completely familiar with anything inside the std namespace. The problem is with people (like he mentioned in the video) who try to replicate the STL and give it the exact names as the original. Yeah, that's gonna fuck everything up. There is absolutely no reason to std:: everywhere when you know what's what. All it does is unnecessarily bloat code. I'm not say don't not use it, but don't exaggerate it's limited consequences, which when they do arise, are easily solvable with any decent IDE.

    • @skaruts
      @skaruts Před 6 lety +21

      I use condoms. So there.

  • @LucidStew
    @LucidStew Před 6 lety +282

    The reason this question gets asked a lot is because programming courses don't want to have to explain scope and scope resolution early on, and once they do, using namespace std is so ingrained they don't bother undoing it.

    • @VictorOrdu
      @VictorOrdu Před 5 lety +12

      Great observation!

    • @HonsHon
      @HonsHon Před 4 lety +18

      That shit happened to me when I started lol

    • @obinator9065
      @obinator9065 Před 2 lety +5

      My teacher didn’t even know about unique scope name resolution lol. They’re too caught up in C World.

    • @nurtaytulegenov7431
      @nurtaytulegenov7431 Před 2 lety +9

      True, it's same also in universities with fields not related to the programming directly. Like we have C++ course on our first year on mechanical engineering, and we were told write using_namespace as mandatory and never got explained what it actually is, because we always used to work with console output, never used more than 2 extensive libraries (vector and cmath) and nor wrote more than 800 lines of code. Thanks to the Cherno I've learned not to do it

    • @tye3630
      @tye3630 Před rokem +3

      Thankfully my teacher explained why using namespace std is not good on the second day of the class. Even though most of us don’t understand what he’s talking about at that time.

  • @MrBLARG85
    @MrBLARG85 Před 5 lety +55

    “Remove all the STDs.”

  • @will8090
    @will8090 Před 6 lety +68

    Why I don't "using namespace std"
    "latte art could use a bit of work but really hits the spot"
    -TheCherno

    • @zBMatt
      @zBMatt Před 4 lety

      Will read your comment while he said that.

  • @zemlidrakona2915
    @zemlidrakona2915 Před 5 lety +334

    I'm kind of an old timer. Been programming since '81. I've even programmed on a computer with real magnetic core memory. You could open the box up and see each bit.......no joke..... In any case, you're one of the few CZcams programmers I like. Keep up the good work.....

    • @mattizzle81
      @mattizzle81 Před 4 lety +24

      Wow, I first played with QBASIC, Assembly, etc in 1993 and I thought those were the old days. Lol. Makes me feel young. ;)

    • @_lapys
      @_lapys Před 4 lety +22

      I envy y'all early programmers. You had it cooler back then

    • @rakinrahman890
      @rakinrahman890 Před 4 lety +28

      @@_lapys ikr, people that time had less resources to learn from, i respect old programmers, they r rly hardworking

    • @shohamziner
      @shohamziner Před 3 lety +1

      wow...
      would you say that programming was easier (or at least simpler) back then when the machines were less complicated and things were less abstract?

    • @TheZenytram
      @TheZenytram Před 3 lety

      are you guys insane, today any 9 years old can download a radom App (for him) a radon tutorial on the internet and star programming on the get go, and in a couple of weeks he already know how to do lots of simples algorithms.
      back them you literally need to have electronics degree to understand whatever the fuck that maching were doing or else everything would break.

  • @jrcowboy1099
    @jrcowboy1099 Před 6 lety +866

    longest. intro. ever.

  • @pako_powr
    @pako_powr Před 6 lety +341

    Now we all know where the Patreon money is going towards lmao.

    • @Guztav1337
      @Guztav1337 Před 4 lety +15

      Probably his EA money to be fair

    • @anona1443
      @anona1443 Před 4 lety +16

      Going to Costa Rica cofee plantations

    • @Badcannon
      @Badcannon Před 3 lety +2

      Making good content ?

  • @mitchellcampbell2775
    @mitchellcampbell2775 Před 3 lety +35

    Dude! Your videos are highly appreciated. I'm a CS student and I find your "real world" perspective on things to be extremely helpful.

  • @sunkuz
    @sunkuz Před 6 lety +18

    "What you may have noticed at the beginning of this video"
    You making coffee?

  • @SamTanXYZ
    @SamTanXYZ Před 6 lety +118

    I'll sneak into your codebase and add "#define eastl:: std::"

    • @kylecox5127
      @kylecox5127 Před 4 lety +53

      You're like hitler, but even hitler cared about Germany or something

    • @luizandre12345
      @luizandre12345 Před 4 lety +1

      @@kylecox5127 lol

    • @maybe_raj
      @maybe_raj Před 4 lety +4

      Then suddenly all EA games will become free and slower xD
      (IDK if that makes sense or not. all I am saying is EAAAAAA = PAYYY and stdlib = slow lib!!)

    • @MultiTrickster121
      @MultiTrickster121 Před 4 lety +2

      @@kylecox5127 Lol nice reference

    • @johneltins9822
      @johneltins9822 Před 3 lety

      monster :0

  • @guywithknife
    @guywithknife Před 4 lety +22

    I’ve been programming for 20 years and based on this experience, I always explicitly namespace (well, typically aliasing it, if its longer than one word), in every language I use (C++, Clojure, Rust, Python and Java). The reason is that this way I always know where a symbol is coming from, at a glance. It lowers my cognitive overhead, which speeds me up and helps me make fewer mistakes. Nevermind name clashes, clarity is more important. In the case of std, I also like to know if something is from the standard library (or other “core to my codebase” libraries like glm) or if its from my own codebase. I find knowing where something comes from cleaner than never knowing where something is declared, without thinking or checking.
    Also: “vector vector;” vs “std::vector vector;” 😛

    • @liam8398
      @liam8398 Před rokem

      tbh rust does it pretty well by letting the user to pick which symbols they want to merge into the current scope. `use std::{cout, endl, vector, function}`;

    • @delta3244
      @delta3244 Před 15 dny

      ​@@liam8398C++ has using std::cout; too, it only lacks that neat {grouping} syntax

  • @mkmabdelkawy
    @mkmabdelkawy Před 5 lety +12

    We are in 2019 and your series still rocking. Your high quality videos and all the many advice you give are invaluable, because it is coming from years of practical experience in this industry. Keep up the good work.

  • @Aqsa792
    @Aqsa792 Před 6 lety +23

    I dont know the basics of C++, I have zero programming knowledge and yet I understood what you were trying to tell. My mind is blown away by how great you are at teaching/explaining stuff to others!
    BEFORE ANYONE ASKS: I accidentally saved this video in my Watch Later and I was confused how/why it was there so I decided to check it(trying to figure out why i saved it) and then I was mesmerized by Cherno's excellent slow-mo coffee making and I just decided to stick till the end and wow I learned something great today.

    • @din3lka
      @din3lka Před rokem +3

      CZcams is a strange place

  • @denislobov8248
    @denislobov8248 Před 3 lety +2

    That intro was one of the most cleanest, beautiful things I have ever seen. Well done, man!

  • @almondhete3623
    @almondhete3623 Před 6 lety +138

    Sorry, I have a question. Why don't you use namespace std?

    • @luisponce3580
      @luisponce3580 Před 6 lety +34

      Yeah, and also, what programming ide is this?

    • @valiok9880
      @valiok9880 Před 6 lety +3

      Visual studio 2017

    • @jjbailey01
      @jjbailey01 Před 6 lety +5

      Technically he does use namespace std. He details this in the video. He does so by explicitly declaring it each and every time he makes a call from std. What he doesn't do is obfuscate the use of namespaces by calling "using namespace std;" which is essentially the lazy way of doing so and can easily make it difficult to remember which function is being called from which namespace.

    • @sandeepr7141
      @sandeepr7141 Před 6 lety +2

      Nice name tho...

    • @almondhete3623
      @almondhete3623 Před 6 lety +2

      Thanks a lot.

  • @Day13May
    @Day13May Před 5 lety +6

    That intro was oddly mesmerizing

  • @LameDuckStudios
    @LameDuckStudios Před 3 lety +11

    I was like: "GASP!" when he waved the mug around the laptop!

    • @dionyzus2909
      @dionyzus2909 Před 2 lety

      someone here has ptsd because of accidents with coffee. I understand you perfectly :p

    • @LameDuckStudios
      @LameDuckStudios Před 2 lety

      @@dionyzus2909 My dad spilled a drink on his laptop keyboard. it was instantly dead.

  • @rissandimo
    @rissandimo Před 6 lety +10

    Great job, I loved this video, it was very informative! I always try to follow best practices and I've been programming in C++ for about a month now. I am going to take your advice.

    • @theshedman
      @theshedman Před 4 lety

      The same with me too. Very new to C++ (3 wks now). I like this very channel. Already learning a lot. A big thanks to @TheCherno for his great job.

  • @IgnoreSolutions
    @IgnoreSolutions Před 6 lety +47

    wtf man the last time i watched you it was you talking over visual studio now you out here being a videography pro

  • @petarsmilajkov9431
    @petarsmilajkov9431 Před 6 lety +6

    Lol, love it... more and more of Peter McKinnon :) Keep it going!

  • @tedleahy8075
    @tedleahy8075 Před 6 lety +7

    Really good, interesting video. I've only recently started learning C++ so this was something I've never even thought about. But why on earth do you think people who've clicked on a programming video would want to watch 2 minutes of you making a coffee first??

  • @abhijeetjain04
    @abhijeetjain04 Před 6 lety

    I was waiting for this video from quite some time and now wait is over. Really good video !!!. Thanks

  • @EpochIsEpic
    @EpochIsEpic Před 4 lety +2

    Thanks for the tip on the header. I haven’t experienced any issues because of that but I can see how that would be disastrous in a group setting

  • @meanmole3212
    @meanmole3212 Před 6 lety +68

    Is that a coffee or a milkshake?

    • @jjbailey01
      @jjbailey01 Před 6 lety +13

      mean mole It is a latte. Basically a fancy steamed coffee milkshake.

    • @xeekk
      @xeekk Před 6 lety +7

      Hard to call it a milkshake when it's not cold or made with icecream. It's simply a cafe latte, espresso + steamed milk.

    • @nallid7357
      @nallid7357 Před 4 lety +3

      @@warrick_lo Very brave.

  • @errorlooo8124
    @errorlooo8124 Před 6 lety +10

    I know you probably know this but i just wanted to leave this out here because you can say "using std::(function name/ class name);" (ex. "using std::cout;"), i think this is better because you are just saying exactly what you want and it's easier because now if you want to for ex. to use another function from a namespace called "cout" you can actually see that there is already a "using std::cout;" so for this case i think that it is better plus you can actually see what functions/classes you are using from std(any namespace), again just becuase it's the best of both worlds dosen't mean you must use it, i just find it easier and better this way, and the rest is basically the same as Cherno, just wanted to say this, as he did not cover this.

  • @NinaTheLudaca
    @NinaTheLudaca Před 6 lety +1

    These intros are the cherry on top of the cream on top of the cake. Beautiful content in every sense.

  • @itsnotallrainbowsandunicor1505

    At least he knows the important of a good espresso before anything is said.

  • @MrWazzup987
    @MrWazzup987 Před 6 lety +4

    What I was always told was it ok to use in main and no where else but I think I might stop doing even that

  • @nekopushyo
    @nekopushyo Před 4 lety +8

    I thought I accidentally clicked on video about coffee

  • @atuljain2845
    @atuljain2845 Před 5 lety

    Very nicely explained. And other than that video editing and intro section was also nice.
    Thank You.

  • @jorgemartin9258
    @jorgemartin9258 Před 4 lety

    Thanks for the video! It’s very interesting.
    I agree with you.
    Could your please provide the IDE that your are using for c++ development? I am now using Vscode, but I see that your IDE provides more information when debuging a program. Thanks!

  • @cantcode1001
    @cantcode1001 Před 6 lety +12

    First two minutes of the video == using namespace std;

  • @joey546
    @joey546 Před 6 lety +46

    I think the better question is why does EA have their own Standard library?

    • @Grougal
      @Grougal Před 6 lety +37

      The std library is often not really fit to use in low level engine programming because you need performance, thread safety, memory leak safety etc. pp.
      Creating your own std library that mimics the actual std library but is better for your purposes ist quite common actually.

    • @PoojaDeshpande84
      @PoojaDeshpande84 Před 5 lety +25

      they need to hide the code where they fleece the customers with dumb dlc

    • @raenastra
      @raenastra Před 4 lety +3

      ​@@PoojaDeshpande84 The EASTL is publicly available on GitHub, and code that handles DLC wouldn't be defined there. I get that you're trying to knock EA here, but at least say something that makes sense.

    • @Sparky579
      @Sparky579 Před měsícem

      Bc Std::vector is not very well optimised

  • @splits8999
    @splits8999 Před rokem +2

    this video starts with 2 minutes of making coffee

  • @codysing8291
    @codysing8291 Před 6 lety +2

    there are plenty of new programmer channels now, but yours is still my favourite number one, bc the others just brag about how great their life as software engineers is, while you offer valuable interesting content.

  • @memakesillything9491
    @memakesillything9491 Před 2 lety +8

    I'm newer to C++ and have thus far been using namespace std. I recognize the reasons why it isn't optimal to use it, however my rationale is that I want to get a hang of the syntax and function library before worrying about namespaces in general. It probably is about time to make the switch before my programs get too complex to keep track, though.

    • @memakesillything9491
      @memakesillything9491 Před 2 lety +1

      I wanted to add the addendum to this comment that I have since stopped using namespace std in my programs. It took about a week before it felt natural. For reference I'm usually coding about 30 minutes a day. It was worth switching, but I am glad I used it for my first few weeks of coding in C++. Stopping helped to develop a better understanding of scope, which becomes more important as your programs become more complex.

    • @laveeshtomar
      @laveeshtomar Před 2 lety +2

      I am also new to C++ , and searching for people to join me on discord to build a small community to share knowledge and help newbies.

    • @memakesillything9491
      @memakesillything9491 Před 2 lety +1

      @@laveeshtomar I am interested in talking to other aspiring programmers. Feel free to post the discord link when it's up!

  • @davidmalinowski6331
    @davidmalinowski6331 Před 2 lety +3

    That is a good argument. Makes me think twice about using it.
    That being said, it will be an extremely long time if ever before I need to worry about massive files. No more namespace.

  • @krisitak
    @krisitak Před 6 lety

    Another great video. Never looked at it that way! Thank you!

  • @HakanSULUNtequila
    @HakanSULUNtequila Před 6 lety

    So, is it ok to use using in my own library code's cpp file? Say if I have arraylist.h and it defines a class in namespace DataStructures, in arraylist.cpp can I use using namespace DataStructures to avoid putting it in front of every member definition? Is it a bad practice as well?

  • @TheYahmez
    @TheYahmez Před 4 lety +4

    Hold on!
    ..I need to watch this with a coffee. Brb.

  • @MsJavaWolf
    @MsJavaWolf Před 5 lety +3

    I really like having complete knowledge and control over my types. Yes in theory if I don't import any other stl like classes I will know what I am working with, but I want to see it explicitly, and I also want to see it explicitly in 6 months. I also don't use auto much.
    I guess this also comes down to what you work on and your role in the team. I do a lot of reverse engineering and often think about actual individual bits of data. I am often also the guy that they call when something "should work but it doesn't" and it's always some small detail like a bug in a private method. Abstraction and short code are great, but some of us have to dive into the ugly details so making everything explicit became a habit of mine.

  • @AndyChamberlainMusic
    @AndyChamberlainMusic Před 4 lety +2

    I thought it was going to be about slowing the program down to begin with given the extremely long intro
    but what he actually said makes much more sense

  • @frosty7674
    @frosty7674 Před 2 lety +1

    I am watching this at morning and the intro... I didn't had a coffee

  • @Andy4Tune
    @Andy4Tune Před 3 lety +6

    Well there it is, one of the examples what separates good coders with lousy ones.

  • @GRHmedia
    @GRHmedia Před 3 lety +3

    Good to see someone has basically the same view I do when it comes to name spaces.
    I'd probably used vector as an example you have std::vector and then you can have math and graphic libraries with vectors which are entirely different in nature.
    When I first stared using C++ the std wasn't near as good as it is now. It was pretty easy to write better performing code on your own. So people very often created their own versions of what was in std.
    99.9% of the time I don't use it. The times I do it is usually something short that is being made and I probably just had the default code system create a console project and was to lazy to delete it to simply show someone else how something works. For large projects I never use it.

  • @sayoojmandodi1172
    @sayoojmandodi1172 Před 4 lety

    adorable intro and as always your explanation made it more easier to understand :) ; Enjoyed it ;

  • @YoungMetroid
    @YoungMetroid Před 6 lety +1

    Whats the song used in the intro?

  • @SlideRSB
    @SlideRSB Před 4 lety +8

    I've been programming in C++ since before namespaces existed . Using "using namespace std" was something I latched onto pretty quickly when namespaces first became a thing and it hasn't ever confused me before, nor has it ever confused anyone working with my code. I guess it's just a matter of style.
    So my question is, when you are using functions from eastl, are you also using functions from std simultaneously? You mentioned that eastl is an API replacement for std, so I would expect one would only use one without the other.

  • @gage2560
    @gage2560 Před 6 lety +69

    that intro tho

  • @jousboxx9532
    @jousboxx9532 Před 6 lety

    The intro honestly adds so much to the video even though it has nothing to do with namespaces.

  • @thekidphi
    @thekidphi Před 6 lety

    Thanks for the very good explanation. Should I use type alias in the header file? Unreal Engine 4 coding standard suggests these types...
    using FString = std::string;
    using FText = std::string;
    using int32 = int;

  • @brand1210
    @brand1210 Před 5 lety +13

    Interesting. It's like the fact that I prefer to code in my native language (french) so I don't mix my functions (in french) and more general functions (in english).

  • @derpmarine216
    @derpmarine216 Před 5 lety +9

    Then there’s Rust.
    #[macro_use] // I think that’s the syntax.
    extern crate clap;
    use clap::*; // oof.

    • @froge8121
      @froge8121 Před 4 lety

      Derp Marine i think if you have clap in your Cargo.toml then you only have to:
      use clap::*;

  • @harshitatailor334
    @harshitatailor334 Před 4 lety

    You should post more these type of concept videos ,i was about to go to bed and after watching this well my sleep is been chased away .It was good and thank u

  • @madhatter5361
    @madhatter5361 Před 5 lety

    Very interesting, but I'm kind of curious, how often is it for programmers to use different namespaces? Would you happen to have a video on that?

  • @koungmeng
    @koungmeng Před 5 lety +4

    6:36 i laughed so hard

  • @jannikkoch4944
    @jannikkoch4944 Před 6 lety +28

    I'm a simple man, I get a youtube notification when Cherno uploaded a new video, I hit like.

    • @Psychedique
      @Psychedique Před 6 lety +7

      You are so simple, you can't even come up with an original comment.

  • @igorgiuseppe1862
    @igorgiuseppe1862 Před 4 lety

    good video, i dont know how to code in c/c++, but looks like this is usefull to figure out what dependences you really used and what you can strip out from your code, right?

  • @msidc1238
    @msidc1238 Před 3 lety +2

    Awesome. learned how to make coffee too.

  • @ThePhinista
    @ThePhinista Před 6 lety +11

    Nice intro but WHY SO MUCH CREAM

    • @rban123
      @rban123 Před 4 lety

      because it's a latte

  • @alexkiecker4175
    @alexkiecker4175 Před 6 lety +8

    Myself and most professionals don't because of name conflicts

  • @herooyyy
    @herooyyy Před 6 lety

    Is there a special reason for using reference by parameter when not going to change the value of that parameter? Like on apple::print() he passes text by reference, but he is not going to change it, he is just gonna cout. Should I always pass by reference even when not changing directly the values?

  • @pmvanker
    @pmvanker Před 4 lety

    i agree with the you. let make habit to avoid usinge for (stadand namespace) . its ok for own namesapce. using namespace xyz (ok), :) ty. can you tell your wrist watch brand?

  • @arielespindola1867
    @arielespindola1867 Před 3 lety +5

    Using std:: actually makes your code cleaner

    • @SR-er6hx
      @SR-er6hx Před 3 lety

      It's and it prevents sudden headaches!!

    • @insydium7385
      @insydium7385 Před rokem

      Depends you could use it in function context and make a rule that you never use it in global context

  • @MrJ-vs7vr
    @MrJ-vs7vr Před 6 lety +47

    Hey man. There are folks whining about the intro. Don’t listen to them, they are brilliant because you’re not just a robot teaching us code. We want to know you as a person in ways you’ll want us to.
    Heck, throw in some drone footage of yer homeland Australia, We’ll love it.😍
    Soo.. thank you so much, you taught me a lot of good programming practices.
    Cheers

    • @shunshirou
      @shunshirou Před 5 lety +3

      People come here to learn C++. They find a high quality video and class FOR FREE and still complain about seconds of coffee making intro. Those shouldn't be here then.

  • @martincets8334
    @martincets8334 Před 6 lety +1

    Fantastic intro, mate!

  • @moatazemad7070
    @moatazemad7070 Před 4 lety

    Lovely intro
    lovely topic
    and best video
    in the CZcams i have ever seen
    Keep going..(:

  • @slap_my_hand
    @slap_my_hand Před 6 lety +18

    What's the point of the long intro?

    • @shruikan123456789
      @shruikan123456789 Před 6 lety +6

      slap_my_hand porn

    • @alep7358
      @alep7358 Před 6 lety +2

      He probably bought an expensive dslr and doesn't do much with it so he needs to make long intros to justify getting the camera

    • @LucidStew
      @LucidStew Před 6 lety +6

      It's art. Art is the point of art.

    • @789blablajaja
      @789blablajaja Před 5 lety +1

      +slap_my_hand Coffee is like 80% of coding, Its a coding tuturial.

    • @robertmurch7660
      @robertmurch7660 Před 5 lety +2

      Whats the point on asking whats the point of the long intro?

  • @bestopinion9257
    @bestopinion9257 Před 4 lety +6

    using namespace std
    at the top of the program violates the reason why namespaces were added in the language.

  • @joshyoutube8569
    @joshyoutube8569 Před 5 lety

    New to programming, and saw this video and thought if I don't declare namespace at the top, where am I supposed to declare it? is there a list I can refer to?

  • @navaneeth6157
    @navaneeth6157 Před 6 lety +2

    best tutorial on how to make coffee :) and nice cinematics of it.

  • @zeuglcockatrice4633
    @zeuglcockatrice4633 Před 6 lety +7

    people don't like opinions
    Vim is better than Emacs

  • @KaranLobana
    @KaranLobana Před 6 lety +91

    "using namespace std;"
    ahh the mark of an amateur

    • @elvisss
      @elvisss Před 6 lety +1

      Karan Lobana could not agree more

    • @arnerademacker8548
      @arnerademacker8548 Před 6 lety +27

      Heavily disagree. Because like any naming convention, whether “using namespace std;” makes code easier or harder to read depends entirely on your code.
      Just like in actual language, btw. If you were to stick to your guts you’d use punctuation and capitalization. You don’t, because implying proper qualification of your sentences is enough to be understood. Just like implying proper qualification of functions is often enough for code to be understandable.

    • @ChrisLeeW00
      @ChrisLeeW00 Před 6 lety +7

      It’s like the mall grabbing of the coder world.

    • @KaranLobana
      @KaranLobana Před 6 lety +3

      I agree its context dependent. If I were to be showcasing a piece of code on a slideshow, I would use this expression. But for any professional codebase or project, I would never use this. And most would agree with me on this.

    • @carbon13
      @carbon13 Před 6 lety +1

      Ah yes, the mark of code that will never see the light of day :)

  • @digiandy6244
    @digiandy6244 Před 11 měsíci

    Very well explained! Thanks for the tip about using a namespace!

  • @TKcKoucher
    @TKcKoucher Před rokem

    Mate..what a great content! Thx for the explanation!

  • @simondimas838
    @simondimas838 Před 4 lety +5

    Hands down one of the most pointless intro I've ever seen.

    • @martinlarsson8947
      @martinlarsson8947 Před 4 lety

      Simon Dimas no need to be rude. You could express the same sentiment saying something like ”Thanks for the videos. That intro was a bit long and doesn’t really relate to the content. Keep up the gopd work!”
      By the way, I liked it as a one off thing but it would get tiresome if it was in every video.

    • @simondimas838
      @simondimas838 Před 4 lety

      @@martinlarsson8947 Whip anf naenae

  • @steakiefrags1866
    @steakiefrags1866 Před 6 lety +57

    I hate these way too long intros

    • @jdnoidea
      @jdnoidea Před 6 lety +8

      SteakieFrags same, seem pretty pointless for coding vids

    • @charbelsarkis3567
      @charbelsarkis3567 Před 6 lety +4

      Every time i see that i wanna click away from the video.

    • @ToxicityGameDev
      @ToxicityGameDev Před 6 lety +4

      I think his other passion is videography, so be supportive ;-)

    • @Admwings
      @Admwings Před 6 lety +1

      Toxicity Game Dev He would be able to create another channel for that.

    • @ToxicityGameDev
      @ToxicityGameDev Před 6 lety +6

      Or you just don't complain about it and let him do what he wants with his skills / free time, I am sick of people saying "Im here for the this", if you don't like it. Go else where for you C++ videos.... Oh wait, they are all terrible so I guess you can either give him props or complain and watch it anyway lol. Because lets be honest, you are going to watch them anyway...

  • @sandipan17
    @sandipan17 Před 4 lety

    The coffee making part was so delightful

  • @ToxicityGameDev
    @ToxicityGameDev Před 6 lety

    Watched half, didn't even need to finish, I was sold on not using namespace in like video three lol, so I was already convinced before this video. Great work Cherno.

  • @christianjoshua7218
    @christianjoshua7218 Před 2 lety

    This is 2021November, a bit late....but your coffee /latey making procedure is both calming and mesmerizing...good start for a vid!

  • @andersonklein3587
    @andersonklein3587 Před 4 lety

    I was wondering that same question every since I first watched your videos. Yeah, when I first found out "using namespace std" I really thought it was the best thing in the world. But your point is surprisingly compelling. Makes me think that if I ever intended to make a complex code library with more than a handful of classes I should actively try to understand and use namespaces to segregate classes.

  • @exoticcoder5365
    @exoticcoder5365 Před 3 lety +1

    I am laughing so hard on the intro
    Welcome back to my Coffee++ Series, my name is Cherno

  • @fatihcnar3513
    @fatihcnar3513 Před 5 lety

    The idea was explained very well. Thank you :))

  • @PaprikaX33
    @PaprikaX33 Před 6 lety +2

    Why you don't mention using X=std::T;??? or typedef std::T X;??
    It's really useful when you need using overly nested container such as: std::vector

  • @rajanimandlecha8888
    @rajanimandlecha8888 Před 5 lety

    Thanks for clearing the confusion

  • @tmtygnz
    @tmtygnz Před 3 lety

    Hello I am new to C++ (From a different language) what did you use to create the GUI for your Hazel Game Engine

  • @stingray427
    @stingray427 Před 2 lety

    Do you have video about EASTL? And when to use it? Does it provide advantages (still today?) ?
    Or use EASTL always when programming (cache-friendly?) Game or Game Engine ?

  • @R7Rhdev
    @R7Rhdev Před 11 měsíci +2

    Hey, you know you can just using namespace std; and then you don't have to type std everytime

  • @alexanderthornton147
    @alexanderthornton147 Před 5 lety

    wow... imma still use it

  • @samindj
    @samindj Před 5 lety

    i learned by using namespace std, how can i unlearn it? I don't know when i have to do std:: and when not to

  • @someguy2910
    @someguy2910 Před 5 lety +1

    0:10 roflol, is that your daily coffee ration? Reminds me so much of Seattle where the people drink coffee like trucks drink gas.

  • @aurafox1
    @aurafox1 Před 4 lety +2

    You're a better C++ teacher than any of my C++ professors.

  • @andysester7785
    @andysester7785 Před 6 lety

    You've convinced me! Excellent video.

  • @MrBLARG85
    @MrBLARG85 Před 5 lety

    Yeah, I don’t use it for pretty much the same reason:
    - I want to know where the item is coming from.

  • @MohamedKhaled-xe8yp
    @MohamedKhaled-xe8yp Před 6 lety

    can u please make a video explaining what is virtual memory and what is address spaces because that is quite confusing to me and I think I don't understand them well and thanks.