Swift is an open source programming language, introduced by Apple in 2014. It is used for their operating systems macOS for desktops and iOS for mobile devices, for instance iPhone or iPad. Since 2015 Swift has also been available on Linux under the Apache Licence 2.0[1]. It is a modern language that includes multiple paradigms like object orientation, functional- and imperative programming. Apple included useful features from other languages like C#, Ruby, Python or Haskell.
Before you can start with Swift, you first have to download and install the compiler and other components[2]. Those can be downloaded fromSwift's download page. On Linux, clang[3] has to be installed too using following command:
$ sudo apt-get install clang
Xcode is only available on macOS. However, there are alternatives which provide similar functionality:
Before we dive right into Swift's basic and advanced features, let's have a look at the world-famous "Hello World" example.
print("Hello World")
Now, let's have a first glance at what variables and constants look like.
varname:String="John"letgreeting:String="Welcome to the world of Swift, "print(greeting+name)// Welcome to the world of Swift, John