What is Swift?
What is Swift?
A school needs a program to display student information and calculate reports. Swift is a programming language for expressing that work as typed values, decisions and reusable operations. It is used for Apple-platform applications and also supports command-line and server programs. You can learn the language without first building an iPhone interface.
Source code is the text you write. A compiler checks it and translates it into executable code. Swift checks many type rules before execution, but compiling successfully does not prove your report calculations are correct. This course starts with console programs and gradually adds data modelling, persistence and concurrent work.
What you’ll learn
- Distinguish Swift source code, a compiler and console output.
- Separate the Swift language from an app interface framework.
What is Swift? in the example
Source text
A school needs a program to display student information and calculate reports.
Source textCompiled program
Source code is the text you write.
Compiled programConsole result
The declaration associates school with a text value.
Console result
Work through what is swift?
Save this complete program as main.swift and run it with the Swift toolchain. No separate input file is needed.
Swift · complete program
let school = "River School"
print(school)Expected output
River SchoolFollow the execution
The declaration associates school with a text value. The next statement passes that value to print, which writes one line to standard output. There is no interface framework or external library involved. The output is enough to inspect this first operation.
Try this program in the Swift compiler. Paste the complete source above.
Practice: What is Swift?
Your task: Would changing the school name require changing the print statement?
Swift · complete program
let school = "River School"
print(school)Worked answer
No. Change the string assigned to school; print still reads that named value. Separating data from the operation makes later changes easier to follow.
Separate the language from app frameworks
Swift is the language; SwiftUI and UIKit are interface frameworks. Console examples teach language behaviour, not the complete lifecycle of an app. The course later points to official app tutorials rather than implying that printing text creates an iPhone screen.
Check your decision
What is Swift? in practice
No. Change the string assigned to school; print still reads that named value. Separating data from the operation makes later changes easier to follow. Swift is the language; SwiftUI and UIKit are interface frameworks.
Further reading: official Swift language guide.
Reaching the recap and completing the quizzes are separate milestones.