Swift Learning Roadmap

Swift-Learning-Roadmap
Recently one of my email subscribers wrote me this:
What I find is that I’m learning the various steps but I do not understand the “big picture”. For me, a guideline, would be helpful. I know Swift is available but I do not even know object oriented programming. I’d really like to see a “roadmap” that says: if you know or do not know this, start here and learn this, then this, etc.

He is not alone. Talking to people and reading comments online I found that many share the same feeling. There is a huge amount of information about iOS development and so many things to learn.
It is easy to get lost and not know what is important to know and what should be learned first.
I know that feeling myself. When I started adventuring into Mac OS X programming in 2005 (the iPhone did not exist yet) I found myself in the same situation. Back then, resources were scarcer than nowadays. I relied a lot on Apple’s documentation and started venturing into the world of Cocoa and Objective-C all by myself.

I soon ran into this same problem: many guides referenced concepts I had no idea about. The guides where detailed, but there was no roadmap for learning. So I went through a long process of putting information together, like a puzzle. I tried to find what the prerequisites of each guide were and I put everything into a logical order to be studied.

I came to the Apple ecosystem after studying computer science at the university, so my background helped me navigate all the information. For people that do not have any programming experience this might be even harder, often paralysing.

Many times you are learning new concepts, you have no idea why they are important or when they should be used.
Learning the programming language of the platform is your first important milestone, whether you have a programming background or not. Many tutorials dive directly into making a first app from scratch. Many of these are even supposed to be for people with no programming experience. Although it might feel productive to start making your first app straight away, clarity over fundamental concepts is lost in the huge amount of material. Yes, it might feel good to have a little app running after completing your first tutorial. The reality is, though, that you probably did not understand why things are done the way they are. This is a common complaint I read again and again. This is a comment I got on Reddit, after asking what people found challenging in learning iOS development:
It seems a common approach to teaching iOS development is to jump straight into writing code and explain the theory later. That’s fine, except I often do not fully understand the theory by the end of working through a lesson or tutorial. Instead, I know the specific way that developer/teacher implemented it. Not why or what other options are available, or how to translate that to my own projects.
There are many complex concepts involved in creating an app which you cannot understand at the beginning. When you learn a foreign language, what do you start with first? Chances are that the first thing you learn is something like “Hello, what is your name?”. You do not start reading a paragraph of literature with complex grammar, exceptions and idioms. Learning iOS development is the same: when you do not know the language, things like view controllers, design patterns, table views, auto layout etc. are all going to get in your way. In the meanwhile you miss the fundamental concepts of programming and of the language you are studying.

Should I learn Swift or Objective-C?

Since the introduction of Swift, often people wonder which language they should learn first. Questions like these are common:
Should I learn Swift now instead of Objective-C if I want to become an iOS developer? I am planning to spend the summer learning iOS development, but with the announcement of Swift I’m not sure whether I should still focus on Objective-C or skip over it and start learning app development with Swift. Is Objective-C a necessary foundation for Swift?
I have seen different advice around: some people tell to start with Objective-C, others with Swift. If you never programmed before, some even suggest you start with a third programming language, unrelated to iOS, like Python.
This is my advice, whether you already know programming or not: start with Swift.
Swift is the new preferred choice from Apple and they are making it increasingly clear. Swift is going to be the standard language of the platform and it does not make sense in my opinion to spend energy on older technologies.
Yes, there are many reasons why you will still need to know Objective-C for a while. But that does not mean you need to know it from the start, especially if you are programming for the first time. Objective-C has a lot of cruft coming from the past, which you do not want to have in your way while you learn a new language (things like pointers and where you should put a * and where not. Ask around). When later you are going to need Objective-C, you can pick it up, coming from a solid foundation in programming and Swift.

It is true that Swift is a newer and more powerful language, which means that it includes more features. It is also true that you do not have to learn all those features all at once. This is also why I do not agree with the advice to learn programming in another language first. The rationale is that languages like Python do not include everything that Swift does, so they are easier to learn. This might be true in a sense: as a language Python might be easier to learn, if your goal is to learn the whole language. But that is not your goal and programming is programming, both in Swift and in any other programming languages.
The fundamental concepts are the same and they are not any harder to learn in Swift.
Finally, who wants to learn an unrelated language and then go through the hassle of learning a new syntax to be able to do some iOS development? Exactly: no one. That is why my advice is to ignore anything unrelated to iOS and to focus on Swift.
Apple has a guide for the Swift language, but this is a language reference for people who know programming already. If you do not know programming yet, that book is not for you. You will need to find other resources (stay tuned for more in the future).
Apple also released a guide for mixing the two languages together, when and if you will need to do so.

What you need to learn when you are starting with no experience

If you are starting from scratch and you have never programmed before, what is most important is to focus on basic programming concepts. Here is a list of the most important features in Swift to learn first.
Variables, constants and the main numeric types. Integers, floating point numbers and booleans are at the base of any programming you are going to do. Variables and constants are the way you store these values to be able to manipulate them. At the beginning it might seem to be pointless to work only with numbers, when modern apps have dynamic interfaces with buttons, gestures and animations. When I was learning programming, I always felt I was wasting my time and that real world programming was different. The reality is that numbers are a fundamental part of every program you will ever write. You need numbers for everything: counting things, placing objects on the screen, animations, etc. The fancier your app, the larger use of numbers you will make.

