# Random thoughts on Swift

·  by Alex Polozov  ·  Read in about 2 min  ·  321 Words

Based on my quick skimming session through the language guide.

Kind of expected from a modern language, would be surprised if it wasn’t included:

• Closures
• Type inference
• First-class collections and tuples
• Generics with all kinds of boundary restrictions
• Interoperability with existing libraries (in this case with C and Obj-C).

Surprisingly included, and it’s nice:

• First-class Maybe monad
• Bret Victor-style interactive IDE (let me make a sincere bow to Apple folks at this point)
• Opt-in mutability
• Lots of small inspirations from D, C#, Scala, etc.

However…

• Reference counting instead of garbage collection. Cannot detect reference cycles, ergo manual weakref management.
• I’m not quite sure how to combine “protocols” (read: interfaces) and “extensions” (read: mixins) into full-fledged traits and typeclasses. For example, how do I define a default method implementation for an interface a protocol?

(Also, why the heck do you need so many new names for existing concepts?!)

• Optional types are not quite Maybe, you can force the “unwrapping” with a ! operator (naturally, with a possible runtime exception). I foresee every single iOS developer just blindly doing it with every external optional they get.

• Extremely closed infrastructure: iOS/MacOS only, proprietary compiler, etc. Hell, you need an iTunes account to even read language documentation.

• Absolutely no first-class concurrency treatment. Moreover, there’s even no library treatment for concurrency (even though it is not enough).

• No stream processing sugar (read: comprehensions/LINQ). Well, at least they have map and reduce in the standard library, but that’s about it.

• No private members.

Not sure how I feel about:

• No exceptions. If you gave us some other monadic alternative, I might’ve put it in the “nice” section.
• Some magic in interoperability. Apparently, they wrote “external parameters names” for many standard library functions and forgot to show them to the legacy Objective-C programmers.
• The fact that their compiler cannot resolve recursive ADT definitions, even though it supposedly should.

Interesting. Let’s see how it flies.