• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

swift.org - About Swift 官网关于notes

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
About Swift

swift.org-about-swift

About Swift

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

The goal of the Swift project is to create the best available language for uses ranging from systems programming, to mobile and desktop apps, scaling up to cloud services.(目标领域:系统,移动,桌面,云平台) Most importantly, Swift is designed to make writing and maintaining correct programs easier for the developer. To achieve this goal, we believe that the most obvious way to write Swift code must also be:

Safe安全. The most obvious way to write code should also behave in a safe manner. Undefined behavior is the enemy of safety, and developer mistakes should be caught before software is in production. Opting for safety sometimes means Swift will feel strict, but we believe that clarity saves time in the long run.(前期严格长远看来是有好处的.)

Fast快速. Swift is intended as a replacement for C-based languages (C, C++, and Objective-C). (swift设计出来就是为了替代C,C++,OC)As such, Swift must be comparable to those languages in performance for most tasks. Performance must also be predictable and consistent(性能邀求:可预测,一致性), not just fast in short bursts that require clean-up later. There are lots of languages with novel features — being fast is rare.

Expressive(富于表达). Swift benefits from decades of advancement in computer science to offer syntax that is a joy to use, with modern features developers expect. But Swift is never done. We will monitor language advancements and embrace what works, continually evolving to make Swift even better.

Tools are a critical part of the Swift ecosystem. (对于Swift生态系统,工具也是很重要的一个部分)We strive to integrate well within a developer’s toolset, to build quickly, to present excellent diagnostics, and to enable interactive development experiences. Tools can make programming so much more powerful, like Swift-based playgrounds do in Xcode, or a web-based REPL can when working with Linux server-side code.

Features

Swift includes features that make code easier to read and write, while giving the developer the control needed in a true systems programming language. Swift supports inferred types to make code cleaner and less prone to mistakes,(类型推断) and modules eliminate headers(取消头文件) and provide namespaces(命名空间). Memory is managed automatically(自动内存管理), and you don’t even need to type semi-colons(不需要分号). Swift also borrows from other languages, for instance named parameters (命名参数)brought forward from Objective-C are expressed in a clean syntax that makes APIs in Swift easy to read and maintain.

The features of Swift are designed to work together to create a language that is powerful, yet fun to use. Some additional features of Swift include:

  • Closures unified with function pointers闭包
  • Tuples and multiple return values元组,多个返回值
  • Generics 泛型
  • Fast and concise iteration over a range or collection集合快速遍历
  • Structs that support methods, extensions, and protocols 支持方法,扩展,协议的结构体
  • Functional programming patterns, e.g., map and filter函数式编程map和filter
  • Powerful error handling built-in内置错误处理
  • Advanced control flow with do, guard, defer, and repeat keywords高级流程控制do,guard,defer,repeat

Safety

Swift was designed from the outset to be safer than C-based languages, and eliminates entire classes of unsafe code. Variables are always initialized before use(变量必须在使用前初始化), arrays and integers are checked for overflow, and memory is managed automatically(自动内存管理). Syntax is tuned to make it easy to define your intent — for example, simple three-character keywords define a variable (var) or constant (let) (语法关键字更好使,var变量,let常量).

Another safety feature is that by default Swift objects can never be nil,(默认对象不能为nil) and trying to make or use a nil object will results in a compile-time error. (创建和使用一个nil对象会导致编译时错误.)This makes writing code much cleaner and safer, and prevents a common cause of runtime crashes. However, there are cases where nil is appropriate, and for these situations Swift has an innovative feature known as optionals(可选). An optional may contain nil, but Swift syntax forces you to safely deal with it using ? to indicate to the compiler you understand the behavior and will handle it safely.

Swift.org and Open Source

On December 3, 2015, the Swift language(编译器), supporting libraries(核心库), debugger(调试器), and package manager(包管理器) were published under the Apache 2.0 license with a Runtime Library Exception, and Swift.org was created to host the project. The source code is hosted on GitHub where it is easy for anyone to get the code, build it themselves, and even create pull requests to contribute code back to the project. Everyone is welcome, even just to file a bug report. There are excellent Getting Started guides available here on the site as well.

The project is governed by a core team of engineers that drive the strategic direction by working with the community, and a collection of code owners responsible for the day-to-day project management. Technical leaders come from the community of contributors and anyone can earn the right to lead an area of Swift. The Community Guidelines includes detailed information on how the Swift community is managed.

Projects

The Swift language is managed as a collection of projects, each with its own repositories. The current list of projects includes:

  • The Swift compiler command line tool 编译器
  • The standard library bundled as part of the language标准库
  • Core libraries that provide higher-level functionality核心库
  • The LLDB debugger which includes the Swift REPL 调试器
  • The Swift package manager for distributing and building Swift source code包管理器

Platform Support 支持的平台

One of the most exciting aspects of developing Swift in the open is knowing that it is now free to be ported across a wide range of platforms, devices, and use cases.

Our goal is to provide source compatibility for Swift across all platforms, even though the actual implementation mechanisms may differ from one platform to the next. The primary example is that the Apple platforms include the Objective-C runtime, which is required to access Apple platform frameworks such as UIKit and AppKit. On other platforms, such as Linux, no Objective-C runtime is present, because it isn’t necessary.

The Swift core libraries project project aims to extend the cross-platform capabilities of Swift by providing portable implementations of fundamental Apple frameworks (such as Foundation) without dependencies on the Objective-C runtime.(核心库不需要OC依赖) Although the core libraries are in an early stage of development, they will eventually provide improved source compatibility for Swift code across all platforms.

Apple Platforms

Open-source Swift can be used on the Mac to target all of the Apple platforms: iOS, OS X, watchOS, and tvOS. Moreover, binary builds of open-source Swift integrate with the Xcode developer tools, including complete support for the Xcode build system, code completion in the editor, and integrated debugging, allowing anyone to experiment with the latest Swift developments in a familiar Cocoa and Cocoa Touch development environment.

Linux

Open-source Swift can be used on Linux to build Swift libraries and applications. The open-source binary builds provide the Swift compiler and standard library, Swift REPL and debugger (LLDB), and the core libraries, so one can to jump right in to Swift development.

New Platforms

We can’t wait to see the new places we can bring Swift—together. We truly believe that this language that we love can make software safer, faster, and easier to maintain. We’d love your help to bring Swift to even more computing platforms.

undefined

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Swift代码着色测试发布时间:2022-07-13
下一篇:
Swift编码总结10 - 玉思盈蝶发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap