Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. are these developments making things easier for the developer?

are these developments making things easier for the developer?

Scheduled Pinned Locked Moved The Lounge
c++questioncsharpvisual-studiocom
24 Posts 20 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sander RosselS Sander Rossel

    One of the "improvements" I find really complicated is the range operator.

    string name;
    name = "My name is Sander Rossel".Substring(11);
    name = "My name is Sander Rossel"[11..];

    Now tell me, which line of code better conveys my purpose? :~ Pattern matching is nice, but should be rarely needed in proper OOP.

    Exception ex = new Exception();
    switch (ex)
    {
    case InvalidCastException:
    break;
    case InvalidOperationException:
    break;
    case NullReferenceException:
    break;
    default:
    break;
    }

    // The alternative is, of course, an if-else statement.
    var exType = ex.GetType();
    if (exType == typeof(InvalidCastException))
    { }
    else if (exType == typeof(InvalidOperationException))
    { }
    else
    { }

    There's probably an advantage to the pattern matching, but it doesn't do much for readability. I love named tuples though.

    public (string firstName, string lastName) GetNameParts(string name) { }
    // Usage...
    (var firstName, var lastName) = GetNameParts("Sander Rossel");
    // Or...
    var tuple = GetNameParts("Sander Rossel");
    Console.WriteLine(tuple.firstName);

    And of course string interpolation, which greatly improves readability and decreases change of bugs.

    Console.WriteLine($"Hi {firstName} {lastName}, welcome to {appName}!");
    // vs.
    Console.WriteLine(string.Format("Hi {0} {1}, welcome to {2}!", firstName, lastName, appName);

    If I could keep only one language improvement from about the last ten years it would be string interpolation!

    Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

    C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #21

    Named tuples and interpolated strings are awesome, as is the ?? operator and the ?. operator. Those stay.

    cheers Chris Maunder

    Sander RosselS 1 Reply Last reply
    0
    • F fd9750

      Yes, it will keep on trucking for a long time. I have seen way too many attempts at using C++ for embedded applications that only use a subset of what C++ can do. And when you objectively ( pun indented ) it just makes you wonder what the point was of using C++ instead of C. Managers of any kind are a very bad idea to begin with.

      S Offline
      S Offline
      sasadler
      wrote on last edited by
      #22

      Hm, as an embedded system designer/programmer (now retired), I used C++ for most of my programing in the last 15 years of my career. Using templates for things like FIFOs, queues, digital oscillators, filter parts, etc made my code cleaner and easier to write. I did stay away from dynamic object creation/destruction and I didn't use C++ exceptions.

      1 Reply Last reply
      0
      • C Chris Maunder

        Named tuples and interpolated strings are awesome, as is the ?? operator and the ?. operator. Those stay.

        cheers Chris Maunder

        Sander RosselS Online
        Sander RosselS Online
        Sander Rossel
        wrote on last edited by
        #23

        I've been using ? and ?? so much I don't even consider them new anymore! So completely agreed :laugh:

        Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

        1 Reply Last reply
        0
        • L Lost User

          A question in the C++ forum today led me to C++ conformance improvements in Visual Studio 2019 | Microsoft Docs[^]. It seems to me that C++ is getting more and more complex and only a select few (some of whom are regulars here) will understand and be able to use these features. So I have to wonder who benefits from them, apart from the compiler writers who will definitely keep their jobs.

          M Offline
          M Offline
          Martin ISDN
          wrote on last edited by
          #24

          i always believed that a large part of it was about "keeping their jobs". i'm not talking only about VS2019 or C++. Windows grows because of it and you see the same buttons with the same functionality changing places in the same Form of say, System Properties. then the UP one directory button disappears in Vista and 7, but then it's coming back in 8. they move the GUI to a heavily 3D multicolored look and then back to 8 colors and win3.11 looks. it's progress alright, but i don't know if it's in the right direction. the chances to start a C++ project that lasts for 5 years and at the end of the project to claim you know modern C++ are getting close to zero, much less to claim you know some other rapidly evolving language. "if this frameworks are so great and helpful why do we need another one? why didn't the last 27 frameworks solve the problem? they didn't so you need the 28th framework, right?" - Jonathan Blow

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups