What is Swift?Edit
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. 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.
Swift on LinuxEdit
Before you can start with Swift, you first have to download and install the compiler and other components. Those can be downloaded from . On Linux, clang has to be installed too using following command:
$ sudo apt-get install clang
IDE for LinuxEdit
is only available on macOS. However, there are alternatives which provide similar functionality:
- . offeres a Swift extension which features code highlighting and completion and also a debugger
- The Open-Source Editor . offeres a plugin that works similar to Xcode's playground where you can easily try new code and immediatly see what it does
Before we dive right into Swift's basic and advanced features, let's have a look at the world-famous "Hello World" example.
Now, let's have a first glance at what variables and constants look like.
var name: String = "John" let greeting: String = "Welcome to the world of Swift, " print(greeting + name) // Welcome to the world of Swift, John
- Apache Software Foundation [online][accessed: 18.09.2017] | https://www.apache.org/licenses/LICENSE-2.0
- Swift.org [online][accessed: 18.09.2017] | https://swift.org/getting-started/
- clang [online][accessed: 18.09.2017] | https://clang.llvm.org
- JetBrain Swift Plugin [online][accessed: 18.09.2017] | https://blog.jetbrains.com/clion/2015/12/swift-plugin-for-clion/
- Atom.io Swift Playground [online][accessed: 18.09.2017] | https://atom.io/packages/swift-playground