Swift is open source, what are the benefits?

Swift is open source, what are the benefits?

Swift is open source, great news that makes you cry!

Swift's official website is https://swift.org
Swift is available on GitHub at https://github.com/apple/swift

This morning, Mr. J asked me, what are the benefits of Swift being open source?
I would like to answer him from the following aspects:

1. Learning Swift is more convenient and simpler

When learning Swift, if you encounter problems or have some ideas, you can open the source code of Swift for reference. I believe you will gain a lot.

For example, let’s take a look at the definition and implementation of the Bool type in Swift. Is it helpful for you to customize a type?

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

2. Swift will become more complete

Less than a day after Swift was open sourced, the Swift project received 13,087 stars and 1,351 forks on GitHub. And it is still growing rapidly...

This shows that many developers are very interested in and enthusiastic about the Swift language, and developers around the world will contribute their code and strength to Swift. Please see the following picture for yourself:

Swift data on GitHub.png

3. Swift is more powerful and has a wider range of applications

Currently, Swift supports not only iOS, OS X, watchOS, and tvOS, but also Linux platforms.

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.

Apple supports everyone to port Swift to other platforms. In the future, there will definitely be capable developers who will use Swift on other new platforms.

My level is limited, I just express my superficial views. If you have different ideas, please comment below to discuss, thank you!

<<:  Weekly crooked review: The haze has cleared up, embrace PHP 7.0 like Apple open source

>>:  A brief discussion on open source from the perspective of Swift programming language

Recommend

During product iteration, how to use data to drive user growth?

In product iteration aimed at user growth , "...

It's here again! Why are there so many supermoons? What are the highlights?

The biggest supermoon of the year is here! Is the...

Why doesn't anyone like your ad?

I have been thinking about a question recently. I...

Q&A on the unfair terms of telecommunications services!

[[129390]] I read an article today. Liu Min, depu...

Is the wind on the Qinghai-Tibet Plateau really “weak and powerless”?

Qinghai-Tibet Plateau It is one of the three majo...

What are the dangers of ethylene glycol explosion?

Recently, everyone must have seen the news of a f...

The undercurrent of climate change is hidden in this wave of atmosphere

Wei Ke We live at the bottom of the Earth's a...

Mail Master Pro is coming to iOS for free this week

Starting this week, Mail Master Pro will be avail...

What pots and containers can be used to bake delicious sweet potatoes?

Imagine that when we get off work and walk out of...

How can corporate network promotion acquire customers through Baidu Tieba?

Different online promotion methods generally have...

How to wake up a sleeping user

User wake-up In the field of mobile Internet , CA...

21 ways to help you acquire effective users at low cost!

From the perspective of product operation , how t...