Swift ka Introduction
Swift ek compiled, statically typed language hai jise Apple ne banaya hai, jo iOS aur macOS development ke liye use hoti hai aur Linux par general-purpose programming ke liye bhi. Is site ke Java, Kotlin, C#, ya JavaScript ke unlike, Swift garbage collector use nahi karta — ye ARC (Automatic Reference Counting) use karta hai, jo track karta hai ki kitne references ek object ko point kar rahe hain aur jaise hi wo count zero hota hai, object ko deallocate kar deta hai — C ya C++ ki manual memory management ke bina deterministic cleanup milta hai.
Swift ki dusri signature feature hai optionals: String jaisa type kabhi 'no value' hold nahi kar sakta — sirf String? kar sakta hai, aur compiler aapko force karta hai ki andar ki value use karne se pehle us possibility ko handle karein. Ye course wo cover karta hai, saath hi structs (Swift ka default, idiomatic tareeka data model karne ka), protocols, associated values wale enums, aur closures.
Ek chhoti preview
Yahan ek real Swift program hai, is page ke apne compiler par actually execute kiya gaya — mockup nahi:
print("Swift: compiled, statically typed, and uses ARC instead of garbage collection.")Swift: compiled, statically typed, and uses ARC instead of garbage collection.
Koi class nahi, koi main function nahi — sirf ek single top-level statement. Next lesson aapka pehla full program run karta hai aur exactly explain karta hai ki kya ho raha hai.
Practice exercise
Ek constant version naam ka banao jiski Int value 14 ho, phir string interpolation use karke "Swift version: " ke baad uski value print karo.