Stories
Slash Boxes
Comments

SoylentNews is people

posted by Fnord666 on Monday October 28 2019, @06:05AM   Printer-friendly
from the evolve-or-die dept.

C++ is a language you should give serious consideration to learning in 2019 (or whenever you happen to come across this article). Rapid language modernization, better tooling, a growing and inclusive community, and a thriving job market are just some of the reasons C++ should be your next language to learn.

Wow, this guy drank too much Kool-Aid ™️️, I'm out.

Yeah, I get it. At least in the communities I've been a part of over the years, C++ has a consistently bad reputation.

...

Modern C++ (versions ≥ 11) is an entirely different beast and should be considered separately.

foreach new_shiny in hackerland
    { import; improve; integrate; }

Plus, importing crusty old code into your projects is fun, well, at least more fun than dissecting them and re-coding in a new language which lacks the libraries they leaned on.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 5, Insightful) by c0lo on Monday October 28 2019, @06:58AM (11 children)

    by c0lo (156) Subscriber Badge on Monday October 28 2019, @06:58AM (#912685) Journal

    No, seriously, you will never get to learn C++ in its entirety and in a practical way.
    It is already an Universe, an almost monstrous one, pretending to "know it all" it's like pretending to "know all Mathematics". For example, take an old topic, expansions of variadic templates arguments [youtube.com] back in 2012 and tell me that you already know by heart what the 20-25mins of the clip means (at least until you get past Variadic variadic templated templates).

    Consider this: the template part of the language is Turing-complete. Since the templates are resolved exclusively at compile time, you can theoretically implement (this is called meta-programming) heaps of algorithms that will be solved by the compiler and having the compiled binary contain only the collection of all your possible results and the code to output them - no runtime processing.

    Then, when you think you know enough of it, there comes the engineering part.
    One example: the cost of using its abstraction in terms ofruntime, or compile time or code maintenance time [youtube.com] - or any combination of them (the link is a fresh CppCon 2019 presentation).

    --
    https://www.youtube.com/watch?v=aoFiw2jMy-0 https://soylentnews.org/~MichaelDavidCrawford
    Starting Score:    1  point
    Moderation   +3  
       Insightful=1, Interesting=1, Informative=1, Total=3
    Extra 'Insightful' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   5  
  • (Score: 1, Interesting) by Anonymous Coward on Monday October 28 2019, @09:48AM (7 children)

    by Anonymous Coward on Monday October 28 2019, @09:48AM (#912728)

    back in 2012 and tell me that you already know by heart what the 20-25mins of the clip means (at least until you get past Variadic variadic templated templates).

    What's so complicated about that?

    Since the templates are resolved exclusively at compile time, you can theoretically implement (this is called meta-programming) heaps of algorithms that will be solved by the compiler and having the compiled binary contain only the collection of all your possible results and the code to output them - no runtime processing.

    Ok, not sure if you are just misinformed or don't know C++.

    The entire thing about templates is that they are templates for *types*. These allow code to have special cases that are then picked at compile time, not runtime. The code still has to run. All that happens is the the code for specific types is produced, as-needed, based on the template. I repeat - templates are a blueprint for *types*. The "resolved exclusively at compile time" must happen, by definition. Like a #define must happen at compile time.

    The upside is that you don't have to write so much code for common container types. Things like std::vector vs. std::vector -- these types actually may have nothing to do with each other and produce code bloat in the binary but have same API while completely different ABI. The downside is people don't understand how it works and they also get to the premature optimization problem very early on.

    Your comment is rather a nice example of not understanding C++. The optimization has nothing to do with C++ - it's about compiler optimization, not the language. Purpose of templates is primarily type safety and the other stuff just falls out of it.

    • (Score: 2) by c0lo on Monday October 28 2019, @10:38AM (3 children)

      by c0lo (156) Subscriber Badge on Monday October 28 2019, @10:38AM (#912734) Journal

      What's so complicated about that?

      In principle, nothing. In the use of ... operator, better open your eyes wide, save heaps of failed compilation with compilation error kilobytes long each.

      I repeat - templates are a blueprint for *types*.

      Exclusively for types, right? What happened with template non-type args [cppreference.com], got deprecated?

      Ok, not sure if you are just misinformed or don't know C++.

      What a boon for humanity with AC-es that do!

      For fun, resolve the problem of N-queens by template metaprogramming.
      Then go contribute to Boost.Metaparse.

      --
      https://www.youtube.com/watch?v=aoFiw2jMy-0 https://soylentnews.org/~MichaelDavidCrawford
      • (Score: 0) by Anonymous Coward on Monday October 28 2019, @01:35PM (1 child)

        by Anonymous Coward on Monday October 28 2019, @01:35PM (#912782)

        Exclusively for types, right? What happened with template non-type args [cppreference.com], got deprecated?

        Yes. Just because it accepts some arguments, doesn't actually mean what you think it means. It defines *types*

        Then go contribute to Boost.Metaparse.

        Non-sequitur.

        C++ is like PowerPoint. Some people think that if they use ALL things available at same time it somehow makes them more "pro".

        • (Score: 2) by c0lo on Monday October 28 2019, @09:25PM

          by c0lo (156) Subscriber Badge on Monday October 28 2019, @09:25PM (#912964) Journal

          Just because it accepts some arguments, doesn't actually mean what you think it means.

          You keep building strawmen, I see.

          Non-sequitur.

          C++ is like PowerPoint. Some people think that if they use ALL things available at same time it somehow makes them more "pro".

          Put this together with my original assertion of

          No, seriously, you will never get to learn C++ in its entirety and in a practical way.

          (abstain from building strawmen and) see if there's a contradiction.

          --
          https://www.youtube.com/watch?v=aoFiw2jMy-0 https://soylentnews.org/~MichaelDavidCrawford
      • (Score: 3, Funny) by hendrikboom on Monday October 28 2019, @02:37PM

        by hendrikboom (1125) Subscriber Badge on Monday October 28 2019, @02:37PM (#912810) Homepage Journal

        What a boon for humanity with AC-es that do!

        What a great idea! Using the Axiom of Choice for template selection!

    • (Score: 2) by Immerman on Tuesday October 29 2019, @12:48AM (1 child)

      by Immerman (3985) on Tuesday October 29 2019, @12:48AM (#913059)

      Actually, no, that's just the commonly used aspect. It's not *nearly* as widely used, but C++ template metaprogramming is a huge field in itself, aided in large part by the fact that you can cause templates to resolve on values as well. Only integers is I recall correctly - but it's C++, anything is an integer if you want it to be. Sqrt(constant) resolved at compile-time? Child's play - practically a meta-programming "hello world".

      Even just using types, if you're clever enough and the problem is amenable, you can resolve a huge amount of processing at compile-time so that only a comparatively tiny amount of data processing specific to run-time variables needs to be done at runtime. And you can pack away a surprising amount of the information you'd assume was variable into outstandingly complex auto-generated templated types.

      I was just beginning to scratch the surface when I drifted away from programming heavily - and my overall impression was that it was an *incredibly* powerful tool that vanishingly few people would ever directly use. I seem to recall some really interesting implementation details in the Boost libraries. They managed to just about add new language features by invoking some of the more esoteric meta-programming abilities.

      • (Score: 0) by Anonymous Coward on Tuesday October 29 2019, @01:38AM

        by Anonymous Coward on Tuesday October 29 2019, @01:38AM (#913075)

        Metaprogramming in QuakeC offers greater rewards.

    • (Score: 2) by exaeta on Wednesday October 30 2019, @09:59PM

      by exaeta (6957) on Wednesday October 30 2019, @09:59PM (#913899) Homepage Journal
      Not true. You can have template variables, and constexpression template parameters... you can do a lot at compile time. :)
      --
      The Government is a Bird
  • (Score: 3, Funny) by bobmorning on Monday October 28 2019, @04:45PM (1 child)

    by bobmorning (6045) on Monday October 28 2019, @04:45PM (#912882)

    It's the systemd of programming languages.

    • (Score: 3, Informative) by arslan on Monday October 28 2019, @10:39PM

      by arslan (3462) on Monday October 28 2019, @10:39PM (#912998)

      I thought that was Ruby...

  • (Score: 2) by JoeMerchant on Tuesday October 29 2019, @04:23PM

    by JoeMerchant (3937) on Tuesday October 29 2019, @04:23PM (#913314)

    The big lie about languages is: it's all about the libraries.

    How useful are Java / Javascript / Python without "import" ?

    Whether it's broad APIs like stdlib or Qt, or specific bits like GDCM, easy, reliable access to solid, well supported libraries is MORE important than which language you are coding in.

    Case in point: PyQt - an interesting experiment in code wrapping - recommended at 0.5/10 for any large applications.

    --
    🌻🌻 [google.com]