Separate names with a comma.
Discussion in 'iOS Programming' started by j2ee, Apr 2, 2017.
What is the real purpose of it?
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.
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.
Thx for sharing. So finally Xcode will not support new app to be developed with objective-c?
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.
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?
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.
Then why Apple develops itune and other Apple stuff with Objective-C even after they made Swift?
Your dates are a little off.
So is Apple transferring its own app to Swift?
Your guess is as good as anybody's. (outside of Apple that is)
There is no evidence that Objective-C is on its way out soon or at all.
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).
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.
Objective-C is also compiled. I think you're thinking of Java.
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.
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.
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.
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.
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.
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.