I keep wondering - what are Apple’s plans for Swift and Objective-C? When Swift appeared in 2014, its creator Chris Lattner argued that these two languages ​​could coexist indefinitely. From the mailing list to Xcode users:
June 3, 2014
McLaughlin, Michael P.
Does anyone know if Apple is going to stop supporting C and C ++? Fortran is no longer supported, although there is still a lot of Fortran code, and a relatively new one, as in MultiNest.
Please tell me that it is not. Not everyone thinks that “experienced users” are those who simply create full-length cartoons. Many of them are scientists and engineers.
Hello Michael
We did not make plans for anything like that. Swift is just a new development option for the platform. We are not going to stop supporting neither C nor C ++ nor Objective-C. If you are developing in one of these languages, you can continue to use it freely.
- Chris.
Original text of the letter> On Jun 3, 2014, at 5:45 AM, McLaughlin, Michael P. <mpm ... @ mitre.org> wrote:
> Does it support C and C ++?
> That's what it sounded like. Fortran even though
> there is a * lot * of Fortran code, there is,
>
> Please say it isn't so. Not all of us consider “power users” to be just those
> who create feature-length cartoons. Many are scientists and engineers.
')
Hi Michael
We have no plans to do anything like that. Swift is a new option for developing
on the platform. We have no plans to drop C, C ++ or Objective-C. If you're
happy with them, please feel free to keep using them.
Chris
The fact is that no one believes in it. Chris Lattner left Apple a long time ago, and if his statement turns out to be false, he will not be able to accept criticism on behalf of the company. In general, the developers agreed that Apple would eventually abandon Objective-C, and Swift would be the only “first class” language for developing Cocoa applications.
The words "first-class language" are meaningful because there is no reason to stop supporting the compiler for Objective-C or to remove it altogether. The compiler supports many programming languages, including underused and old ones. So Lattner’s statement may be formally true, but that’s not the point. The question is in choosing a language for developing Cocoa-applications for iOS and macOS.
The developer community is probably right. I agree that Objective-C and Swift cannot continue to coexist indefinitely. However, I am not so sure that the future is in Swift. What if it is? I would like to dedicate this article to this scenario. First, let me tell you why Swift and Objective-C cannot coexist peacefully.
New Hope?
Neither Swift nor Objective-C are almost used outside of Apple platforms. This may change in the future, but at the moment it is a fact. So if you want to develop applications for Apple platforms, you need to study either of them, or both. “Which language should I learn?” Is a rather difficult question for a newbie. If you take one language, then the standard advice will be Swift. Although I do not agree with him, but I admit that it is standard. Smart heads will offer to learn both languages. But here lies the snag. If you need to master both platform-specific languages ​​only for writing applications, Apple platforms lose their appeal to developers. Swift liked developers because of its “modernity” and “familiarity”, rather than Objective-C. But if you still need to learn Objective-C, then what is the advantage? Third-party developers have adopted Swift, um ... quickly
(in the original it turned out to be a pun, Swift = "quickly" - approx. Lane) - Apple was told to jump - they jumped. Like Apollonia in
"Lake Minnetonka .
" Swift has become very popular. This caused a huge demand for Swift-resources. In mailing lists, forums, blogs, Stack Overflow, Twitter, and everywhere, developers want to know about Swift and discuss it. Swift has influenced the technical publishing industry. Even the labor market has affected - many companies intentionally, or because of the fashion of the language, or simply because of illiteracy, hire only Swift-developers. Many developers for Apple platforms do not know Objective-C. And many Objective-C developers take to using Swift exclusively, and to such an extent that Objective-C begins to forget and has difficulty if it comes back to it. Swift's fascination, the demand for it among developers, threatens to stifle Objective-C. These two languages ​​can coexist “officially” in the mind of Apple, but can they coexist informally with someone else? Can there be double - in each language - letters, blogs and wiki pages? What about open source projects - Objective-C or Swift? And, if the labor market moves almost exclusively to Swift, the developers have no choice but to go in the same direction.
The Empire Strikes Back
Judging by the above arguments, Objective-C is doomed. More developers prefer Swift. However, all is not lost, because non-developers manage Apple platforms. The only place where Swift does not yet dominate is, ironically, Apple themselves. The company is very slowly developing Swift. To date, Apple has implemented surprisingly little Swift code. A good analysis of this can be found
in one blog . Several explanations were suggested - many may call this an apology. For example, Apple frameworks cannot use Swift, because it has not yet reached ABI-stability (or even source-stability, for that matter). Whatever the explanation, the fact remains: Apple's internal Swift code base is relatively tiny, while the Objective-C base is most likely the largest in the world.
If Apple has to abandon one language right now, which one? Failure to Swift will be extremely painful for third-party developers. On the other hand, for Apple itself, this will pass almost imperceptibly - too little Swift code will have to be converted into Objective-C. Of course, Apple put a lot of effort into Swift, especially with regard to Xcode, however, this is a non-refundable cost. Apple will not throw money to the wind. In Objective-C, too, much has been invested, and these costs are even more irrevocable than those of Swift. What matters is not the price that has already been paid, but the price that will have to be paid in the future. Apple has nothing against sunk costs. According to rumors, they have invested a huge pile of money in a car project for which there is still nothing, and that it was mostly postponed.
Apple can rewrite all of its Objective-C code into Swift if they wish. Of course, they have resources for this. The amount of liquid assets that they own is simply overwhelming, unprecedented in history. However, their current corporate culture assumes that they cannot or will not carry out this transformation. There are several factors behind this. First, Apple has moved to the annual release cycle for all of its major OS versions. Indeed, the company reportedly hit the Agile philosophy of software development. This approach leaves too little time for complete rework. And we have already seen how quality is declining, and functionality is lost when Apple rewrites a technology or application from scratch.
Secondly, Apple is proud to hire the "best" engineers. I know a lot of experts from Apple and not, so I think this is a myth. But regardless of whether this is true or not, this is the company's point of view, and therefore, they are unlikely to be able to hire a huge number of people and throw all their resources into Objective-C code rewriting.
Thirdly, relying on the previous moments, I will say that the number of knowledgeable Objective-C is decreasing. Even if Apple wants to transfer a bunch of people to this task, where will they find them? If you need to rewrite Objective-C in Swift, naturally, you need specialists who understand both languages, without knowledge of Objective-C, the whole idea will turn into a catastrophe.
Apple's internal research also indicates that if
Sophie had to choose between two languages ​​today, it would definitely not be Swift. If you are a third-party developer, fully immersed in Swift, this thought, at least, should scare you. And ask yourself if today the pendulum swings in this direction, how much time must pass, and what should happen for it to swing back? At what time, in what year will it be more painful for the company to abandon Swift, rather than Objective-C?
Perhaps you are now grumbling, they say, Apple can not betray the developers so, abandoning Swift. How do Apple executives sleep at night? I suspect on mattresses stuffed with cash. They will not think twice. They can even praise themselves for courage. If you look at the history of Apple's relationship with developers, you will see a whole chain of refusals of support, disappointments, sufferings and unkept promises. Objective-C garbage collector, 64-bit Carbon, Cocoa-Java interface, Yellow Box for Windows, Dylan. Do I need to continue? I could. Apple evangelists will tell you that Swift is the best programming language, and then change their mind and say that they have always been against Swift.
Prequels
When Apple decided to create Swift, what was their plan? I see three options.
- They really intended to support both languages ​​indefinitely.
- Planned in the end to abandon Objective-C and go to Swift, what the developers believe.
- They did not have a specific plan, and in general were not sure that Swift would even shoot.
The first option is not suitable for the reasons described above, so that you can immediately dismiss it.
If the second was in effect, I would really like Apple to express it openly. The message from Lattner is at least misleading. If Swift is the future, so why not be frank with the developers, not share your plans with them so that they can adapt to them? Uncertainty is the worst that can be in this respect. We can agree that Swift is our future if we have no choice. But if Swift is Apple's choice, and they feed us with illusions that there is still a choice, then some of the developers may make the wrong choice, which is disastrous for everyone.
I believe that the third option is true. I know many people think that Apple is working on a grand, secret, megabyte plan. Does Apple have long-term plans? Sure. Are these plans specific? I doubt it. In the technical sphere, you can make long-term plans, but do not expect to be able to stick to them. Technology is changing ... fast. You need to be flexible (not like Agile, but just flexible). You need to be able to respond to what your competitors are doing. For example, Lettner's departure - was it in Apple’s plans? Plans change. They must change. Third-party developers immediately pounced on Swift, but Apple also had to take into account the possibility that it would pass unnoticed by them. Hoping for the best, plan for the worst.
Outcast one
By all accounts, the Swift project was secret even inside Apple. Only a select few knew about him. When it was announced openly, for most Apple engineers, this was as unexpected as for developers. Apple employees were not ready for this. And this represents the biggest challenge for Swift: internal conflicts between Apple’s development teams. Team-for-Swift, with support in the face of the leadership, presents Swift as the future of Apple application development. But the Swift Team cannot just sweep away the present and put the future in its place as an established fact. The present for Apple is Objective-C. Lots of Objective-C. Decade Objective-C, accumulated before the purchase of NeXT. The entire code base of Objective-C cannot simply disappear as if by magic. You represent Swift to a group of Apple teams that are limited in both time and resources; all they do is send you to hell. They may like the idea itself, but WWDC is close and needs a lot of work to do. Maybe in a year ... Or in two.
How can Apple reconcile these competing interests? They want to secure the future for Swift, but they also have a ton of Objective-C code, and they want to continue their flexible software development, while hiring only the best engineers. Yes, and maintain the quality of software. (I hope we can assume that they still care about quality.) Something will have to be sacrificed. Meanwhile, third-party developers will place greater demands on Swift resources. API descriptions are likely to be largely automated, so double stacking won't be a big problem, but Swift developers will need documentation and code examples. If Apple’s official position is to support both languages, do they write double documentation and double code examples? And how much effort do they put into updating old Objective-C documentation?
What is the community response to this problem? People who think that Apple will abandon Objective-C - how do you think they will cope with it? Some will suggest that Apple abandon the external use of Objective-C, but will continue to use it internally. However, I think these people underestimate the problem. Given the size of the Objective-C code base and the limitations that Apple is working with, the transition to Swift will indeed drag on. How long do you think the company will support all the tools for Objective-C? If your answer is not 5 years, not 10 years, or even not more than 10 years, I think you can’t imagine the volume of the entire task. For me, it seems highly unlikely that Apple will allocate separate resources to develop and support the internal version of Xcode, internal Objective-C API, internal Objective-C documentation (everyone needs documentation), etc. And again, if the company officially abandoned Objective-C, the number of Objective-C developers would fall at an even faster pace than now, so where is Apple going to find people to support the code base in the future?
Episode C
Let me refute possible counterarguments to the above by me. The counter argument is that Apple is already pulling a double stack of technologies: Objective-C and C. Foundation and Core Foundation. Therefore, the addition of another language is not something new and unknown. At first glance, this objection seems convincing, but there is a breach. Yes, Objective-C and C are two different languages, but it is impossible to draw an analogy with Swift, because Objective-C is, in fact, an add-in over C. If you study Objective-C and you study well, then you know C also. It does not matter that many people take on C first and then Objective-C. In fact, I was walking along this path, and would advise to follow him and others. But learning C and then Objective-C is not the same thing as learning two programming languages. In fact, this is just a two-step learning Objective-C. Everything you learned about C applies to Objective-C. It just works, so to speak. But Swift is not concerned. Of course, there are some intersections, because Swift was developed by people operating Objective-C, but by no means one of them is a superstructure above the other. Swift and Objective-C are incompatible much worse than, say, C ++ and C, which are very close, but not quite compatible.
In addition, C is not an iOS and macOS application development language. Can you create an application on pure C? Perhaps, but certainly not easy. The C API for development was not Cocoa, but rather Carbon, and Carbon Apple was largely abandoned. There are several supported APIs for C on Apple platforms, but still C is not as close to developing iOS and macOS applications as Objective-C and Swift.
Some kind of revenge
These are just my suspicions, but it seems to me that Apple did not expect Swift to become so popular so quickly. This whole strategy would be more meaningful if Swift had developed slowly over the years. A double stack is advantageous if the developers are distributed over two camps roughly evenly. Apple and third-party developers would have enough time to rewrite existing code from Objective-C to Swift. Swift may be our future, it may be the only language to develop, but this is the distant future. It may be a mistake in planning or imagining that Swift can suddenly overwhelm Objective-C in the mindset of developers. And now Apple has faced a difficult choice. How do they cope with the unexpected popularity of Swift outside the company, when they are not ready for it inside it?
I suspect that Apple will fall away from Swift. I think Lettner’s resignation makes this opportunity even more likely. Many developers put all their resources on Swift. This could seem like a good investment at the time, and it may be paying off. It probably pays off. What if not? Suddenly there will be a change of management, or just change the mood inside the management? What if Apple suddenly decides that their internal limitations are harder to overcome than they expected and language changes are unprofitable? Can you rule out this possibility? I'm afraid many are not ready for such a cruel world. If this happens, there will be a lot of tears and screams. But not among Objective-C developers who will laugh and have fun, as if in the courtyard of 1999. In a pinch, 2001.