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

11 ways to increase product conversion rate!

Improving conversion rate is one of the core task...

If "Children" is written on food packaging, does it mean it is safe and healthy?

On April 16, taking advantage of the weekend, Wen...

I'm so angry! Where did it come from?

Almost all of us have experienced "belly blo...

How to obtain seed users during the cold start period?

For Internet products, if there are no users, no ...

China's most high-tech luxury car Aion LX is on sale, starting at RMB 249,600

On October 17, GAC New Energy held an in-depth in...