自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Swift開源了,有什么好處?

移動開發(fā)
學(xué)習(xí)swift的時候,遇到問題,或者有一些想法的時候,你可以打開swift的源碼參考一番,我相信會有很大的收獲。

swift開源了,喜大淚奔的好消息!

swift的官方網(wǎng)站https://swift.org
swift在github的開源地址https://github.com/apple/swift

今天早上J君問我,swift開源了有什么好處呢?
我想從以下的幾個方面來回答他:

1.學(xué)習(xí)swift更加方便和簡單了

學(xué)習(xí)swift的時候,遇到問題,或者有一些想法的時候,你可以打開swift的源碼參考一番,我相信會有很大的收獲。

舉個例子,我們來看看swift中的Bool類型的定義和實現(xiàn),是不是對你自定義一個類型的時候很有幫助呢?

  1. public struct Bool { 
  2.   internal var _value: Builtin.Int1 
  3.  
  4.   /// Default-initialize Boolean value to `false`. 
  5.   @_transparent 
  6.   public init() { 
  7.     let zero: Int8 = 0 
  8.     self._value = Builtin.trunc_Int8_Int1(zero._value) 
  9.   } 
  10.  
  11.   @_transparent 
  12.   internal init(_ v: Builtin.Int1) { self._value = v } 
  13.  
  14. extension Bool : _BuiltinBooleanLiteralConvertible, BooleanLiteralConvertible { 
  15.   @_transparent 
  16.   public init(_builtinBooleanLiteral value: Builtin.Int1) { 
  17.     self._value = value 
  18.   } 
  19.  
  20.   /// Create an instance initialized to `value`. 
  21.   @_transparent 
  22.   public init(booleanLiteral value: Bool) { 
  23.     self = value 
  24.   } 
  25.  
  26. extension Bool : BooleanType { 
  27.   @_transparent 
  28.   @warn_unused_result 
  29.   public func _getBuiltinLogicValue() -> Builtin.Int1 { 
  30.     return _value 
  31.   } 
  32.  
  33.   /// Identical to `self`. 
  34.   @_transparent public var boolValue: Bool { return self } 
  35.  
  36.   /// Construct an instance representing the same logical value as 
  37.   /// `value`. 
  38.   public init<T : BooleanType>(_ value: T) { 
  39.     self = value.boolValue 
  40.   } 
  41.  
  42. extension Bool : CustomStringConvertible { 
  43.   /// A textual representation of `self`. 
  44.   public var description: String { 
  45.     return self ? "true" : "false" 
  46.   } 
  47.  
  48. // This is a magic entrypoint known to the compiler. 
  49. @_transparent 
  50. public // COMPILER_INTRINSIC 
  51. func _getBool(v: Builtin.Int1) -> Bool { return Bool(v) } 
  52.  
  53. @_transparent 
  54. extension Bool : Equatable, Hashable { 
  55.   /// The hash value. 
  56.   /// 
  57.   /// **Axiom:** `x == y` implies `x.hashValue == y.hashValue`. 
  58.   /// 
  59.   /// - Note: the hash value is not guaranteed to be stable across 
  60.   ///   different invocations of the same program.  Do not persist the 
  61.   ///   hash value across program runs. 
  62.   public var hashValue: Int { 
  63.     return self ? 1 : 0 
  64.   } 
  65.  
  66. //===----------------------------------------------------------------------===// 
  67. // Operators 
  68. //===----------------------------------------------------------------------===// 
  69.  
  70. // Unary logical complement. 
  71. @_transparent 
  72. @warn_unused_result 
  73. public prefix func !(a: Bool) -> Bool { 
  74.   return Bool(Builtin.xor_Int1(a._value, true._value)) 
  75.  
  76. @_transparent 
  77. @warn_unused_result 
  78. public func ==(lhs: Bool, rhs: Bool) -> Bool { 
  79.   return Bool(Builtin.cmp_eq_Int1(lhs._value, rhs._value)) 

2.swift會變得更加的完善

swift開源不到一天的時間,swift項目在github收到了13087個star,1351個fork。并且還在快速增長中......

這表示了眾多開發(fā)者對swift這個語言的關(guān)注和熱情十分的高漲,并且全球的開發(fā)者都會為swift貢獻自己的代碼和力量。大家看下圖體驗一下:

swift在github上的數(shù)據(jù).png

3.swift更加強大,更加廣泛的應(yīng)用

目前swift支持的平臺,除了自家的iOS, OS X, watchOS, 和 tvOS.還支持了Linux平臺。

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.

蘋果公司是支持大家把swift移植到別的平臺去的,日后必定有有能力的開發(fā)者,在別的新的平臺上使用swift。

水平有限,只是發(fā)表一下自己淺薄看法。如果你有不同想法,歡迎在下方評論來討論,謝謝!

責(zé)任編輯:倪明 來源: 簡書
相關(guān)推薦

2013-03-19 09:40:44

CookiesCookies跟蹤個人隱私

2013-09-23 14:54:54

編程語言開發(fā)

2020-09-11 09:42:28

云安全云計算

2020-04-21 22:25:43

智能垃圾物聯(lián)網(wǎng)IOT

2021-11-10 23:31:21

混合云云計算數(shù)據(jù)

2021-03-04 11:01:43

服務(wù)器虛擬化IT

2022-08-08 14:18:34

物聯(lián)網(wǎng)鋁行業(yè)工業(yè) 4.0

2021-08-26 16:06:35

物聯(lián)網(wǎng)網(wǎng)關(guān)路由器物聯(lián)網(wǎng)

2022-07-27 11:21:27

服務(wù)器IT 基礎(chǔ)架構(gòu)

2013-07-24 09:36:03

產(chǎn)品上線產(chǎn)品著陸頁

2010-11-23 09:29:49

Lync微軟

2023-12-25 09:47:40

區(qū)塊鏈運輸業(yè)供應(yīng)鏈管理

2018-05-04 14:11:34

SwiftPython開發(fā)

2010-01-05 14:33:09

.NET Framew

2017-02-06 17:00:09

TensorFlowHadoop開源

2017-02-07 09:30:49

TensorFlowHadoop開源

2021-02-19 23:55:15

PythonPythonic數(shù)據(jù)

2015-07-01 13:50:29

Swift開源思考

2022-06-07 08:39:35

RPCHTTP

2018-08-27 06:58:06

無線路由器WiFi網(wǎng)絡(luò)
點贊
收藏

51CTO技術(shù)棧公眾號