📜 ⬆️ ⬇️

History of programming languages: from Objective C to Swift



To abandon a programming language in which commercial development is already underway, and to start learning a new one, programmers need a good reason. But the history of the IT industry knows many cases where the choice for them was made by time, and the transition took place as if by itself.

What made a lot of developers switch to Objective C? What makes you abandon it now and choose Swift?
')
Objective-C is an extension of the C language to which new features have been added for the object-oriented programming approach. The language uses the Smalltalk object model. Fully compatible with C programming language. Apple has long used Objective C as the main programming language for developing its products.

The creators of Objective C are Brad Cox and Tom Love. They began working on it in the early 1980s, when they were still employed by the telecommunications company ITT Corporation. At about the same time, Cox and Love became familiar with the Smalltalk programming language. Cox then took up the problem of re-using code.
Due to the increase in the amount of code in the projects and the complexity of its support, from the 1960s a new, object-oriented programming paradigm began to form, breaking up the programs into even smaller components - data types.



Each object is a variable of a data type defined by the programmer (the so-called class). The definition of such a special user data type (class) consists of two things: the definition of a data set (invariants, members) and a set of subroutines (methods) that will serve them.

The main advantage of the object-oriented approach is the ability to create new classes based on those already written (add invariants and methods, redefine methods, use methods defined in the base class as your own), called inheritance.

A set of methods is an interface for interacting with invariants.

OOPC


Brad Cocos quickly realized that Smalltalk was not suitable for solving problems in ITT Corporation: compatibility with the C language was critical for them. However, Cox decided to modify the C preprocessor in the direction of Smalltalk.
This modification consisted in adding new syntactic constructions and a special preprocessor for them (which, passing through the code transformed them into ordinary calls of C functions), as well as a new runtime library (these calls are processing). Thus, Objective-C was initially perceived as an add-on over C. In a sense, this is still the case: you can write a program in pure C, and then add some constructs from Objective C to it (if necessary), or vice versa, use C freely in Objective-C programs. In addition, this also applies to C ++ programs.

What turned out, Cox called "OOPC" - Object-Oriented Pre-Compiler. In 1982, Love worked at Schlumberger Research and was given the opportunity to purchase the commercial version of Smalltalk-80. This helped them to further work on Objective C. As a result, Objective C had the ability to create objects and work with them.



Cox's goal was to create a language that supports the concept of software IC, which implies the ability to assemble programs from ready-made components (objects), just as complex electronic devices can be assembled from a set of ready-made integrated circuits. At the same time, the language should be simple and based on the C language in order to facilitate the transition of developers to it.

One of the goals was also the creation of a model in which the classes themselves are full-fledged objects, introspection and dynamic processing of messages would be supported. Any object can send any message. The object, instead of processing the message, can send it to another object for processing (delegation), in particular, it is possible to implement distributed (that is, located in different address spaces and even on different computers) objects.

The binding of the message to the corresponding function occurs at the execution stage.

The Objective-C language supports working with meta-information — for example, at runtime, you can find out the class of an object, a list of its methods (with the types of arguments passed) and instance-variables, check whether the class is a descendant of the specified and supports the specified protocol and so on.

Next


In 1986, Cox published the book Object-Oriented Programming, An Evolutionary Approach, in which he posted a description of his programming language, sorted out the problem of code reuse and pointed out the advantages of Objective C in solving it. Love and Cox also created Productivity Products International (PPI), which was supposed to help monetize the Objective C compiler with class libraries. Next, the foundation was renamed StepStone.

In 1988, NeXT Software licensed the Objective C language, improved its libraries, and added new ones — the AppKit and Foundation Kit. Based on them, the NEXTSTEP development environment was later created.



In 1992, the developers of the GNU project as part of the OpenStep project joined the improvement of the language and compiler. Since then, GCC supports Objective C.

Failing to succeed in the market as a computer manufacturer, NeXT turned its full attention to creating and selling software development tools.

On December 20, 1996, Apple bought NeXT Software, and the NEXTSTEP development environment became the main development environment for the future major version of Apple's operating system, OS X.

After buying NeXT, Apple took their SDK (compiler, library, IDE) as the basis for their further development. IDE for code development was called Xcode, and for GUI - Interface Builder. Cocoa development framework for GUI development (and not only) today is the most significant development environment for Objective-C programs.

