Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift for Rubyists

Swift for Rubyists

Bridging the Gap

Avatar for Zoran Majstorovic

Zoran Majstorovic

November 19, 2025
Tweet

More Decks by Zoran Majstorovic

Other Decks in Programming

Transcript

  1. Intro 1. Why Swift? 2. How it started? 3. Syntax

    & Basics - First impressions 4. Static vs. Dynamic typing: types & type inference 5. Classes and Structs - Reference vs. Value types 6. Conditionals and loops 7. Functions & Closures 8. Handling nil safely: Optionals 9. Protocols & Extensions 10. Summary
  2. Why Swift? • Performant: Compiled language, often significantly faster than

    interpreted Ruby. ◦ Statically typed, compiled, automatic reference counting (ARC). • Expressive: Concise yet powerful syntax, inspired by modern languages. • Growing Ecosystem: Strong backing from Apple, active community: ◦ cross-platform: iOS, macOS, Linux, and Windows ◦ coming to Android devices (early stage) ◦ server frameworks (Vapor, Kitura, Hummingbird, and more)
  3. Christopher A. Lattner started in 2010, open-sourced v2.2 in 2015

    (no. 1 in Most Loved Programming Language in the Stack Overflow Developer Survey in 2015) Current version: 6.2 How it started Yukihiro Matsumoto - Matz started in 1993, open-sourced v0.95 in 1995 (no.5 in "Top paying technologies" in 2022) Current version: 3.4
  4. Syntax: First Impressions no semicolons at the end of lines!

    "Hello, #{name}!" "Hello, \(name)!" print("Hello") print("Hello") The same syntax, but not the same result: print in Ruby does not append new line
  5. Variables declaration and type inference Naming conventions in Swift: camelCase

    for variables and functions, PascalCase for types: classes, structs, enums, protocols, etc. Naming conventions in Ruby: snake_case for variables and functions, PascalCase for classes and modules
  6. Methods, Blocks & Lambdas vs. Functions & Closures Explicit type

    signatures for parameters and return values.
  7. Summary • Type safety in Swift: assigned value must match

    the variable’s type, while Ruby variables do not have a type, only values have a type* • Variables declaration: let (immutable) vs. var (mutable) • Optionals for nil safety • Classes (reference type) vs. Structs (value types) • Protocols (conformance) & Extensions (adding behavior) _____________________________________________________ * from the book: "Master Hotwire" by Radan Skorić
  8. Summary: What You Might Miss from Ruby • Dynamic metaprogramming:

    Swift has limited runtime dynamism by design. • Swit extensions are more constrained than Ruby's monkey-patching. • Duck typing: Explicit protocols are the Swift way. • nil's flexibility: Swift's safety comes with more boilerplate for nil handling.