Swiftly Swift

Apple releases swift, levels playing field for developers where there is no advantage to any one, everyone starts at the same time. Now that is good, but it has also brought it's own share of issues. This article shall look at the issues that surround this new Gold Rush.

The Gold Rush

Yes, the gold rush because it has become a race. Every other developer wants to have an article on teaching Swift, if not an article, they want to make a video. Those that are not writing articles or making videos or writing a book or an eBook are creating websites that are collecting links to all of these resources. It is beyond me as the only reason I foresee would be self promotion or hits and thereby advertising money.

What's So wrong

The one thing that is wrong with all of this is the artificial race it has created. The result of which is that the videos and articles are mostly rehashes of the material supplied by Apple, from the WWDC videos or the iBooks. The quality of which are not something to even talk about. Where Apple provides High Resolution videos of it's WWDC sessions, the ones found on YouTube are poor quality ones, sufficient only for the audio. If you are a developer you would have access to these videos anyways. Plus the websites that are creating links to these content are thereby creating a poor repository or have no real access to the content that matters.

Content That matters?

While everyone is trying to understand what is swift all about, looking for articles or what not, the best source for all explanation is Apple itself. The two iBooks and the WWDC videos are just amazing, these should help one to catch up to speed on the 2 years of development. I know that Swift has been 4 years in development, but what I mean when I say 2 years is that you would be up to speed with the basics. Then you can embark onto the intermediate and advanced use of Swift.

Advanced Use??

Let's see Swift for what it is. It is a new language, leaving out all the buzz words of type safe, etc, etc it means in real simple terms that it is a language that has been created to do the following
1. Replace Objective-C
2. Lower the entry barrier for new developers
3. Simplify the API and code (scripting languages are more English like than code like)
4. Eliminate (or rather reduce) run time errors by checking for the issues pre-compile

With these things in mind, they have achieved a milestone in this journey, not really reached the destination. So understanding the syntax of a scripting language is one part and a very small one for that matter. To give an example, everyone studies the Alphabets in school (even if it is in your own mother tongue or English) that just helps one to be able to read and write. That does not make everyone a poet or a writer but provides the ability to be able to read and comprehend that text. Similarly, these introductory videos are more like "In english we have 5 Vowels, they are A, E, I, O and U. However Y is an additional one that sits as both a vowel and a consonant hence a semivowel." Ok, we learned about vowels, now are we going to strike it rich? Hey let's add some consonants to the vowels and make a W-O-R-D.

The point of this still remains that though swift is a language that looks easy and feels like an easy take on development, it is not.

Swift is NOT easy?

the bottomline in a nutshell is that it is NOT. Let's look at this in a different way to understand a bit more. Let's first start with C. What is wrong with C? Nothing. it is not different than a scripting language, take the example below

   printf("Hello World\n");

Then came C++ which was THE language, it has OOP and Inheritance (it always sounds rich) but it was not for all as it had rules. The same code would not compile as it required that all functions should have a return type. So the same code became

  int main()
   printf("Hello World\n");
   return 0;

Then came the classes from Borland and Microsoft that allowed creating GUI apps. Borland has OWL (Object Windows Library) and Microsoft has MFC (Microsoft Foundation Class) These allowed developers using their tools to build visual applications. While both were variants of the same language C++, the classes used were different, so you would either develop with MFC or with OWL, it was rare for a developer to work with both (it was possible, but would have served no purpose).

Where OWL code would look like
 class myApp:TApplication()
  //Define the class here

 myApp::myApp() : TApplication("The Application Title")
  // The constructor

 int OwlMain(int, char*[])
  myApp app
  return app.Run();

it started to get a bit more complex. It was actually quite simple but still it was a minefield as there were memory pointers and classes to deal with. Java was then created to alleviate developers from the issues of pointer management. Suddenly everyone loved Java. (Basic was similar but not a progressive update to the issues faced with C/C++ it was a parallel language that existed on 8-bit computers) The issue with Java was the classes, the sheer number of classes. If you want to write a string, you have a stringWriter class right? Not really. You have a Writer class then you have stingWriter and a charWriter, then you have a bufferedStringWriter and an unbufferedStringWriter and the complexity goes on. So it is all about knowing the classes if you want to get something done.

What about Swift?

So coming back to Swift, it is a new language from Apple that is NOT a scripting language but an alternative to compile and build executables, not a pseudo interpreted executable running in a VM, but native code. These executables would run on the Apple ecosystems, Mac OSX and iOS. Thereby to be able to develop with swift one would still have to learn the underlying layer of Cocoa and CocoaTouch. The framework is not replaced, Swift is only the language to access it. It does bring some new features that make it easier, no more allocation and deallocations (Automatic Reference Counting - ARC) no more pointers to memory hence fewer issues (hopefully).


Swift is a nice fresh outlook to develop but it is not the silver bullet that will make a developer out of a non-developer. The race with swift is not on a level playing ground as those that have worked with Cocoa and CocoaTouch have the advantage of knowing what class to use and how to get things done. Think of it as a new family that has moved into your street/building. They are new and so are you to them, however you know the street and the area or the building they do not. That is the advantage that those developing would have over the new comers.

So the point is focus on the core which is Cocoa and CocoaTouch. The videos and regurgitated tutorials are not teaching you anything. If you have written code in any language, it is only a matter of adapting to swift. If you have no idea about Cocoa or CocoaTouch, how will you even get anything done beyond playgrounds?

Would you know that you use a NSRect for Mac and a GCRect for iOS and there is NSBezierCurve and UIBezierCurve but both are not the same, and have varying capabilities and NSView and UIView have different capabilities too. Did you know that drawing with NSView the co-ordinate system starts from the bottom left as opposed to the top left and with objective-C you would use the isFlipped and that it is a function that you override not a property that you can set. Hope that you get an idea of what's involved.


Popular Posts