My Thoughts on the Swift Programming Language

At their recent conference, Apple announced a new programming language called Swift.

I got very excited – because something being kept a secret for a four years (2010-2014) must be really groundbreaking!

After scanning the docs I was sure that my initial feeling was right.

This new language will really shape the future.

Swift logo

Swift logo

A very familiar language

Xcode is Apple’s IDE (Integrated development environment), and I have it installed on my Mac.

However I’ve been using it only indirectly – when exporting from Unity for iOS platform.

To me, the syntax of Objective-C was something I’m not used to.

My programming background is really C#, Javascript and Actionscript 3 – all of which very much differ from the Objective-C syntax.

That’s why for me – looking at Objective-C was pretty much like reading Chinese. 🙂

On the other hand, Swift looks very familiar – like I’ve been using it for years.

“Apple’s C#”

Having a managed language is a giant leap for Apple.

Comparing Swift to Objective-C is much like comparing C# with C++ – a giant leap forward.

Swift developers won’t have to bother with memory issues anymore because the system will handle those for them.

However, Swift could be run parallel with Objective-C code, allowing low-level manipulations.

Plenty of features

The new language brings a plenty of features, taken from different existing languages, and adding its own.

Basically all of the things being “broken” or “non logical” in other languages Swift gets right.

One of the examples is a switch statement. A missing break statement inside of the switch was a very common source of errors. However, nobody ever thought of fixing the issue of accidental fallthroughs.

Apple fixed it by removing the break statement from the language and introducing the fallthrough statement instead.

Now all the case statements return immediately and not falling-through by default anymore.

And if the developer wants the fallthrough, he should specify it with the fallhtrough keyword (just like he previously used the break statement).

Everything done right

Much like the switch statement, everything else is done just right.

Apple “borowed” from other languages only the good (and modern) stuff.

Javascript programers will appreciate functions as first class citizens as well as closures.

“Playground”

Inspired by Bret Victor’s research of IDE user interfaces, Apple created a new IDE feature called Playground.

Playground provides an instant feedback to developers in a sense of object positioning, value scrubbing (via the slider) and curve tweaking.

Changing the code reflects in the display on the right.

This feature should definitely make a developer’s life easier.

The playground

The playground

Conclusion

Swift language is an entry point to iOS for C#, Javascript, Actionscript 3 programmers – and many more.

I believe many of devs will at least try building and publishing an iOS app.

As for myself – as soon as I get time, I’ll try to build mine.

I bet I am right

I bet I am right