Skip to Main Content
UC Logo
Libraries | Ask the Libraries

Swift (programming language)

Introduction to Swift programming

Introduction

What is Swift?

Swift is a general purpose, compiled programming language which was started by Chris Lattner and team in 2010 and further developed by Apple Inc. for modern approach to software design patterns like macOS, iOS, watchOS, tvOS, and beyond. 

How is Swift different from other languages?

Swift developer base has recently grown beyond apple products with support for cross platform operability. The heart of the Swift language is its LLVM compiler environment which converts the code to intermediate representation known as LLVM-IR. This allows swift to either compiler the IR to stand along binary or perform JIT (Just In Time) compilation. Swift playground in Xcode also allows REPL (Read-Eval-Print loop) to evaluate expressions as soon as they are written.

Please visit LLVM, JIT, REPL  for more information.

Why is it used?

Swift version 2.2 released in 2016 can run on linux and version 5.3 in 2020 become available for the Windows operating system. Swift is open-source and cross-platform, so Swift code can run on Apple products and also Linux and Windows. The Swift programming language gained popularity and became the top choice of developers who built apple apps. Swift use is not limited to developing apps for Apple products as it is designed to be a general-purpose language and is being used to develop web services and even web applications.

Where is it used?

Swift is a efficient, stable and secure programming language and is gaining popularity for

  • Mobile applications development. It is a official language to develop iOS apps.
  • ML based mobile and web applications. 
  • Facebook, Uber, Slack. Lyft  uses swift for the development.
  • Stand alone desktop application can also be implemented.
  • Data Science. reference

Please visit swift_documentation for more information about swift programming language.

Get Started

Swift uses an LLVM based compiler to execute the code. The LLVM compiler enables JIT compilation on LLVM-IR to generates byte code for the interpreter.  Swift programming code can be written in multiple ways. Some them are listed below:

Stand-alone Swift Installation

Swift is supported on all the major operating systems. Click the following links to download the latest release for the respective operating systems. 

  • Windows 
    •  For more help on installation, visit this page.
  • macOS
    • For more help on installation, visit this page.
  • Linux/Unix
    • For more help on installation, visit this page
Visual Studio Code

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and open source IDE with extension based support for most languages.

  • Download and install Visual Studio Code distribution from here.
  • Please visit this page for more information on how to add Swift extension to VS code.
Jupyter Notebook Installation using 'pip'

Jupyter Notebook is a web-based tool to run live code including Python. Install Python before installing the stand-alone Jupyter Notebook. After the Python's installation, type one of the following commands in the command terminal.

  • 'pip install jupyter notebook' or 'pip3 install jupyter notebook'

'pip' is the keyword that is used to install missing libraries/packages in Python. Please visit this page to know more about 'pip'.

Note: Make sure the PATH variable is set properly before installing any Python related package. Click the following links to learn how to set the PATH variable in the respective operating systems.

    1. Right-click 'This PC' and go to 'Properties'.
    2. Click the 'Advanced system settings' on the right under 'Related settings'.
    3. Click the 'Environment Variables' button present at the bottom.
    4. In the 'System variables' section, select the 'Path variable' and click 'Edit'. This will display all the directories that are currently a part of the PATH variable.
    5. Click 'New' and enter Python’s install directory (Installation directory can be found at C:\Users\Username\AppData\Local\Programs\Python\Python310).

Jupyter Support Swift Language.

    1. 'csh' shell − type setenv PATH "$PATH:/usr/local/bin/python" and press Enter.
    2. 'bash' shell (Linux) − type export PATH="$PATH:/usr/local/bin/python" and press Enter.
    3. 'sh' or 'ksh' shell − type PATH="$PATH:/usr/local/bin/python" and press Enter.
    • (Installation directory can be found at /usr/local/bin/python)

University of Cincinnati Libraries

PO Box 210033 Cincinnati, Ohio 45221-0033

Phone: 513-556-1424

Contact Us | Staff Directory

University of Cincinnati

Alerts | Clery and HEOA Notice | Notice of Non-Discrimination | eAccessibility Concern | Privacy Statement | Copyright Information

© 2021 University of Cincinnati