JS to Swift
For my thesis project at Hack Reactor my group elected to build a native iPhone app using Swift. I was excited to learn Swift because I felt that learning another language and developing for a different platform would be a great way to become a better software engineer. I believe that it has and here’s why:
Thinking about the solution to a problem in language agnostic terms is valuable. Control flow and logic statements are fairly consistent across languages. Learning a new language has strengthened my basic understanding of algorithm design.
When Swift was announced last July there was a lot of excitement over the simplicity and accessibility of this new language. People felt that the learning curve for Swift would be substantially less than that of Objective C. In fact, the name “Swift” probably has more to do with increasing developer productivity than any potential performance benefits(Speed tests in fact seem to show Objective C actually performs much faster than Swift). So just how easy is it to learn Swift?
Short answer: Very.
Here are some of the big gotchas that I came across while learning Swift:
Arrays need to be filled with the same type of data.
Dictionaries are not JS Objects and need to have consistent data for all keys and consistent data for all values.
In order to perform unit testing on a class in Xcode you must declare the class and certain functions as public.
Swift is great and easy to learn, but an important thing to note is that learning Swift and learning iOS development are two different things entirely. Learning iOS has been a beast. I have spent hours trying to accomplish seemingly simple tasks. Some tasks, like designing the layout and appearance of the App, took far less time in xCode than it would in HTML and CSS but other tasks, like making asynchronous calls to a server, took forever to figure out. Learning iOS has been very difficult, but learning Swift has been easy and fun.