In 2007, Apple presented an updated version of the language and called it Objective C 2.0, this version of the language is relevant now. Used in the development of Apple OS X, iOS.

Swift


In 2014, Apple introduced a new programming language - Swift. It has become the fastest growing programming language in history.

“With the discovery of Swift source code, developers around the world can contribute to this programming language and make it available on new platforms,” said Craig Federigi, senior vice president of software engineering at Apple. “Swift's efficiency and simplicity will give young programmers the incentive to learn, and now they can spread their ideas everywhere: from mobile devices to cloud systems.”



The creator of Swift is Chris Lattner. He joined Apple in 2005. There he was engaged in the development of LLVM. Apple used LLVM to change the way Objective C is used to create applications.
LLVM (Low Level Virtual Machine) is a universal system for analyzing, transforming and optimizing programs or, as the developers call it, “compiler infrastucture”.
Chris Lattner oversees all Apple developer tools: everything that creates programs for phones, tablets and Apple computers, both by third-party developers and by the company's engineers. As a graduate student at the University of Illinois, he created a kind of developer tool called LLVM, which today underlies Xcode.
Lattner also used LLVM as the basis for Swift. These two products were specifically created to work in tandem.

He began working on Swift in the summer of 2010. Lattner kept it a secret for a year and a half. He created Swift in his spare time.

After a year and a half, he told Apple top managers about the project. Highly appreciating Lattner's work, they sent several developers to help him. However, the project was still shrouded in a halo of mystery. Even the people who indirectly participated in the creation of the language and helped Chris were very surprised at what exactly he worked on. After another year and a half, the Lattner project was included in the list of the main directions of the company, and the development team has expanded significantly.

According to Apple, Swift has every chance to change the IT industry.

On June 2, 2014, the company released a test version for third-party developers and programmers. Apple is positioning this language as a faster and more efficient way to create programs for the iPhone, iPad and Mac.



Audience expansion


A programming language takes several years to become popular even in narrow circles of enthusiasts. The situation with the Go language, which Google introduced back in 2009, is quite indicative. The best minds (Ken Thompson and Rob Pike) worked on Go; however, considerable efforts are still being made to popularize it. However, Apple is doing everything to make Swift an exception and follow the example of Java and C # in the 1990s and early 2000s, respectively.

Swift is designed for the average programmer. Even the simplest applications can be written in the language, and endowed with fairly clever tools, the language offers an effective way to learn how to write independently. But the main reason for the future popularity of the language lies elsewhere. Hundreds of thousands of developers today are creating applications for Apple devices using Objective C. Apple devices are very popular, which means these developers will continue to create applications for them, but already on Swift. According to Apple, it is much better and more efficient than Objective C.

December 3, 2015 the company opened the source code Swift. The global developer community — from application creators to companies to educational institutions — can develop Swift and optimize the language to make it available on new computing platforms.

“There was no real incentive to use Google Go,” says Paul Jansen, who has been tracking the progress of various programming languages ​​for about fifteen years. "Swift is distinguished by the presence of an incentive."

In the ranking, TIOBE Swift occupies the 14th position. For the year he rose to 3 positions. The Go language has moved from position 95 to 20, which is very impressive. And Objective-C dropped from 6th place to 15. Thus, we can say that Swift technically bypassed its predecessor.



Today, on GitHub, a popular open source repository for development, more than 2500 projects use Swift.

Swift is not just a language, it is a language that is closely connected with everything that a developer needs for work. This includes not only the integrated development environment, but also many other tools (for example, a debugger) that are already familiar to every Apple developer.

Swift is fast (the speed of implementation of some algorithms is 3.9 times faster than in Python) and laconic (developers got rid of the verbosity of Objective C). Another important innovation is the ability to write code and see the results in real time.

Prior to this, for a long time the process of creating a software product and the product itself were separated, and because of this, programmers had to spend a lot of time checking and optimizing the code. In Swift, they can make corrections and immediately see the result. This means that developers will be able to test their concepts faster and more generally build applications faster.

PS Apple is not the first company to release a new programming language in the recent past. This has already been done by Facebook, Google and Mozilla. Where this will lead - time will tell.

Source: https://habr.com/ru/post/308450/


All Articles