Swift's clean and modern syntax makes it quick and easy to get started, but mastering this new language will take a while
That high-level road map and a few details about the syntax of declaring variables is all you need to get going. Within a few days of Apple's announcement, open source software written in Swift started appearing on GitHub. One of the most impressive, a clone of Flappy Birds by Nate Murray, required just two major Swift files and a bit of glue code. If you know your way around OS X or iOS programming, you can get moving very quickly. Murray says he spent only a day on his clone.
Swift fixes a few of the biggest complaints about Java syntax. You won't need to waste keystrokes spelling out the type of each variable; the compiler will infer it from initialization. You get all of the advantages of letting the compiler check the types without many of the keystrokes. If you want to glue together variables and strings, a simple templating hack uses a mere three keystrokes to insert a variable into a string. It's a masterstroke.
For all of the advances and improvements, I found the size of Swift to be a bit daunting. While it's easy to see how Nate Murray knocked off Flappy Birds in a day, many other details of the language can't be mastered in a few minutes. I spent some time puzzling about the difference between data that's passed around by value (
struct) and data that's passed around by pointers (
class). Juggling these differences is one of the big challenges to C programming, and it will remain an issue for Swift programmers who want to squeeze the best performance out of their code.
Optimization will probably be a real headache for some kinds of code. Strings, for instance, are always passed by value, which means Swift will be making copies of strings left and right with every function call. This may not be much of an issue for graphics-based programs like games, but programs like Web servers and content management systems are essentially concatenation machines. Anyone who starts juggling strings will need to pay attention to this when writing Swift code. They may end up wrapping the string values in classes to avoid the copying.
There are a number of other areas that I earmarked for deeper study. Downcasting, for instance, lets you shift the focus from a class to a subclass with the typecasting operator (
as). This may fail, so there's another typecasting operator with a question mark (
as?), which returns the value of
nil if the downcast doesn't succeed. There are a number of these optional features where the presence or absence of the question mark changes the behavior of keywords. Another feature, subscripts, lets you dig into a class quickly to pull out a particular value. It's neat shorthand, but it has the potential to confuse.
This weekend's Windows 10 upgrade has users angry, and it's unclear if the ploy will continue
Here’s the best of the best for Windows 10. Sometimes good things come in free packages
Speaking at the O'Reilly Fluent conference, Eich also endorsed the Service Workers mobile app...
Four, rich, pretrained machine learning APIs bring the smarts behind Google to your apps
F# 4.1 will include struct tuples, improved error messages, and backing for .Net Core
The Apache project for container orchestration aims higher than merely managing Docker or being a...
Whether their cloud is powered by Amazon, Google, Microsoft, or IBM, developers need security tools....