緣起
盡管在2014年Swift就發(fā)布了,但是作為一名iOS開發(fā)者,我是最近才開始關(guān)注它的辕棚。起因也是一次偶然發(fā)現(xiàn)它居然還能寫后端奴曙,這一點深深地吸引了我别凹。加之最近這段時間有些面試公司明確要求需要有Swift開發(fā)經(jīng)驗。
初識
五年以來洽糟,Swift已經(jīng)進化到了5.0版本炉菲。儼然一副Apple親兒子的的態(tài)勢,首先我們看一下官方對Swift的描述:
Swift is a fantastic way to write software, whether it’s for phones, desktops, servers, or anything else that runs code. It’s a safe, fast, and interactive programming language that combines the best in modern language thinking with wisdom from the wider Apple engineering culture and the diverse contributions from its open-source community. The compiler is optimized for performance and the language is optimized for development, without compromising on either.
Swift是一種非常棒的軟件編寫方式坤溃,不管是應(yīng)用于手機拍霜,桌面,服務(wù)器還是其他需要代碼的地方薪介。它是一種安全沉御,快速,交互式的編程語言昭灵,它是廣泛的Apple工程文化及智慧與開源社區(qū)編程智慧的集大成者吠裆。其編譯器對性能進行了優(yōu)化,同時并沒有對其他方面產(chǎn)生影響烂完。
我去试疙,聽上去超級納愛斯啊。
Swift defines away large classes of common programming errors by adopting modern programming patterns:
- Variables are always initialized before use.
- Array indices are checked for out-of-bounds errors.
- Integers are checked for overflow.
- Optionals ensure that nil values are handled explicitly.
- Memory is managed automatically.
- Error handling allows controlled recovery from unexpected failures.
Swift通過采用現(xiàn)代編程模式來定義廣大類常見的基本編程錯誤:
- 1.變量往往會在使用前進行初始化
- 2.數(shù)組索引的越界問題將得到檢查
- 3.整數(shù)溢出會得到檢查
- 4.Optionals類型會確保nil值得到處理
- 5.自動內(nèi)存管理
- 6.錯誤處理允許從意外故障中恢復(fù)
做開發(fā)的抠蚣,我們一眼就能明白這是在干什么祝旷。正是有了這些編程模式,使得Swift相比Objective-C更加安全。
Swift combines powerful type inference and pattern matching with a modern, lightweight syntax, allowing complex ideas to be expressed in a clear and concise manner. As a result, code is not just easier to write, but easier to read and maintain as well.
Swift將強有力的類型推理和模式匹配與現(xiàn)代輕量級的語法相結(jié)合怀跛,這就允許復(fù)雜的想法能夠用清晰簡明的方式去表達距贷。因此,Swift的代碼不僅容易編寫吻谋,更加容易閱讀和維護忠蝗。
深入
easier to write?easier to read 漓拾?easier to maintain?
這簡直是一個十分誘人的理由阁最,怪不得Apple要當親兒子養(yǎng)呢。那么骇两,作為一名iOS開發(fā)者還有什么理由不擁抱它呢速种?盡管項目可能用不到,研究一下也是大有裨益低千!
所以配阵,超哥準備從此結(jié)合官檔和代碼系統(tǒng)性學(xué)習(xí)下Swift。也歡迎感興趣的猿友們一起探討示血!
我的打算的學(xué)習(xí)方式就是看官檔《THE SWIFT PROGRAMMING LANGUAGE》,原因有三:
1.官檔是學(xué)習(xí)Swift最直接最權(quán)威的渠道
2.閱讀英文原版順便可以提升一下英文水平
3.我會將原文做部分翻譯作為自己的學(xué)習(xí)筆記
這里提到的學(xué)習(xí)筆記闸餐,就是這個系列了。我不會一味翻譯原文矾芙,我會根據(jù)自己的閱讀著重記錄Swift與OC相比新增的特性或者不同的語法表達舍沙,其他的會一筆帶過。當然剔宪,其中也難免夾雜一一些個人學(xué)習(xí)過程中的思考和想法拂铡。同時,也會附上細化到每個知識點相關(guān)的官檔鏈接供自己回顧復(fù)習(xí)時便于和官檔對照葱绒。
--------------------------------------------------------------20190516.21.40夜
熬夜
不是出于苦工
而是為了自由的滋味
以及對知識的深切渴望
-----------------------------非著名八線互聯(lián)網(wǎng)九流程序猿 chaors