Description #
Swift is a fast, safe, and modern programming language developed by Apple. It is primarily used for building iOS, macOS, watchOS, and tvOS applications, and is known for its expressive syntax and strong safety features.
History #
Swift was announced by Apple at WWDC in 2014 as a successor to Objective-C. Created by Chris Lattner and Apple’s developer tools team, Swift aimed to address the limitations of Objective-C while maintaining compatibility with existing Apple frameworks. Swift quickly gained popularity among Apple developers and became open-source in 2015, extending its reach to Linux and other platforms.
Hello World Code #
print("Hello, World!")
How to Run #
Option 1: Online
Option 2: Local
- macOS users can use Xcode or Swift Playgrounds
- Linux users can install Swift from swift.org
To run in terminal:
swift hello.swift
Key Concepts #
- Compiled to native machine code
- Type inference and strong type safety
- Optionals for null safety
- Functional programming features
- Protocol-oriented design
- Powerful standard library
- SwiftUI for UI development
- Interoperable with Objective-C
- Memory-safe by default
- Open-source and cross-platform
Try It Online #
Fun Facts #
- Apple replaced Objective-C with Swift for new projects, but both can coexist in the same codebase.
- Swift was ranked one of the most loved languages on Stack Overflow shortly after its release.
- Swift can now be used for server-side development via frameworks like Vapor.