Ignores commenting on another static vs. dynamic dispatch article because people won’t accept Swift is a hybrid not plain static.— Joe Fabisevich 🐶🐳™ (@mergesort) May 24, 2016
Guess that didn’t last long.
There’s a conversation happening in the iOS community at the moment, static vs. dynamic programming. On one side we have many people who have been writing Objective-C for over 20 years (wow!) saying that the dynamism of Objective-C is the reason why it is an amazing language, and has succeeded. The argument is predicated on the fact that those nay-saying it don’t understand the power of dynamism, and how it’s empowered programmers. On the other end you have many people saying that static languages are the way forward, and that a whole class of errors is avoided, and that we should look at all the bugs prevented by having a good type system!
This back and forth ignores that Chris Lattner, the creator of Swift, has himself stated that Swift is a hybrid, not explicitly static or dynamic. His explanation is very interesting, because it takes the argument from being black vs. white and turns it into many gray shades. Other languages have explored these concepts before, with ideas like gradual typing, which was born out of the idea of grafting a type system onto dynamic languages, not making static languages more expressive.
But what exactly is expressiveness? As this StackOverflow post explains (always cite your StackOverflow posts kids):
‘Expressive’ means that it’s easy to write code that’s easy to understand, both for the compiler and for a human reader.
Two factors that make for expressiveness:
• Intuitively readable constructs
• Lack of boilerplate code
Peter Norvig has a great talk on design patterns in programming languages. One slide stuck out to me as I was reading it recently.
Let’s break that down:
There are fewer design patterns in expressive languages, because the type system does not prevent programmers from trying to express a concept.
Dynamic languages by their very nature of a weak type system have less issue being expressive.
This does not rule out static languages from being expressive!
The lack of expressiveness of static languages is dogma attached from other static languages that have existed before. I’d argue that Go is as expressive as Python, and Swift, even in its incomplete state, is nearly as expressive as many dynamic languages. You can recreate the advantages Objective-C offers through its dynamic nature by using different expressive techniques, like protocols and generics, in a statically typed language.
One more thing: Many arguments imply that Apple hasn’t thought about writing apps, that they built a static language, and forgot to take into account. Care to tell me which company writes apps on the most iPhones in the world? That’s right, Apple. I don’t think they’re stupid enough to create a language which they believe is objectively worse for writing apps.
Regardless of how this whole static vs. dynamic “conversation” turns out, one thing’s for certain, I’m #TeamSwift.
Joe Fabisevich is an indie developer creating software at Red Panda Club Inc. while writing about design, development, and building a company. Formerly an iOS developer working on societal issues @Twitter.
Like my writing? You can keep up with it in your favorite RSS reader, or get posts emailed in newsletter form. I promise to never spam you or send you anything other than my posts, it's just a way for you to read my writing wherever's most comfortable for you.
If you'd like to know more, wanna talk, or need some advice, feel free to sign up for office hours, I'm very friendly. 🙂