Why I don't "using namespace std"

Поділитися
Вставка
  • Опубліковано 4 сер 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

КОМЕНТАРІ • 1,1 тис.

  • @TheCherno
    @TheCherno  6 років тому +395

    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 6 років тому +22

      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 6 років тому +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 6 років тому +17

      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 6 років тому +8

      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 6 років тому

      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 3 роки тому +890

    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 2 роки тому +31

      Thats solid advice. I can feel it.

    • @AviPars
      @AviPars 2 роки тому +18

      My college does all the time lol

    • @biqbicle4982
      @biqbicle4982 Рік тому

      @@AviPars ur college should be in hell rn tbh

    • @spaghettiking653
      @spaghettiking653 9 місяців тому +2

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

  • @paul70079
    @paul70079 6 років тому +1996

    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 6 років тому +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 6 років тому +37

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

    • @michaelsherwin4449
      @michaelsherwin4449 6 років тому +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 6 років тому +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 6 років тому

      ward

  • @h.hristov
    @h.hristov 6 років тому +571

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

    • @worsethanjoerogan8061
      @worsethanjoerogan8061 6 років тому +48

      Learned this the hard way

    • @JoseGonzalez-rt5fk
      @JoseGonzalez-rt5fk 6 років тому +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 5 років тому +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 5 років тому +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 4 роки тому

      Ok, but did you understand why?

  • @yonikeshet8691
    @yonikeshet8691 6 років тому +1237

    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 6 років тому +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 6 років тому +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 6 років тому +135

      It was a joke xD

    • @useraccout1635
      @useraccout1635 6 років тому +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 6 років тому +21

      I use condoms. So there.

  • @ScaramangaG
    @ScaramangaG 6 років тому +1306

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

    • @sandeepr7141
      @sandeepr7141 6 років тому +134

      and using std:cin;

    • @PoojaDeshpande84
      @PoojaDeshpande84 5 років тому +350

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

    • @DarkLevis
      @DarkLevis 5 років тому +81

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

    • @zeyode
      @zeyode 5 років тому +37

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

    • @DarkLevis
      @DarkLevis 5 років тому +83

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

  • @LucidStew
    @LucidStew 6 років тому +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 5 років тому +12

      Great observation!

    • @HonsHon
      @HonsHon 4 роки тому +18

      That shit happened to me when I started lol

    • @obinator9065
      @obinator9065 3 роки тому +5

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

    • @nurtaytulegenov7431
      @nurtaytulegenov7431 2 роки тому +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 Рік тому +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 5 років тому +57

    “Remove all the STDs.”

  • @jrcowboy1099
    @jrcowboy1099 6 років тому +866

    longest. intro. ever.

    • @IsakFyksen
      @IsakFyksen 6 років тому +87

      This guy clearly does not listen to Pink Floyd.

    • @VictorOrdu
      @VictorOrdu 5 років тому +1

      @@IsakFyksen lol

    • @sadhlife
      @sadhlife 4 роки тому +17

      best. intro. ever.

    • @pxolqopt3597
      @pxolqopt3597 4 роки тому +13

      Yeah but i loved every second of it

    • @dimitrisdelidis365
      @dimitrisdelidis365 3 роки тому +1

      so you are new here

  • @zemlidrakona2915
    @zemlidrakona2915 5 років тому +336

    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 UA-cam programmers I like. Keep up the good work.....

    • @mattizzle81
      @mattizzle81 4 роки тому +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 4 роки тому +22

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

    • @rakinrahman890
      @rakinrahman890 4 роки тому +28

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

    • @shohamziner
      @shohamziner 3 роки тому +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 3 роки тому

      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.

  • @will8090
    @will8090 6 років тому +68

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

    • @zBMatt
      @zBMatt 4 роки тому

      Will read your comment while he said that.

  • @mitchellcampbell2775
    @mitchellcampbell2775 3 роки тому +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.

  • @pako_powr
    @pako_powr 6 років тому +341

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

    • @Guztav1337
      @Guztav1337 4 роки тому +15

      Probably his EA money to be fair

    • @anona1443
      @anona1443 4 роки тому +16

      Going to Costa Rica cofee plantations

    • @Badcannon
      @Badcannon 3 роки тому +2

      Making good content ?

  • @guywithknife
    @guywithknife 4 роки тому +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 Рік тому

      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 Місяць тому

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

  • @arcanesunku
    @arcanesunku 6 років тому +18

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

  • @Aqsa792
    @Aqsa792 6 років тому +24

    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 Рік тому +3

      UA-cam is a strange place

  • @rissandimo
    @rissandimo 6 років тому +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 5 років тому

      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.

  • @mkmabdelkawy
    @mkmabdelkawy 5 років тому +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.

  • @denislobov8248
    @denislobov8248 3 роки тому +2

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

  • @LameDuckStudios
    @LameDuckStudios 3 роки тому +11

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

    • @dionyzus2909
      @dionyzus2909 3 роки тому

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

    • @LameDuckStudios
      @LameDuckStudios 3 роки тому

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

  • @SamTanXYZ
    @SamTanXYZ 6 років тому +118

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

    • @kylecox5127
      @kylecox5127 4 роки тому +53

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

    • @luizandre12345
      @luizandre12345 4 роки тому +1

      @@kylecox5127 lol

    • @मेबीराज
      @मेबीराज 4 роки тому +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 4 роки тому +2

      @@kylecox5127 Lol nice reference

    • @johneltins9822
      @johneltins9822 3 роки тому

      monster :0

  • @memakesillything9491
    @memakesillything9491 2 роки тому +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 2 роки тому +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 2 роки тому +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 2 роки тому +1

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

  • @abhijeetjain04
    @abhijeetjain04 6 років тому

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

  • @NinaTheLudaca
    @NinaTheLudaca 6 років тому +1

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

  • @petarsmilajkov9431
    @petarsmilajkov9431 6 років тому +6

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

  • @almondhete3623
    @almondhete3623 6 років тому +138

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

    • @luisponce3580
      @luisponce3580 6 років тому +34

      Yeah, and also, what programming ide is this?

    • @valiok9880
      @valiok9880 6 років тому +3

      Visual studio 2017

    • @jjbailey01
      @jjbailey01 6 років тому +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 6 років тому +2

      Nice name tho...

    • @almondhete3623
      @almondhete3623 6 років тому +2

      Thanks a lot.

  • @EpochIsEpic
    @EpochIsEpic 4 роки тому +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

  • @HakanSULUNtequila
    @HakanSULUNtequila 6 років тому

    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?

  • @Day13May
    @Day13May 5 років тому +6

    That intro was oddly mesmerizing

  • @tedleahy8075
    @tedleahy8075 6 років тому +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??

  • @codysing8291
    @codysing8291 6 років тому +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.

  • @atuljain2845
    @atuljain2845 5 років тому

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

  • @MrWazzup987
    @MrWazzup987 6 років тому +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

  • @davidmalinowski6331
    @davidmalinowski6331 2 роки тому +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.

  • @IgnoreSolutions
    @IgnoreSolutions 6 років тому +47

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

  • @errorlooo8124
    @errorlooo8124 6 років тому +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.

  • @itsnotallrainbowsandunicor1505
    @itsnotallrainbowsandunicor1505 4 роки тому +5

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

  • @MsJavaWolf
    @MsJavaWolf 5 років тому +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.

  • @herooyyy
    @herooyyy 6 років тому

    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?

  • @jorgemartin9258
    @jorgemartin9258 4 роки тому

    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!

  • @GRHmedia
    @GRHmedia 3 роки тому +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.

  • @meanmole3212
    @meanmole3212 6 років тому +68

    Is that a coffee or a milkshake?

    • @jjbailey01
      @jjbailey01 6 років тому +13

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

    • @xeekk
      @xeekk 6 років тому +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 4 роки тому +3

      @@warrick_lo Very brave.

  • @sayoojmandodi1172
    @sayoojmandodi1172 4 роки тому

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

  • @harshitatailor334
    @harshitatailor334 4 роки тому

    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

  • @nekopushyo
    @nekopushyo 4 роки тому +8

    I thought I accidentally clicked on video about coffee

  • @SlideRSB
    @SlideRSB 4 роки тому +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.

  • @AndyChamberlainMusic
    @AndyChamberlainMusic 4 роки тому +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

  • @krisitak
    @krisitak 6 років тому

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

  • @Andy4Tune
    @Andy4Tune 3 роки тому +6

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

  • @joey546
    @joey546 6 років тому +46

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

    • @Grougal
      @Grougal 6 років тому +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 5 років тому +25

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

    • @raenastra
      @raenastra 4 роки тому +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 2 місяці тому

      Bc Std::vector is not very well optimised

  • @madhatter5361
    @madhatter5361 5 років тому

    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?

  • @joshyoutube8569
    @joshyoutube8569 5 років тому

    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?

  • @brand1210
    @brand1210 5 років тому +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).

  • @TheYahmez
    @TheYahmez 4 роки тому +4

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

  • @thekidphi
    @thekidphi 6 років тому

    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;

  • @andersonklein3587
    @andersonklein3587 4 роки тому

    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.

  • @cantcode1001
    @cantcode1001 6 років тому +12

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

  • @derpmarine216
    @derpmarine216 5 років тому +9

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

    • @froge8121
      @froge8121 4 роки тому

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

  • @YoungMetroid
    @YoungMetroid 6 років тому +1

    Whats the song used in the intro?

  • @PaprikaX33
    @PaprikaX33 6 років тому +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

  • @gage2560
    @gage2560 6 років тому +69

    that intro tho

    • @jdnoidea
      @jdnoidea 6 років тому +4

      GAGE was long.

  • @ThePhinista
    @ThePhinista 6 років тому +11

    Nice intro but WHY SO MUCH CREAM

    • @rban123
      @rban123 4 роки тому

      because it's a latte

  • @jousboxx9532
    @jousboxx9532 6 років тому

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

  • @arnodunstatter
    @arnodunstatter 3 роки тому

    Could we protect our programs by putting brackets {} around the entire portion wherein we've declared `using namespace std;` to limit its scope?

  • @jannikkoch4944
    @jannikkoch4944 6 років тому +28

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

    • @Psychedique
      @Psychedique 6 років тому +7

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

  • @koungmeng
    @koungmeng 5 років тому +4

    6:36 i laughed so hard

  • @guiorgy
    @guiorgy 3 роки тому

    In your example, wouldn't adding another file that also defines an "apple" namespace with a "print" funtion that takes a char pointer and does cout in reverse result in the same problem (the behavior suddenly changed, and you need to track down why) even though you were using "apple::"?

  • @tmtygnz
    @tmtygnz 3 роки тому

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

  • @alexkiecker4175
    @alexkiecker4175 6 років тому +8

    Myself and most professionals don't because of name conflicts

  • @MrJ-vs7vr
    @MrJ-vs7vr 6 років тому +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 5 років тому +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.

  • @MrTopfpflanze1
    @MrTopfpflanze1 6 років тому

    You have a really good point, usually explicit code looks a little bit more bloated, but is much more readable!

  • @ToxicityGameDev
    @ToxicityGameDev 6 років тому

    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.

  • @arielespindola1867
    @arielespindola1867 3 роки тому +5

    Using std:: actually makes your code cleaner

    • @SR-er6hx
      @SR-er6hx 3 роки тому

      It's and it prevents sudden headaches!!

    • @insydium7385
      @insydium7385 Рік тому

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

  • @bestopinion9257
    @bestopinion9257 4 роки тому +6

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

  • @emagist
    @emagist 6 років тому

    Whohaa! This guy loves coffee, guitars and programming! My brother from another mother!
    Back to the issue I want to ask: In the example of invoking two namespaces does the order of those command give any kind precedence over the other? Or is simply the functions footprint?
    By the way: thank you for the content created! Really good quality.

  • @christianjoshua7218
    @christianjoshua7218 2 роки тому

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

  • @slap_my_hand
    @slap_my_hand 6 років тому +18

    What's the point of the long intro?

    • @shruikan123456789
      @shruikan123456789 6 років тому +6

      slap_my_hand porn

    • @alep7358
      @alep7358 6 років тому +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 6 років тому +6

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

    • @789blablajaja
      @789blablajaja 6 років тому +1

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

    • @robertmurch7660
      @robertmurch7660 6 років тому +2

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

  • @zeuglcockatrice4633
    @zeuglcockatrice4633 6 років тому +7

    people don't like opinions
    Vim is better than Emacs

  • @samindj
    @samindj 5 років тому

    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

  • @vorpal22
    @vorpal22 5 років тому

    Why are you using a capture of [=] for lambda when you don't need to capture anything at all?
    Also, why std::endl instead of '
    '? Do you really want to keep flushing the buffer?

  • @KaranLobana
    @KaranLobana 6 років тому +91

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

    • @elvisss
      @elvisss 6 років тому +1

      Karan Lobana could not agree more

    • @arnerademacker8548
      @arnerademacker8548 6 років тому +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 6 років тому +7

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

    • @KaranLobana
      @KaranLobana 6 років тому +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 6 років тому +1

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

  • @simondimas838
    @simondimas838 4 роки тому +5

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

    • @martinlarsson8947
      @martinlarsson8947 4 роки тому

      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 4 роки тому

      @@martinlarsson8947 Whip anf naenae

  • @justintabatchnick1675
    @justintabatchnick1675 4 роки тому

    off topic - I'm new to VS and typically I update software with new revs. I create a new project with an incremented rev number and do a copy and paste from the previous rev and then edit the files. With all VS sophistication there has got to be a better way . Any suggestions , thanks - Justin

    • @justintabatchnick1675
      @justintabatchnick1675 4 роки тому

      BTW - liked your video , very informative . Wish I had your latte machine.

  • @stingray427
    @stingray427 2 роки тому

    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 ?

  • @steakiefrags1866
    @steakiefrags1866 6 років тому +57

    I hate these way too long intros

    • @jdnoidea
      @jdnoidea 6 років тому +8

      SteakieFrags same, seem pretty pointless for coding vids

    • @charbelsarkis3567
      @charbelsarkis3567 6 років тому +4

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

    • @ToxicityGameDev
      @ToxicityGameDev 6 років тому +4

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

    • @Admwings
      @Admwings 6 років тому +1

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

    • @ToxicityGameDev
      @ToxicityGameDev 6 років тому +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...

  • @prateekkarn9277
    @prateekkarn9277 3 роки тому

    suppose you are using namespace std and using a vector, but if I wanted to use an eastl vector when im using std, can I just
    eastl::vector //for eastl vector
    vector //std vector as im using namespace std
    I mean that is the function of scope resolution operator

    • @TheVenomAnt
      @TheVenomAnt 2 роки тому

      Finally somebody with some common sense, that’s all it takes. Most people don’t think like this though. Most people suck at problem solving.

  • @maishamolepo2216
    @maishamolepo2216 4 роки тому

    New to programming and I was taught to end the int main with return 0. I see you use std::cin.get(). What does this do?

    • @josefaschwanden1502
      @josefaschwanden1502 4 роки тому

      cin.get() reads a single character from the console (to pause the program to read the output of it), return 0 isn't needed for c and c+, the compiler will do it for you if it isn't there.

  • @TwstedTV
    @TwstedTV 4 роки тому

    Problem I am having with this is for some reason when I dont use -- using namespace std;
    the string data-type will have problems. I dont know if the maintainer in their recent update broke something or what, but if I just use, std by itself like this example for an output.
    std::cout > std::cout -- using namespace std;
    everything is working again... meaning......... I have to use both -- using namespace std; and std::cout

  • @BrandonAB
    @BrandonAB 6 років тому +1

    Good point. Who knows what may happen if you were "using namespace std;" and "using namespace eastl;" and called a function, that was included in both, but varied slightly in definition.

  • @Xxp0r
    @Xxp0r 6 років тому +1

    Personally, I use "using std::vector;" for example in the scope it is being used. I find it a good compromise due to a lot of the flaws of "using namespace" that you mentioned in your video, it allows me to see what parts of std I'm using up front for that scope without having to continually type std::

  • @igorgiuseppe1862
    @igorgiuseppe1862 4 роки тому

    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?

  • @exoticcoder5365
    @exoticcoder5365 3 роки тому +1

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

  • @kushagrapandey8898
    @kushagrapandey8898 Рік тому

    But how do I know the exact functions of std library? To which functions I have to add std:: and to whom not to?

  • @SebastianGonzalez-cv4tu
    @SebastianGonzalez-cv4tu 3 роки тому +1

    Not that i would.. but can someone clearly tell me some concrete example where using namespace in a header file turns out a bad idea?

  • @cedrust4111
    @cedrust4111 5 років тому

    The ‘C’ logo stickier on your Dell.. where/how can I get one?

  • @fatihcnar3513
    @fatihcnar3513 5 років тому

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

  • @douglasoak7964
    @douglasoak7964 6 років тому

    The link for implicit conversation does not appear on mobile UA-cam

  • @shiv_live
    @shiv_live 5 років тому

    4:00 how did he do it? Find and select by typing? Is this a smartcast or what?

  • @MohamedKhaled-xe8yp
    @MohamedKhaled-xe8yp 6 років тому

    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.

  • @user-rt1ft8bt6o
    @user-rt1ft8bt6o 6 років тому

    Hi Cherno, thank you for all your videos, I totally agree with you about not using namespace std.
    PS: very cool intro, it turns this video in a work of art