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. Other Discussions
  3. The Insider News
  4. Swift the best choice to succeed C++, Apple says

Swift the best choice to succeed C++, Apple says

Scheduled Pinned Locked Moved The Insider News
c++swifthtmlcomperformance
8 Posts 4 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.
  • K Offline
    K Offline
    Kent Sharkey
    wrote on last edited by
    #1

    Infoworld[^]:

    Company cites safety, speed, approachability, and built-in C and C++ interoperability as Swift’s compelling advantages.

    So get busy rewriting, C++ folks

    S H 2 Replies Last reply
    0
    • K Kent Sharkey

      Infoworld[^]:

      Company cites safety, speed, approachability, and built-in C and C++ interoperability as Swift’s compelling advantages.

      So get busy rewriting, C++ folks

      S Offline
      S Offline
      Shao Voon Wong
      wrote on last edited by
      #2

      Swift tries too hard to be different from C/C++ to stand out. For example, ++ and -- operators do not exist in Swift through += and -= exists. Its for-loop are different and inflexible. This is a C for loop to increment from 0 to 10

      for(int i=0; i<=10; ++i)
      {
      printf("%d", i);
      }

      This is Swift version of the same thing. It has limitations that it cannot increment more than one in a single step or decrement.

      for number in 0...10
      {
      print(number)
      }

      This is a C for loop to increment from 0 to 9

      for(int i=0; i<10; ++i)
      {
      printf("%d", i);
      }

      This is Swift version of the same thing.

      for number in 0..<10
      {
      print(number)
      }

      This is the C for-loop that increment from 0 to 256 in steps of 16

      for(int i=0; i<=256; i+=16)
      {
      printf("%d", i);
      }

      This is Swift version

      for number in stride(from: 0, through: 256, by:16)
      {
      print(number)
      }

      This is C for-loop of decrementing by steps of 16.

      for(int i=256; i>=0; i-=16)
      {
      printf("%d", i);
      }

      This is Swift version of decrementing by steps of 16.

      for number in stride(from: 256, to: 0, by: -16)
      {
      print(number)
      }

      C for-loop syntax more or less stay the same while Swift's change depending whether you want to increment more than one or decrement. C version of do-while

      do
      {
      ...
      }
      while (i<10);

      Swift version of do-while

      repeat
      {
      ...
      }
      while (i<10);

      These are some examples. The try-catch exception is also very different. I tried to port my Windows DirectX application to Apple Metal but I gave up because the Swift's syntax is too different. I do not mean they should be the same. At least, the basic syntax should stay the same instead to be different in order to differentiate Swift from other C-compatible languages. So that I only struggle on the DirectX/Metal differences rather than the language's unimportant differences.

      1 Reply Last reply
      0
      • K Kent Sharkey

        Infoworld[^]:

        Company cites safety, speed, approachability, and built-in C and C++ interoperability as Swift’s compelling advantages.

        So get busy rewriting, C++ folks

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        Yeah, no. C++ isn't going anywhere. Not in my lifetime. Not in yours. If I had kids, not in theirs. The fact that languages like Rust and Swift are touted by their authors as C++ successors just reinforces the idea that C++ is the language to "beat". (Such as that means anything in this context) C++ is flexible, powerful, and entrenched. The fact that it has been around for decades means sheer inertia will keep it moving for many more.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        C 1 Reply Last reply
        0
        • H honey the codewitch

          Yeah, no. C++ isn't going anywhere. Not in my lifetime. Not in yours. If I had kids, not in theirs. The fact that languages like Rust and Swift are touted by their authors as C++ successors just reinforces the idea that C++ is the language to "beat". (Such as that means anything in this context) C++ is flexible, powerful, and entrenched. The fact that it has been around for decades means sheer inertia will keep it moving for many more.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          C Offline
          C Offline
          charlieg
          wrote on last edited by
          #4

          C++ has enough issues with complexity as it is.... but one thing that irritates me to no end are developers who say they know C++, but when you look at their code, it's just C. Yeah, I know C++ is just a better C compiler (was told this one time), but in the world I live in, most cannot spell "class".

          Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

          H 1 Reply Last reply
          0
          • C charlieg

            C++ has enough issues with complexity as it is.... but one thing that irritates me to no end are developers who say they know C++, but when you look at their code, it's just C. Yeah, I know C++ is just a better C compiler (was told this one time), but in the world I live in, most cannot spell "class".

            Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #5

            charlieg wrote:

            but one thing that irritates me to no end are developers who say they know C++, but when you look at their code, it's just C

            I'm half guilty of that because I do embedded, which often requires me to forgo the STL for want of a compliant version, if it exists at all. And even if it does, it's not set up for multiple heaps, nor using tiny heaps responsibly. While I could make custom allocators for everything, it's often just easier to use the C functions for what I need. I still make judicious use of class, struct, and template.

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            C 1 Reply Last reply
            0
            • H honey the codewitch

              charlieg wrote:

              but one thing that irritates me to no end are developers who say they know C++, but when you look at their code, it's just C

              I'm half guilty of that because I do embedded, which often requires me to forgo the STL for want of a compliant version, if it exists at all. And even if it does, it's not set up for multiple heaps, nor using tiny heaps responsibly. While I could make custom allocators for everything, it's often just easier to use the C functions for what I need. I still make judicious use of class, struct, and template.

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              C Offline
              C Offline
              charlieg
              wrote on last edited by
              #6

              This is where I live as well, so it explains a lot. But in the herd of engineers I work with, I'll come across a mishmash of coding styles. In 20 years, the group has never been able to standardize on coding standards let alone development philosophy. And, as you say, one must be very careful using C++ features in an embedded RTOS environment. If those support libraries aren't coded correctly, you'll lose too much performance. Ah well, on 6/27, you'll find me by the pool.

              Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

              H 1 Reply Last reply
              0
              • C charlieg

                This is where I live as well, so it explains a lot. But in the herd of engineers I work with, I'll come across a mishmash of coding styles. In 20 years, the group has never been able to standardize on coding standards let alone development philosophy. And, as you say, one must be very careful using C++ features in an embedded RTOS environment. If those support libraries aren't coded correctly, you'll lose too much performance. Ah well, on 6/27, you'll find me by the pool.

                Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #7

                charlieg wrote:

                Ah well, on 6/27, you'll find me by the pool.

                Vacay or retirement?

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                C 1 Reply Last reply
                0
                • H honey the codewitch

                  charlieg wrote:

                  Ah well, on 6/27, you'll find me by the pool.

                  Vacay or retirement?

                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                  C Offline
                  C Offline
                  charlieg
                  wrote on last edited by
                  #8

                  retirement... for at least 3 months, we'll see how it goes.

                  Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                  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