Programming languages
Swift
Apple's modern safe language for iOS, macOS and other platforms, also available on Linux and Windows.
What it is
Apple introduced Swift in 2014 as the successor of Objective-C. It has been open source under Apache-2.0 since 2015, and the compiler is built on LLVM.
Swift is statically typed, with optionals instead of null, value types (structs), protocols and automatic memory management (ARC). Version 5.5 added async / await and actors, and Swift 6 added strict data race checking.
Its main niche is apps for iOS, iPadOS, macOS, watchOS and visionOS, often with SwiftUI. There are server frameworks (Vapor) too, though that is a smaller part of the ecosystem.
Use it when
- A native app for Apple platforms with access to every system API.
- You need top performance and integration with iOS and macOS.
- New code in a project that used to be Objective-C.
Avoid it when
- One codebase for iOS and Android on a small budget: Flutter or React Native fit better.
- General backends, where Swift's ecosystem is much smaller than Go or Java.
Key concepts
- Optionals
- A
String?type explicitly marks a possibly missing value, unwrapped withif letorguard let. - Value vs reference types
structandenumare copied,classis passed by reference.- Protocols
- A description of behavior any type can adopt and extend through extensions.
- ARC
- Automatic Reference Counting: memory is freed when no references remain.
weakbreaks cycles. - async / await and actors
- Structured concurrency and state isolation without manual locks.
Example
Interview questions
1. How does a struct differ from a class in Swift?
A struct is a value type and is copied when passed, a class is a reference type. Apple recommends starting with structs and using classes when you need identity, shared state or inheritance.
2. What is an optional?
A wrapper type that holds either a value or
nil. The compiler forces you to unwrap it (if let,guard let,??), so a missing value is never overlooked.3. What are ARC and a retain cycle?
ARC counts strong references and frees an object at zero. If two objects strongly reference each other, a cycle and a leak appear. You break it with
weakorunowned.4. What are actors for?
An actor guarantees that only one task mutates its state at a time. That removes data races without manual locking.
Related technologies
- SwiftUIApple's declarative UI framework for iOS, macOS, watchOS, tvOS and visionOS in Swift.
- KotlinA modern concise language for the JVM, Android and multiplatform development, fully interoperable with Java.
- FlutterGoogle's UI framework in Dart: one codebase for mobile, web and desktop with its own rendering.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).