Swift Excitement

Of all of the many announcements from Apple’s WWDC yesterday, the one that seemed to pique the interest of the largest number of people in attendance, online, and in my living room, was the premiere of Swift. Apple has been the subject of some ridicule for their Objective-C language for many years. A lot of blog-ink has been spilled, and a lot of audio has been recorded, with people arguing for and against adopting a new programming language. I happened to be in the camp that thought they needed develop one, but that was purely for selfish reasons. I’ve wanted to make applications — nothing profitable, marketable, or really all that interesting. Just to put together a little something-something for myself to make task X, or Y easier. One might say, “to scratch an itch.”

Objective-C melts my brain. It is a hideous monstrosity of a language, covered in warts. I know why it is that way. Many consider that a feature, and a testament to the original design. As someone that didn’t grow up using C-based languages, those reasons mean very little to me. I have none of that development baggage. All I want to do is get in, and get out. Have my tactical strike run of a few lines of something I can read, and be done with it. This isn’t just a barrier to adoption for me, but for many. The reason to learn Objective-C is to do something with Apple’s platforms that require it.

As I’ve said before, my ability to do anything at all stems from using graphics software that uses embedded Python interpreters to provide scripting, or expression, functionality. That’s why I know enough Python 2.7 to configure a Twisted settings.py file for multiple, virtual hosts, and to write a stupid static blog engine, and other proprietary pipeline scripts. I don’t know enough to do anything super-important, because what I consider to be super-important is programming a GUI, not CLI stuff. Tons more people know JavaScript because they’ve had to tinker with it for the web. These things are not completely dissimilar to one another.

That’s what’s so valuable about Swift. It integrates all the things I want to make with a language I can read and understand. I don’t have an iOS, or Mac Apple Developer account yet, but I probably will. It is too enticing to think about writing little pet apps for myself.

Just how easy is it to understand it given my limited background? Well if you understand:

print('Hello World')

Then you’ll understand:

println('Hello World')

Blocks aren’t exactly the way I’d like them ({} cruft), but they’re easy to interpolate between the two in your head:

mydict = {'apple':0, 'blackberry':0}
for key,val in mydict:
    if key == 'apple':
        val = 1


var mydict = ["apple":0, "blackberry":0]
for (key,val) in mydict {
    if key == "apple" {
        val = 1

If you already know one of these similar languages then this is approachable as fuck. If you don’t know one, then at least it’s equally cryptic! The only part I foresee being potentially confusing for me is the difference between var and let which I’m sure I will get wrong 50% of the time.

Next Generation of Programmers

I don’t recall seeing many Apple developers maintain a personal site where they publish any information about how something internal was developed, but Chris Lattner has done just that. Excerpt from his site.

I started work on the Swift Programming Language (wikipedia) in July of 2010. I implemented much of the basic language structure, with only a few people knowing of its existence. A few other (amazing) people started contributing in earnest late in 2011, and it became a major focus for the Apple Developer Tools group in July 2013.

The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.

The Xcode Playgrounds feature and REPL were a personal passion of mine, to make programming more interactive and approachable. The Xcode and LLDB teams have done a phenomenal job turning crazy ideas into something truly great. Playgrounds were heavily influenced by Bret Victor's ideas, by Light Table and by many other interactive systems. I hope that by making programming more approachable and fun, we'll appeal to the next generation of programmers and to help redefine how Computer Science is taught.

A beautiful sentiment. It made me feel bad for laughing when I read this.


There are some not-great things about Swift that are immediately obvious right out of the gate.

  1. It was not, and will not be, developed in the open so that people will have advanced knowledge of new features in the language, or be able to propose, or respond to, features in the language.
  2. It can’t be run on any other operating system. (You could write a web service in Swift, but it would need to run on Apple hardware.)
  3. The development IDE, Playground, looks great, but that will be the IDE.
  4. Security. Apple is the only one that will really be able to do anything with the guts of the language, and the compiler. Not that anything would happen.
  5. It is not one of many, similar, existing languages.

Those are ALL the things I expect of any Apple language. I don’t expect them to start a standards body where people can weigh in on this stuff. Pfft. What possible incentive is there for them to do that when the goal is not to increase adoption of the language on competing platforms, but to increase adoption of their platforms.

A few, long-time Objective-C developers seem to be averse to Swift. Todd Ditchendorf, former Apple developer, and developer of commercial software, like Fluid, was beside himself on Twitter yesterday. Todd loves Objective-C, and he sees Swift as inferior. I mentioned to him that I was excited about it, because it would help get more people to write software for Apple’s platform, to which he replied:

@joesteel I’m sorry, you must be looking for rational @iTod. You’re currently speaking with emotionally violated @iTod.

Todd’s been linking to complaints against Swift, so anyone interested in seeing this from another angle should definitely be following him. He linked to this piece by David Flanagan, a Mozilla programmer.

The fact that Apple treats a new programming language as a WWDC surprise, says a lot about Apple’s culture, I guess. If I wrote software targeting Apple hardware (or managed people who did) I don’t think I’d be happy at all about having a new language dropped on me from the blue—here’s the new language you’ll be using from now on… go learn it right away!

Naturally, I think David is overstating the urgency to adopt Swift swiftly. Its very design allows it to run alongside Objective-C code — of course it would. It is in Apple’s own interest not to invalidate the a language that is used for everything in both of their operating systems. The reason it was unveiled was to increase excitement about future development. To give guidance that there is a direction things will go eventually. Apple famously had Carbon and Cocoa frameworks for doing things in OS X for a really long time before they deprecated Carbon. There’s no way they expect an overnight switch, as David argues.

Back to the security concern: Unicode. There is a delightful part of Apple’s Swift book that shows unicode characters, and emoji, being used in variable assignment. This is neat, and great for developers of other languages. Python 3 also lets people do this and Armin Ronacher, a prominent developer, has pointed out that it is very possible to include backdoors in code if you substitute certain, lookalike unicode characters. I have not been able to test a similar situation under Swift, but I’d be curious to see how they avoid the same pitfall.

Who Else is Pumped?!

I am! Are you?

2014-06-03 14:50:00

Category: text