Why Apple brings up Swift and Kicks out Objective-C?

Discussion in 'iOS Programming' started by j2ee, Apr 2, 2017.

  1. j2ee Suspended

    j2ee

    Joined:
    Apr 21, 2015
  2. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #2
    Swift is just better. Just on a syntactic level it makes a lot more sense than Objective-C.

    And I'm saying this as someone who started out in Objective-C and still has an irrational love of it.
     
  3. firewood, Apr 2, 2017
    Last edited: Apr 2, 2017

    firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #3
    • To allow the LLVM compiler toolchain to potentially do more optimization and error checking than was reasonably possible with generic Objective C and its C subset.
    • To reduce the percentage of apps submitted to Apple's App store that produce crash dumps due to some too common and typical bugs and flaws (especially when using the C subset of Objective C).
    • To remove some of the indeterminicity and memory footprint of the Objective C runtime interpreter.
    • To start fresh, thus allowing the community to contribute some newer software engineering concepts to the evolution of an Open Source programming language.
    • And to do so for multiple (including non-Apple) platforms.
    Objective C is over 30 years old (and was based on two even older languages). While those languages included a ton of good ideas of that era, compiler writers have learned stuff since then; and typical software development methodology has changed quite a bit since then as well.

    BTW, Apple hasn't "kicked out" Objective C. A lot of Apple's own apps are still being developed in Objective C.
     
  4. j2ee thread starter Suspended

    j2ee

    Joined:
    Apr 21, 2015
    #4
    Thx for sharing. So finally Xcode will not support new app to be developed with objective-c?
     
  5. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #5
    If Apple did that, they would not be able to maintain and improve their own major apps (iMovie, iTunes, etc.). So quite unlikely until after you see those apps completely ported to Swift (you can tell when because the binaries will contain Swift libraries instead of Objective C class and method signatures.) Which might take years.
     
  6. j2ee thread starter Suspended

    j2ee

    Joined:
    Apr 21, 2015
    #6
    So Swift is more like C#/Java while Objective-C is more like C++, and for complicated and loading speed matter a lot, objective-c is still better than swift but just need a whole pro team to work on it?
     
  7. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #7
    More like the opposite, since Swift, C and C++ are compiled (thus potentially fast and small), but Obj C needs a run-time. The similarity is that both C++ and Obj C are old (mature? or aged?) languages.
     
  8. j2ee thread starter Suspended

    j2ee

    Joined:
    Apr 21, 2015
    #8
    Then why Apple develops itune and other Apple stuff with Objective-C even after they made Swift?
     
  9. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #9
    Your dates are a little off.
     
  10. j2ee thread starter Suspended

    j2ee

    Joined:
    Apr 21, 2015
    #10
    So is Apple transferring its own app to Swift?
     
  11. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #11
    Your guess is as good as anybody's. (outside of Apple that is)
     
  12. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #12
    There is no evidence that Objective-C is on its way out soon or at all.
     
  13. darkgoob macrumors 6502

    Joined:
    Oct 16, 2008
    #13
    Maybe they eventually will be 100% Swift, but it's not practical to rewrite a whole project. There might be new classes for their Obj. C apps being written in Swift, since you can write apps in both at the same time.

    Also bear in mind that those are not the only two languages used on Apple's platforms. For one there is Metal Shading Language, which is based on C++, and is used for GPU stuff. Then there is straight C, which you can write alongside your Obj. C code. And finally, C++ itself is still used for some parts of Audio Units (see the .mm files in this example).

    As well, Apple accepts apps written in Java (using Google's j2objc), C# (using Xamarin), or JavaScript (using FaceBook's ReactNative [transpiled] or Telerik's NativeScript [custom runtime based on V8]). I'm sure there are others as well. People use these alternatives when they want to have a shared codebase across multiple platforms (e.g. iOS, web, and Android). You give up some of the advantages of fully native development in XCode, and you put yourself somewhat at the mercy of a third-party stack of dependencies, in exchange for writing less code.

    Web developers may laugh at the idea of "being at the mercy of a third-party stack of dependencies," since that's what every web app is nowadays, but I mean, with a website, you control 100% of the stack all the way down to the version of linux the server runs on, and all you really have to worry about are browser-specific issues.

    However, with iOS or Mac, you don't control whether users upgrade to the latest OS version the day it comes out. What if your third-party dependencies fail and don't have a new version yet? Just know the risks.

    Sorry, that was a bit of a tangent.
     
  14. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #14
    Objective-C is also compiled. I think you're thinking of Java.
     
  15. bjet767 macrumors 6502a

    Joined:
    Oct 2, 2010
    #15
    Swift was brought in to attract a new audience of programmers whose base is not C or any of its subsets.

    It was also developed/improved by a master compiler designer who just recent left Apple for other things.

    I would also imagine that Apple's internal apps are not all written in ObjectiveC; they probably have a "lower level" language designed for speed and code optimization. But that's just a guess.
     
  16. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #16
    No need to guess. The open sourced portions of the "lower levels" of Mach and Darwin (OSX kernel) are in C. The open source portions of WebKit (for Safari) are in C++. For graphics, the LLVM Metal GPU compiler compiles a subset of C++.

    Knowing how to code in C (or knowing how to do "C-like" code in Swift) is still important for doing optimized or low level stuff.
     
  17. bjet767 macrumors 6502a

    Joined:
    Oct 2, 2010
    #17
    There you go!

    Back in the day to program MS Windows, before the C++ Foundation Classes, the code had to be written C and was more than laborsome. Every Window/View had to be built and allocted into memory. Then along came MFC and life got easier. I also seem to remember the inital C libs and compiling required the use "Pascal" calling flags, something to do with bit alignment. But I could be wrong.

    Anyway the whole point of Swift is to attract new programmers who "turn their nose up" at C, so to speak, and Apple invested in the man and the tech to make it a good and fast language.
     
  18. spiffers Suspended

    Joined:
    Apr 12, 2009
    #18
    When Apple revealed Swift, they presented it as Objective-C without the C. The Objective-C APIs are still evolving, and in the "Swiftification" of libraries, the good 'ole Objc has gotten a great overhaul. So Swift has not weakened Objc, it has actually made it more modern. Also the protocol oriented programming mindset has "leaked" over to the "other side". Look at both as siblings. Objc is the older and wiser sister, and Swift the little naughty brat that wants to go its own ways. They still manage to co-exist.
     
  19. Gidjit-SmartLauncher

    Joined:
    Apr 19, 2017
    Location:
    Baltimore
    #19
    I have to say after switching from Obj-c to Swift I would never go back. There were some difficulties at first. Xcode's building and parsing of Swift were super slow. The swift migrations were kind of a pain, however it is much better now. The language is nice and I would recommend anybody beginning a new project to use Swift.
     
  20. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #20
    I'm in the same place language-wise. Swift is a better language than Obj-C. You can write more concise, more expressive code in swift.

    However the tools just aren't as mature. I recently updated an old objective-C project. The whole project builds in about ten seconds. My swift projects take five minutes to build. And if only the debugger worked reliably with Swift. And if only symbolicated swift crashlogs made sense.
     

Share This Page