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.
You may still be better off sticking with Win7 or Win8.1, given the wide range of ongoing Win10...
Now that we're down to the wire, many upgraders report that the installer hangs. If this happens to...
Angular 3 will have better tooling and will generate less code; Google also is promising a new major...
From data scooping to facial recognition, Amazon’s latest additions give devs new, wide-ranging powers...
Intel’s container-focused Linux distro for the cloud is packed with intriguing features. Here’s what...
In 2017, we're past the point of just dev and test and DR in the cloud. Before embarking on any new...
Data science skills will become more important for coding as software is 'trained' via AI