History of programming languages: from Objective-C to Swift



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

    What made many developers switch to Objective-C? What now makes you abandon it and choose Swift?

    Objective-C is an extension of the C language to which new features for the object-oriented programming approach have been added. The language uses the Smalltalk object model. Fully compatible with the C programming language. Apple has long used Objective-C as the primary programming language for developing its products.

    The creators of Objective-C are Brad Cox and Tom Love. They started working on it in the early 1980s, when they were still employees of the telecommunications company ITT Corporation. Around the same time, Cox and Love became acquainted with the Smalltalk programming language. Cox was then occupied with the problems of reusing code.
    Due to the increase in the amount of code in projects and the difficulties of supporting it, a new, object-oriented programming paradigm began to form in the 1960s, breaking 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 set of data (invariants, members) and a set of routines (methods) that will serve them.

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

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

    Oopc


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

    What happened, Cox called “OOPC” - Object-Oriented Pre-Compiler. In 1982, Love settled in Schlumberger Research and was given the opportunity to purchase a commercial version of Smalltalk-80. This helped them in their further work on Objective C. As a result, the ability to create objects and work with them was implemented in Objective-C.



    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 to create a model in which the classes themselves are full-fledged objects, introspection and dynamic message processing would be supported. Any object can be sent any message. An object can instead send a message 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 run time.

    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 to be passed) and instance variables, check whether the class is a descendant of the given and supports the specified protocol, and so on.

    Next


    In 1986, Cox published the book Object-Oriented Programming, An Evolutionary Approach, which posted a description of his programming language, explored the problem of code reuse, and pointed out the benefits 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. Further, the fund was renamed StepStone.

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



    In 1992, GNU developers joined the OpenStep project to improve the language and compiler. Since then, GCC has supported Objective C.

    Not succeeding in the market as a computer manufacturer, NeXT turned its 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 purchasing NeXT, Apple took their SDK (compiler, libraries, IDE) as the basis for its further development . The IDE for code development is called Xcode, and for the GUI it is called Interface Builder. Cocoa framework for GUI development (and not only) is by far the most significant development environment for Objective-C programs.

    In 2007, Apple introduced an updated version of the language and named it Objective C 2.0, this version of the language is relevant at present. 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 opening of Swift source code, developers around the world can contribute to this programming language and make it available on new platforms,” said Craig Federigi, Apple's senior vice president of software. “The efficiency and simplicity of Swift will give young programmers incentives to learn, and now they can spread their ideas everywhere: from mobile devices to cloud systems.”



    The creator of the Swift language is Chris Lattner. He joined Apple in 2005. There he was involved in the development of LLVM. Apple used LLVM to change the way Objective C is used in building applications.
    LLVM (Low Level Virtual Machine) is a universal system for analyzing, transforming and optimizing programs or, as developers call it, “compiler infrastucture”.
    Chris Luttner oversees all the tools of Apple developers: everything with which programs are created for phones, tablets and Apple computers, both by third-party developers and engineers of the company. As a graduate student at the University of Illinois, he created a kind of developer tool called LLVM, which today underpins Xcode.
    Luttner 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 from the main work.

    After a year and a half, he talked about the project to Apple's top managers. Appreciating Luttner’s work, they sent several developers to help him. However, the project was still shrouded in a halo of mystery. Even 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 expanded significantly.

    According to Apple, the Swift language has every chance of changing the IT industry.

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



    Audience extension


    A programming language needs 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 worked on Go (Ken Thompson and Rob Pike), but to this day considerable efforts have been made to popularize it. However, Apple is doing everything to make Swift an exception and following the example of the Java and C # languages ​​in the 1990s and early 2000s, respectively.

    Swift is designed for the average programmer. Even the simplest applications can be written in a language, and endowed with fairly smart tools, the language offers an effective way to learn to write yourself. But the main reason for the future popularity of the language lies elsewhere. Hundreds of thousands of developers today create 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 significantly better and more effective than Objective C.

    On December 3, 2015, the company opened Swift source code. The worldwide community of developers, from application developers to companies and educational institutions, can develop Swift and optimize the language to make it accessible on new computing platforms.

    “There was no real incentive to use Google Go,” said Paul Jansen, who tracked the progress of various programming languages ​​for about fifteen years. “Swift has a stimulus.”

    In the ranking of TIOBE Swift takes 14th position. Over the year, he climbed 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 outperformed its predecessor.



    Today, on GitHub, the popular open source development repository, more than 2,500 projects use Swift.

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

    Swift is fast (the implementation speed of some algorithms is 3.9 times faster than in Python) and concise (developers got rid of the verbosity of Objective-C). Another important innovation is the ability to write code and see 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 quickly check their concepts in action and, in general, create 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.

    Also popular now: