Tuesday, June 3, 2014

Swift Links [feedly]



----
Swift Links
// MacStories

The third big announcement that followed OS X Yosemite and iOS 8 yesterday was Swift, Apple's new programming language meant to replace Objective-C.

From Apple's website:

Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C.

Swift has been in the works since 2010, as confirmed by Chris Lattner, Director of the Developer Tools (via John Siracusa):

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.

One of the key features of Swift is interactive Playgrounds, which will allow you to type code and see the results appear immediately:

Playgrounds make writing Swift code incredibly simple and fun. Type a line of code and the result appears immediately. If your code runs over time, for instance through a loop, you can watch its progress in the timeline assistant. The timeline displays variables in a graph, draws each step when composing a view, and can play an animated SpriteKit scene. When you've perfected your code in the playground, simply move that code into your project.

As an introduction to Swift, Apple has created the Swift Programming Language guide, available as a free eBook on iTunes and on the web:

Swift is friendly to new programmers. It is the first industrial-quality systems programming language that is as expressive and enjoyable as a scripting language. It supports playgrounds, an innovative feature that allows programmers to experiment with Swift code and see the results immediately, without the overhead of building and running an app.

Over at The Verge, Ben Popper talked to iOS and OS X developers and collected their reactions to Swift:

The other big idea behind Swift is that programmers can write their code and see the results in real time. In the old paradigm, developers write line after line of code in a text box, then compile those results — sometimes a lengthy, painful, productivity-denting task — and wait to see the end result. The product and the process were distinct from one another. With Swift, they can tweak a parameter or algorithm and watch the changes happen right away in the same coding environment. Theoretically, this means developers can toy with concepts faster and make what they're trying to make in less time.

Last, Tim Stevens has a good general overview at CNET, explaining the differences between various programming and scripting languages and Apple's approach with Swift:

Scripting languages, like Python, tend to be easy to write and easy to test, but they aren't particularly powerful and generally don't perform well. Not ideal when you're writing, say, a game that needs access to the full power of your device. Traditional programming languages, like Objective-C, give better access to the power of the device and enable the creation of more comprehensive apps, but are difficult to learn and tedious to compile and test.

Swift promises to have all the good with none of the bad. Apple promises that, at least in a few key benchmarks, it is considerably faster to execute than Python and faster even than Objective-C. But, despite that, the language supports what's called "playgrounds" within the Xcode developer environment, visualizing Swift code in real-time, like a scripting language.

∞ Read this on MacStories


----

Shared via my feedly reader


Sent from my iPhone

No comments:

Post a Comment