Commute talk: Why do I write in C++?

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ธ.ค. 2024

ความคิดเห็น • 48

  • @JamesSmithereen
    @JamesSmithereen 3 ปีที่แล้ว +3

    I agree with all of these good things. C++ has really improved since 98

  • @lawrencemanning
    @lawrencemanning 5 ปีที่แล้ว +18

    I see you don't use exceptions. This gives me much relief as I really can't stand them. Thoughts? C++ is indeed a great language, but a negative against it is its sheer size. Likewise the standard library is nearly boundless in scope. On the other hand you can pick and choose what you want to use...

    • @awesomekling
      @awesomekling  5 ปีที่แล้ว +13

      True! I never liked exceptions. Unlike RAII, they actually do obscure control flow, often to a painful degree.
      The "pick and choose" aspect of C++ is one of its greatest strengths IMO. And that you only pay for what you use. I tend not to use the STL at all, and as a result my programs are nice, tight and pretty fast to compile! ... there might be some bias at play about the "nice" part, of course. :)

    • @m4gh3
      @m4gh3 5 ปีที่แล้ว

      Oh and also... I found a little bit of a pain make C++ exceptions work in a kernel.At least with gcc.Same with RTTI.

    • @awesomekling
      @awesomekling  5 ปีที่แล้ว +4

      Oh yeah, you can make them work.. but I really don't want to. I like my C++ without exceptions and RTTI. I would like RTTI better if I could control how the compiler stores the type information, but since I can't, I just implement my own when I need it :)

    • @lawrencemanning
      @lawrencemanning 5 ปีที่แล้ว +1

      Exceptions are just goto with a different name really.
      In 2006 ish I wrote an Instant Messaging (MSN, ICQ, GoogleTalk etc) filtering proxy in basically C with a few classes and bits of the STL. It was great just having those things on top of C. But using the language in team projects scares me because some projects/teams will use every single language feature/STL feature, which would cause a massive cognitive load. So the size and scope of the language has to, unfortunately, be considered a downside. Luckily with Serenity, like me with my IM proxy, you are in charge.

  • @LukeSchoen
    @LukeSchoen 5 ปีที่แล้ว +1

    Love the point you made about passing parameters by (const) ref !

  • @antoniocs8873
    @antoniocs8873 5 ปีที่แล้ว +3

    I do like C++. The language I use at work (php) has a few similarities with it, but quite a few things are different, especially in inheritance. I have been bitten by this so many times, but hey, still enjoy doing stuff in C++

    • @awesomekling
      @awesomekling  5 ปีที่แล้ว

      I actually quite like PHP as well. It's really fast to get something quick&dirty going with PHP, and it's way more forgiving than e.g Python or Ruby. I never understood why PHP isn't more popular as a non-web scripting language..

    • @antoniocs8873
      @antoniocs8873 5 ปีที่แล้ว

      @@awesomekling One of the big issues people have with php is how quick&dirty many projects are. This is not the fault of php but the programmers but people still blame the language.
      Hey, you have an OS, put in a scripting language, make it PHP :D. Windows has powershell, linux has bash, you'll have PHP

    • @eyesight2073
      @eyesight2073 3 ปีที่แล้ว +3

      I'm really bad at typing $

    • @FreeScience
      @FreeScience ปีที่แล้ว

      @@awesomekling I know of a couple of guys who used to do rescue data from damaged hard drives, and other IT consulting. I think they knew C++ pretty well, but they wrote all their internal tools in PHP.

  • @Spongman
    @Spongman ปีที่แล้ว

    how about c+=14: auto returns, generic lambdas, c++17: guaranteed copy elision, structured binding? c++20: coroutines/generators.

  • @TheOnlyJura
    @TheOnlyJura 4 ปีที่แล้ว +3

    What do you think about modules in C++20 ?

    • @awesomekling
      @awesomekling  4 ปีที่แล้ว +5

      Hi Jiří! I think it sounds great in theory and I'm very interested to see how it turns out in practice. I'm definitely going to start using them when they become available in a compiler :)

    •  3 ปีที่แล้ว +2

      @@awesomekling Any update on this?

  • @tristanpartin9493
    @tristanpartin9493 5 ปีที่แล้ว

    Do you have a link to that smart pointer you wrote for work? Would love to see it.

  • @DFsdf3443d
    @DFsdf3443d ปีที่แล้ว

    What do you think about exceptions? i ask because i noticed libAK doesn't have any exception class, which leads me to assume you dont like them, or at least you prefer the ErrorOr pattern over it, however in this video you say you like constructors but how do you deal with that when constructors pretty much requires you to use exceptions (considering you cant return anything obviously)?

  • @brianmillar6040
    @brianmillar6040 5 ปีที่แล้ว +12

    Only C for me.

    • @awesomekling
      @awesomekling  5 ปีที่แล้ว +11

      Mad lad!

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว

      Agreed C is the best!

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว

      @@brian_n_millar I did the opposite. I used C++ for more than 15 years, and now I have switch to C for the last years. So much better!

  • @mr_waffles_the_dog
    @mr_waffles_the_dog 5 ปีที่แล้ว +2

    Because C++ is the best language!

    • @mr_waffles_the_dog
      @mr_waffles_the_dog 5 ปีที่แล้ว +1

      I mean aside from Haskell of course :)

    • @awesomekling
      @awesomekling  5 ปีที่แล้ว +2

      Obviously :)

    • @mr_waffles_the_dog
      @mr_waffles_the_dog 4 ปีที่แล้ว

      @@user-hufgfdsddssdfdsdsdsdd2 hahah, no C++ is best, but I had to write a Haskell compiler many many years ago

  • @willmcpherson2
    @willmcpherson2 5 ปีที่แล้ว +11

    I'm interested to hear what your C++ dislikes are
    Also, obligatory: have you tried Rust? You were almost baiting for that question talking about generics, references, null pointers, lambdas and ranges

    • @awesomekling
      @awesomekling  5 ปีที่แล้ว +29

      Answered: th-cam.com/video/zuRBhxxaQ1g/w-d-xo.html :)
      As for Rust, I’m sure it’s okay and if it makes someone productive that’s great. The evangelism around it is obnoxious though.

    • @justinmalcolm6287
      @justinmalcolm6287 3 ปีที่แล้ว

      ​@@awesomekling Love your videos. Have watched a few lately. I was surprisingly turned off by your answer about Rust ( which I have not used yet ). No strike against you per se. You are certainly not the only one turned off by overzealous Rust advocacy. That said, it would bug me to see a comment complaining about somebody that passionately evangelized consistent, professional UX, 90's era Human Interface Guidelines, UNIX / POSIX design principles, or clean vertical integration in an OS. I guess I am attracted to the passion more than I am turned off by the evangelism. Seeing people get criticized for their passion makes me sad. Loved your video on TempleOS. I wish you saw some of the same beauty in Rust ( or its advocates I guess ). Again, this is not meant to be a complaint against you; it is only meant to be a commentary on the world as I wish it was. Please do not take it as a lecture on what opinions to have or how to share them. Glad you like C++ so much. I agree with your video comment that C++ would benefit from more consistent move semantics and fewer buffer overflows. I agree with most of the opinions you share. I guess that is why I notice the ones where I do not.

    • @awesomekling
      @awesomekling  3 ปีที่แล้ว +2

      Hi Justin, this was quite a while ago now. I have since spoken to people from the Rust team and learned that the unpleasant people who were spamming people/projects about how they should rewrite everything in Rust were part of a decentralized smear campaign designed to make the Rust team look bad. In retrospect I should have realized this, but I didn't think critically. That's my bad :)

    • @dosu360
      @dosu360 3 ปีที่แล้ว

      @@awesomekling Well that's news! I've always felt that Rust was overhyped.

  • @fededevi1985
    @fededevi1985 2 ปีที่แล้ว

    Like for all c++ developers it is about self hate.

  • @deckard5pegasus673
    @deckard5pegasus673 3 ปีที่แล้ว +1

    I prefer C

  • @Lircking
    @Lircking ปีที่แล้ว

    this is a joke video right?

  • @deckard5pegasus673
    @deckard5pegasus673 3 ปีที่แล้ว

    Sorry to break it to you, but C++ references are just C pointers, when you see how they are implemented in assembly.

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว +1

      @ok Obviously; I see his point as "invalid". Just as a reference can be "invalid". Also references are just "static pointers" that cannot be changed, and thus are infinitely less flexible. Just as a static pointer can point to invalid memory, a reference can be invalid and also point to invalid memory, because they are SAME thing. No there is no "cognitive overhead", in C, as the same exists in C. What C offers is much more flexibility.

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว +1

      @ok Nulls are not the problem. A null value may be the correct value and does not mean there is an error in the program. In fact, most programs (should) initialize pointers to null and thus when an object is created and assigned to a pointer, the null condition can be used to to gracefully error check if an object was created or not, and whether it needs to be free it or not, or whether something has failed, etc. Thus nulls are not the problem, they are actually needed, used and accounted for in C systems programming. To the contrary, an invalid reference or pointer is the real problem.
      C++, (and Java much worse), really complicates, and abstracts too much. If someone wants to program in C++, and it's mechanisms, like templates, references(static pointers) etc. fine. But I see C++,Java, C#, etc. as cognitive overload....and I use to program heavily in C++ MFC(microsoft foundation classes) way back in the day. Then later in Java and C# for some years. And also did many native C++ Carbon apps in Mac, before C++ Carbon was deprecated in favor of Cocoa objective C. But now I have switch to C, and won't look back. programming in C is like playing a video game in "god mode" , anything is possible.

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว

      @ok When "references" are needed, there is the static pointer in C.

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว

      @ok also there is also this thingy called "static". If you cannot write a program setting a static pointer, which is set ONLY one time in the program to the intended value, I can safely say you should NOT be programming.

    • @deckard5pegasus673
      @deckard5pegasus673 3 ปีที่แล้ว

      @ok This is getting little tiring...
      first, static variables don't need to be global in C. Second, whether one uses const, or static in C, they are intended to be set one time. Thus whether static or const (to clarify so you understand) in C are set ONE time, and if a programmer cannot do that one single assigment well, they probably need to look into learning how to program better rather than hoping some language abstraction will help them. Again there is no advantage in references as they are really just static/const pointers under the hood. And you will say, oh but reference can not be null, and neither can static/const if the programmer takes 2 seconds to set them right, as they are set ONLY single one time. But again NULL, is not the problem, invalid memory locations are.
      And while on the topìc of OOP, OOP is probably even more obsolete than globals, where data oriented programming has shown to be much more efficient in design than OOP and in fact the "inventor" of OOP Alan Kay, is now saying OOP abstraction is being abused. Thus Abstaction is really becoming "obsolete". Just look at Vulkan vs OpenGL, which is reverting the "abstraction" trend. Obviously OOP in moderation can be useful, but is not the holy grail, in fact, in excess may be the opposite.