Swift

Apple Swift logoQ: What is Swift?

A: Swift is Apple’s new programming language for (iOS)iPhone and iPad apps and (OS X) Mac. It works side-by-side with Objective C but it is a new language in its own right.

Q: Was there a need for a new language?

A: C has been around for about 40 or more years and of course things develop very fast in the world of technology. There’s an opportunity now to develop a new language and I believe that Apple have done this with Swift. It’s very versatile, it does a lot more things than you can do with other languages and it’s a joy to work with.

Q: Is Swift better than what came before?

A: I believe I have just answered that question.

Q: What did you think when you heard there was going to be a new programming language?

A: At first I was a bit concerned, because I didn’t know how it might turn out – but now having worked with it I think it’s really good. Easy to work with, very versatile and I think it’s going to be something that a lot of people will take up in the industry.

Q: How long have you worked with it?

A: I’ve worked with it now for a few weeks. In that time I’ve almost mastered it. I’ve developed a complete project with it, so clearly it’s an easy language for someone who has a grounding in Objective C to move to.

Q: What are the things you like best so far?

A: I like the way that classes, enumerations and structs are all very similar, but have their own distinctive traits. For example, a class is the only one that you can subclass and it can have methods and properties. A struct can also have methods and properties.

It’s inherently designed to be safe. Variables are always initialized before use, arrays and integers are checked for overflow, and memory is managed automatically.

Also, it’s fast to compile. It uses the high-performance LLVM compiler.

Q: What is a struct?

A: A struct, much like a class, is a general-purpose, flexible construct that becomes the building block of your program’s code. You define properties and methods to add functionality to your classes and structures by using exactly the same syntax as for constants, variables, and functions.

Q: What is the Interactive Playground?

A: The Interactive Playground is a convenient way to test your code without actually running it in an app. It’s a feature of X Code – it’s like a text screen into which you enter code, and as you enter it you get an immediate result. For example if you say let x = 1+2 then you’ll get an answer of 3 straight away – without having to run the app.

Q: Does Swift allow you to do more interesting and exciting things?

A: Yes, definitely. I think the possibilities are endless with Swift. From what I know of it already it’s very exciting – hard to explain in a few words exactly what it can do but maybe I can expand on that later.

Q: Is the support documentation up to date?

A: I believe so.

Q: Can anybody learn Swift?

A: If you have a solid grounding in Objective C it’s going to be easier than if you’re coming to it from scratch. What I will say is that it’s a worthwhile investment of your time. Swift is not just a flash in the pan. In my opinion it’s a genuine improvement on what came before and opens up a lot of opportunities for developers.