Introduction
Swift is Apple's language for building iOS, macOS, watchOS, and tvOS apps, first released in 2014 as a safer, faster replacement for Objective-C. It's statically typed and compiled, and its compiler is deliberately strict about the kinds of mistakes that used to crash apps at runtime.
Your first Swift program
A Swift file needs no boilerplate — no class wrapper, no main function required for a simple script. print() writes to standard output:
print("Hello, Swift!")
Hello, Swift!
Where Swift code runs
The easiest way to try Swift without installing anything is an online playground, or Xcode's built-in Playgrounds feature if you're on a Mac — both give you a line-by-line editor that shows each expression's result immediately. For a real app, Xcode compiles your Swift code into a native binary using the same LLVM-based toolchain that also compiles C and C++.
Comments and semicolons
// this is a single-line comment print("No semicolon needed") // but one is allowed here too
No semicolon needed