Swift (programski jezik)

S Vikipedije, slobodne enciklopedije
Svift
Originalni nazivSwift
Izgovara seSvift
Modelimperativni, objektno-orijentisani, funkcionalni
Pojavio se2014
Autor(i)Kris Latner i Epl
Dizajner(i)Epl
UticajiObjective-C, Rust, Haskell, Ruby, Python, C#, CLU, D[1][2]
Operativni sistemiiOS, OS X, watchOS, tvOS, Linuks
LicencaApači 2.0 (verzija Svifta 2.2 i novija)
Veb-sajtdeveloper.apple.com/swift

Svift (engl. Swift) je programski jezik opšte namene. Podržava imperativni, objektno-orijentisani i funkcionalni način programiranja. Stvoren od strane preduzeća Epl da bi zamenio Objective-C pri programiranju iOS i OS X programa.[3] Napravljen je upotrebom LLVM programskog prevodioca koji je dostupan u Xcode 6 beta.

Uputstvo na 500 strana, The Swift Programming Language, predstavljeno je na WWDC-u i dostupno na iBooks Store besplatno.[4]

Zvanična aplikacija WWDC je 2. juna 2014. postala prva javno dostupna aplikacija napisana u Sviftu.

Primeri koda[uredi | uredi izvor]

// Коментар у једном реду

/* Коментар у свифту,
али у више редова */

var implicitInteger = 70
var implicitDouble = 70.0
var explicitDouble: Double = 70
let numberOfApples = 3
let numberOfOranges = 5
let appleSummary = "I have \(numberOfApples) apples."
let fruitSummary = "I have \(numberOfApples + numberOfOranges) pieces of fruit."
println("Hello, world")

let people = ["Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25]
for (name, age) in people {
    println("\(name) is \(age) years old.")
}
"This is a string literal in Swift"

// константа
let const = "This is a string literal in Swift"

// променљива
var str = "This is a string literal in Swift"

// штампање променљиве
print(str)
func sayHello(personName: String) -> String {
    let greeting = "Hello, " + personName + "!"
    return greeting
}

print(sayHello("Jane"))
// исписује "Hello, Jane!"

Reference[uredi | uredi izvor]

  1. ^ „Building assert() in Swift, Part 2: __FILE__ and __LINE__ - Swift Blog -”. Apple Developer. Pristupljeno 26. 09. 2014. „Swift borrows a clever feature from the D language: these identifiers expand to the location of the caller when evaluated in a default argument list. 
  2. ^ Lattner, Chris (3. 06. 2014). „Chris Lattner's Homepage”. Chris Lattner. Pristupljeno 3. 6. 2014. „I started work on the Swift Programming Language in July of 2010. I implemented much of the basic language structure, with only a few people knowing of its existence. A few other (amazing) people started contributing in earnest late in 2011, and it became a major focus for the Apple Developer Tools group in July 2013 [...] drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list. 
  3. ^ „Apple announces Swift, a new programming language for iOS”. 
  4. ^ The Swift Programming Language.

Spoljašnje veze[uredi | uredi izvor]