Swift is a general-purpose, multi paradigm, object-oriented, functional, imperative and block structured language. Swift is the result of latest research on programming languages and is built using a modern approach to safety, software design patterns by Apple Inc. for iOS application, macOS application, watchOS application, tvOS application.
Swift is easy to learn, easy to implement, safe, fast and expressive. Developing Swift in the open has it’s own exciting aspects as it is now free to be ported across a wide range of platforms, devices, and use cases.
The features of Swift are designed to work together to create a powerful language. Additional features of Swift include:
- Closures unified with function pointers
- Tuples and multiple return values
- Concise and fast iteration over a range or collection
- Structs that support methods, extensions, and protocols
- Functional programming patterns, e.g., map and filter
- Powerful error handling built-in
- Advanced control flow with do, guard, defer, and repeat keywords
Memory Management –
Swift uses Automatic Reference Counting (ARC) to manage memory. Earlier, Apple used to require manual memory management in Objective-C, but after introducing ARC in 2011 memory allocation and de-allocation became easier.
Swift is managed as a collection of projects, each with its own repositories. The current list of projects include:
- The Swift compiler command line tool
- The standard library bundled as part of the language
- Core libraries that provide higher-level functionality
- The Swift REPL included LLDB debugger
- Xcode playground support to enable playgrounds in Xcode.
- The Swift package manager for distributing and building Swift source code
// Basic Swift Program import UIKit var str1 = "Hello geeks!" var str2 = "How are you?" print (str1) print (str2)
Hello geeks! How are you?
Run: Code can be tested on Online IDE for Swift
Note: Import statement is used to import any objective-C framework or library directly into Swift program.
var keyword is used for variable and let keyword is used for constant. There is no need of ; for termination, in case programmer uses it compiler won’t show error.
- Swift is open sourced and easy to learn.
- Swift is fast, safe and expressive.
- Swift is approachable and familiar (C and C++ code can be added by Swift programmers into Swift applications.)
- Swift is the future of Apple development.
- Swift is enterprise ready.
- The language is still quite young and talent pool is limited.
- Swift is considered a “moving target” as it is a new language and number of swift programmers are few.
- Poor interoperability with third-party tools and IDEs
- Lack of support for earlier iOS versions.
- Introduction to Swift Programming
- Features of C Programming Language
- Which Programming Language to Choose?
- Which Programming Language Should I Choose as a Beginner?
- Introduction of HIP parallel programming language
- Introduction to the C99 Programming Language : Part III
- Introduction to the C99 Programming Language : Part II
- Introduction to the C99 Programming Language : Part I
- Difference Between C Language and LISP Language
- Difference between Functional Programming and Object Oriented Programming
- fgets() and gets() in C language
- What is COBOL(Common Business Oriented Language)?
- Converting a List to Vector in R Language - unlist() Function
- Remove Leading whitespaces from a String in R Language - trimws() Function
- Modify values of a Data Frame in R Language - transform() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.