{"id":1384,"date":"2021-08-31T07:21:07","date_gmt":"2021-08-31T07:21:07","guid":{"rendered":"https:\/\/blog.amt.in\/?p=1384"},"modified":"2021-08-31T07:21:07","modified_gmt":"2021-08-31T07:21:07","slug":"introduction-to-swift","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2021\/08\/31\/introduction-to-swift\/","title":{"rendered":"Introduction to Swift"},"content":{"rendered":"<p>Swift\u00c2\u00a0is a\u00c2\u00a0general-purpose,\u00c2\u00a0multi-paradigm,\u00c2\u00a0compiled\u00c2\u00a0programming language\u00c2\u00a0developed by\u00c2\u00a0Apple Inc.\u00c2\u00a0for\u00c2\u00a0iOS,\u00c2\u00a0macOS,\u00c2\u00a0watchOS,\u00c2\u00a0tvOS, and\u00c2\u00a0Linux. Swift is designed to work with Apple&#8217;s\u00c2\u00a0Cocoa\u00c2\u00a0and\u00c2\u00a0Cocoa Touch\u00c2\u00a0frameworks\u00c2\u00a0and the large body of existing\u00c2\u00a0Objective-C(ObjC) code written for Apple products. It is built with the open source\u00c2\u00a0LLVM\u00c2\u00a0compiler\u00c2\u00a0framework and has been included in\u00c2\u00a0X code\u00c2\u00a0since version 6. On platforms other than Linux,\u00c2\u00a0it uses the Objective-C\u00c2\u00a0run-time library\u00c2\u00a0which allows\u00c2\u00a0C, Objective-C,\u00c2\u00a0C++\u00c2\u00a0and Swift code to run within one program.<\/p>\n<p>Apple intended Swift to support many core concepts associated with Objective-C, notably\u00c2\u00a0dynamic dispatch, widespread\u00c2\u00a0late binding,\u00c2\u00a0extensible programming\u00c2\u00a0and similar features, but &#8220;safer&#8221; (easier to catch\u00c2\u00a0software bugs); Swift has features addressing some common\u00c2\u00a0programming errors\u00c2\u00a0like\u00c2\u00a0null pointers\u00c2\u00a0and provides\u00c2\u00a0syntactic sugar\u00c2\u00a0to help avoid the\u00c2\u00a0pyramid of doom. Swift supports the concept of\u00c2\u00a0protocol\u00c2\u00a0extensibility, an extensibility system that can be applied to types,\u00c2\u00a0structs\u00c2\u00a0and\u00c2\u00a0classes, which Apple promotes as a real change in programming paradigms they term &#8220;protocol-oriented programming&#8221;\u00c2\u00a0(similar to\u00c2\u00a0traits).<\/p>\n<p>Swift was introduced at Apple&#8217;s\u00c2\u00a02014 Worldwide Developers Conference\u00c2\u00a0(WWDC).\u00c2\u00a0It underwent an upgrade to version 1.2 during 2014 and a more major upgrade to Swift 2 at WWDC 2015. Initially a\u00c2\u00a0proprietary language, version 2.2 was made\u00c2\u00a0open-source software\u00c2\u00a0under the\u00c2\u00a0Apache License\u00c2\u00a02.0 on December 3, 2015, for Apple&#8217;s platforms and\u00c2\u00a0Linux.<\/p>\n<p>In March 2017, Swift made the top 10 in the monthly\u00c2\u00a0TIOBE index\u00c2\u00a0ranking of popular programming languages,\u00c2\u00a0and was ranked 11th at the end of 2017.\u00c2\u00a0By October 2017, however, Swift had begun to lose momentum in the TIOBE index as mobile development moved toward\u00c2\u00a0Xamarin\u00c2\u00a0and\u00c2\u00a0C#, as well as similar tools for\u00c2\u00a0JavaScript. As of April 2018, Swift ranked No. 15 at 1.53% share, losing 0.75% from its 2.28% share just one year earlier.<\/p>\n<p>Different major versions have been released at an annual schedule with incompatible syntax and library invocations each, requiring significant source code rewrites. For larger code bases this has caused many developers to dismiss Swift\u00c2\u00a0\u00c2\u00a0until a more stable version becomes available.<\/p>\n<p>Swift is an alternative to the Objective-C language that employs modern programming-language theory concepts and strives to present a simpler syntax. During its introduction, it was described simply as &#8220;Objective-C without the C&#8221;.<\/p>\n<p>By default, Swift does not expose pointers and other\u00c2\u00a0unsafe\u00c2\u00a0accessors, in contrast to Objective-C, which uses pointers pervasively to refer to object instances. Also, Objective-C&#8217;s use of a\u00c2\u00a0Small-talk-like syntax for making\u00c2\u00a0method calls\u00c2\u00a0has been replaced with a dot-notation style and\u00c2\u00a0namespace\u00c2\u00a0system more familiar to programmers from other common\u00c2\u00a0object-oriented\u00c2\u00a0(OO) languages like\u00c2\u00a0Java\u00c2\u00a0or\u00c2\u00a0C#. Swift introduces true\u00c2\u00a0named parameters\u00c2\u00a0and retains key Objective-C concepts, including\u00c2\u00a0protocols,\u00c2\u00a0closures\u00c2\u00a0and\u00c2\u00a0categories, often replacing former syntax with cleaner versions and allowing these concepts to be applied to other language structures, like\u00c2\u00a0enumerated types\u00c2\u00a0(enums).<\/p>\n<p>The above is brief about Swift. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swift\u00c2\u00a0is a\u00c2\u00a0general-purpose,\u00c2\u00a0multi-paradigm,\u00c2\u00a0compiled\u00c2\u00a0programming language\u00c2\u00a0developed by\u00c2\u00a0Apple Inc.\u00c2\u00a0for\u00c2\u00a0iOS,\u00c2\u00a0macOS,\u00c2\u00a0watchOS,\u00c2\u00a0tvOS,<\/p>\n","protected":false},"author":1,"featured_media":1385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[154,175,7],"tags":[156,178,18],"class_list":["post-1384","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-language","category-swift","category-techtrends","tag-programming-language","tag-swift","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=1384"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1384\/revisions"}],"predecessor-version":[{"id":1386,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1384\/revisions\/1386"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/1385"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=1384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=1384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=1384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}