Swift入坑0x00序章

作者: WallisW | 来源:发表于2019-05-16 21:40 被阅读7次

    缘起

    尽管在2014年Swift就发布了,但是作为一名iOS开发者,我是最近才开始关注它的。起因也是一次偶然发现它居然还能写后端,这一点深深地吸引了我。加之最近这段时间有些面试公司明确要求需要有Swift开发经验。

    初识

    五年以来,Swift已经进化到了5.0版本。俨然一副Apple亲儿子的的态势,首先我们看一下官方对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是一种非常棒的软件编写方式,不管是应用于手机,桌面,服务器还是其他需要代码的地方。它是一种安全,快速,交互式的编程语言,它是广泛的Apple工程文化及智慧与开源社区编程智慧的集大成者。其编译器对性能进行了优化,同时并没有对其他方面产生影响。

    我去,听上去超级纳爱斯啊。

    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通过采用现代编程模式来定义广大类常见的基本编程错误:

    • 1.变量往往会在使用前进行初始化
    • 2.数组索引的越界问题将得到检查
    • 3.整数溢出会得到检查
    • 4.Optionals类型会确保nil值得到处理
    • 5.自动内存管理
    • 6.错误处理允许从意外故障中恢复

    做开发的,我们一眼就能明白这是在干什么。正是有了这些编程模式,使得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将强有力的类型推理和模式匹配与现代轻量级的语法相结合,这就允许复杂的想法能够用清晰简明的方式去表达。因此,Swift的代码不仅容易编写,更加容易阅读和维护。

    深入

    easier to write?easier to read ?easier to maintain?

    这简直是一个十分诱人的理由,怪不得Apple要当亲儿子养呢。那么,作为一名iOS开发者还有什么理由不拥抱它呢?尽管项目可能用不到,研究一下也是大有裨益!

    所以,超哥准备从此结合官档和代码系统性学习下Swift。也欢迎感兴趣的猿友们一起探讨!

    我的学习实录就是看官档《THE SWIFT PROGRAMMING LANGUAGE》,原因有三:

    • 1.官档是学习Swift最直接最权威的渠道

    • 2.阅读英文原版顺便可以提升一下英文水平

    • 3.我会将原文做部分翻译作为自己的学习笔记

    这里提到的学习笔记,就是这个系列了。我不会一味翻译原文,我会根据自己的阅读着重记录Swift与OC相比新增的特性或者不同的语法表达,其他的会一笔带过。当然,其中也难免夹杂一一些个人学习过程中的思考和想法。同时,也会附上细化到每个知识点相关的官档链接供自己回顾复习时便于和官档对照。

    --------------------------------------------------------------20190516.21.40夜

    0512.jpg

    熬夜
    不是出于苦工
    而是为了自由的滋味
    以及对知识的深切渴望
    -----------------------------非著名八线互联网九流程序猿 chaors

    相关文章

      网友评论

        本文标题:Swift入坑0x00序章

        本文链接:https://www.haomeiwen.com/subject/ubnqaqtx.html