Basic operators. Assignment, arithmetic operators, ranges and logical operators manipulate the data and control the flow of a program. The fact that numbers appear so often causes sometimes the false impression that you need to know a lot of math. This is not true: to learn programming you need to be able to think logically and solve problems. Complex math is almost never required. You will mostly do basic arithmetic: sum, subtraction, multiplication and division. Later, when you are going to be more experienced and you will work on more complex apps, math might come in handy, especially for some games. Until then, no complex math knowledge is required.

Strings. Strings in programming represent text and you find them everywhere. Text is the way we communicate information and few apps are completely devoid of text. Strings are also often used to send data over a network. String manipulation is important to be able to create dynamically generated text or to create data structures to communicate with other programs.

Control flow structures. These allow you to make programs do something more useful than just follow a linear set of instructions. Control flow is at the base of any useful program. Loops (for and while) repeat instructions, while conditional statements (if and switch) make the decisions that guide your program.

Arrays and dictionaries (collections). Soon you will need a way to manipulate not only single values with variables, but lists of them. Arrays and dictionaries are the basic structures used to manipulate small and big sets of values. If you write an app to handle a todo list, for example, that list is going to be an array or a dictionary.

Functions. This is a concept borrowed from mathematics, but you do not need to know their mathematical counterpart. Functions are a way to group code that produces a specific result, giving it a name. In this way you can reuse it in different parts of your programs without copying and pasting the code around.

Structures, classes and object oriented programming concepts. Object oriented programming (OOP) is a further way to organize your code to make it more structured, understandable, manageable and easy to change. Although this is not a necessary programming paradigm and others exist, this is the way development on Apple platforms works.  It is important to understand it well to be able to work on complex projects. Other paradigms can be learned later. Functional programming is one of them and is getting some popularity since introduction of Swift. Be sure to learn and understand basic OOP concepts: encapsulation, composition, inheritance and polymorphism.

Automatic reference counting. This is how you manage memory on Apple platforms. You will not need to be concerned about this much while writing programs, but it is necessary to know some pitfalls that might cause problems in your apps.

What you can leave for later

These are, in my opinion, some less useful features of Swift, at least while learning. Some of them are actually quite important to know, but not at the beginning. I am not suggesting you skip them completely, but while learning programming they might get in your way.

Enumerations. This is a great Swift feature that allows you to create types other than the basic ones given to you by the language. Definitely a must know to write more readable code, but you can learn them after learning the basics of programming.

Optionals. This is a fundamental concept of Swift to deal with values that might not exist. As such, you cannot skip it, since you will have to use it often while making apps. But you can leave it out while you wrap your mind around the basic concepts of programming.

Extensions and protocols. These further help in structuring and architecting your code in a complex project. Extensions allow you to add functionality to existing object. Protocols to specify a set of functionality some objects are required to have. Learn them only when you understand basic OOP concepts well.

Tuples. They are a way of grouping a few values together without using a collection. Not really necessary until you understand why and where you would need them, but a nice feature to know and use.
Switch statements with ranges and tuples. This is a more complex type of switch statements that is more powerful and expressive. Definitely useful, but given the rarity of cases where you will use these, you can skip them at the beginning until you understand the benefit of using them.
Function types, nested functions and closures. Functions in Swift are a type of their own, like integers or strings. This means you can manipulate them the way you manipulate basic types: assigning them to variables or passing them as parameters to other functions. Although useful, this is a more advanced concept that  can be left for later. Many Apple APIs use them, so you will have to learn the concept at some point.

Generics. These allow you to create more flexible and reusable types and functions. They are definitely a must know, but not important when you are starting and still will not understand the benefit of using them.

Custom operators. Powerful but dangerous feature. They make the language more expressive and concise, but sometimes they make your code less readable. Given their double edged nature, some developers do not use them at all. You will at least need to know them when you will read code from developers that use them.

Assertions. These are a way to test for correctness of your code. Good to know, but not fundamental. Many developers find them useful, many others never use them.

Ternary operator. A concise alternative to express decisions instead of using an if statement. Many developers never use it since they find it unreadable. I use it often, but it is definitely not necessary.

Unicode strings. Unicode is an international standard for text. It is necessary only when dealing with alphabets different from our own or for special characters and symbols. Otherwise you usually do not need to bother.

Subscripts. These allow you to create custom types that behave like other collection types. They are definitely a nice feature to know, but they are not necessary and rarely used by developers.

Nested types. Types defined inside other types. A good feature to better structure your code in some cases, but not a fundamental concept.

Bitwise operators. Needed only when dealing with binary numbers. They are useful when you are dealing with hardware, low level network communications or maybe to build some efficient data structure. These are all advanced concepts and it is likely that you will never meet some of them in your career. I never had to work with these in any app I built, so they are definitely a feature you can skip until needed.

Different kinds of integers (8, 16, 32 or 64 bits integers). These are necessary only when dealing with architectural difference in hardware or low level transmission of data on networks. I never used any of these in more than 10 years of programming, so you can safely skip them and pick them up only when necessary.

Comments

Post a Comment

Popular posts from this blog

How to Apply for an iOS Developer Job

Partitioning and Naming Drives (Windows 8)