Not your GrandParent’s C++ - Phil Nash - NDC TechTown 2024

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025

Комментарии • 13

  • @womiro
    @womiro 21 час назад +11

    One of the truly great things about C++ is all the people giving excellent talks at all of these excellent conferences.

    • @xealit
      @xealit 19 часов назад +2

      And the book authors. Scott Meyers, Josuttis, Alexandrescu-there are not many authors of such level around.

  • @VoidloniXaarii
    @VoidloniXaarii 11 часов назад +2

    Thank you for this great walk through history! 🙏

  • @stephenjames2951
    @stephenjames2951 9 часов назад

    I remember the early template implementation almost doomed templates, the old CFront compiler code bloat, slow builds, etc.

  • @robby3467
    @robby3467 17 часов назад +4

    Been a C++ application developer for 28 years, but most of the code bases I've worked with were C++98 or ported C code. The newer work probably doesn't move past C++11. I rarely use anything from C++14 or later. Most of the new stuff increases cognitive load for little or no real benefit.

    • @not_ever
      @not_ever 14 часов назад +5

      A lot of the new stuff reduces cognitive load and is beneficial which you'd know if you had experience using it.

  • @Nellak2011
    @Nellak2011 21 час назад

    I saw a C++ code snippet and thought it was super ugly, so I made it more readable in a made up programming language to just show how bloated C++ is compared to what it is actually expressing.
    === Bloated C++ (15 LOC, 40 words)
    class MyClass {
    std::string m_name;
    std::vector m_data;
    public:
    MyClass(std::string const& name,
    std::vector const& data)
    : m_name(name),
    m_data(data)
    {}
    std::string name() const { return m_name; }
    std::string data( int i ) const { return m_data.at(i); }
    size_t size() const { return m_data.size(); }
    }
    === What it actually is expressing (3 LOC, 25 words)
    let MyClosure (name : string, data : string list) =
    // inner state here if needed
    {name: () -> name; data: i -> item i data; size: () -> length data} // this is returned
    === What it actually is expressing (no comments or unnecessary code) (1 LOC, 17 words)
    let MyClosure (name : string, data : string list) = {name: () -> name; data: i -> item i data; size: () -> length data}
    =====
    My hypothetical syntax is 40/17 = 2.35 times more concise than the regular C++ version.

    • @toby9999
      @toby9999 19 часов назад

      There was nothing wrong with the original version, in my opinion. Just use a wider screen if you have long lines. I also put every class declaration in a separate file. Number of lines isn't a problem there.
      That said, I tend to use the older style C++ syntax. Some of the latest additions are destroying the elegance of the language.

    • @Nellak2011
      @Nellak2011 19 часов назад

      @@toby9999 The original version was pure code noise. However, if you want to adopt a style that is compatible with the C++ paradigm then this would be more optimally readable:
      public class MyClass(string name, vector data) {
      string name = () => name
      string data = (int i) => data.at(i)
      size_t size = () => data.size()
      }
      C++ devs are super economical with computer resources they use, but super liberal with developer resources, it is unnecessary complexity.

    • @raymundhofmann7661
      @raymundhofmann7661 18 часов назад +3

      This is what happens if one applies useless patterns. What is the use of "MyClass"?

    • @Nellak2011
      @Nellak2011 18 часов назад

      @@raymundhofmann7661 Facts, classes are pretty useless. Functions all day.

    • @robby3467
      @robby3467 17 часов назад +3

      @@Nellak2011 I like classes but I use then sparingly, and mainly to group conceptually related functionality together instead of having everything global. I spent many years working with C code, and globals were the root cause of very many bugs, way more than memory issues. There is a balance with classes. I really dislike what I see in most Java code though.