Swift for dummies

8 lat temu
2172 0

Swift is a relatively new programming language (introduced in 2014) developed by Apple for iOS and macOS. It was designed as an alternative for Objective-C: simpler syntax, no pointers and dot-notation style, which makes it a more friendly language to learn for people like me, who are more familiar with C# or Java. Swift is open source and available on GitHub.

I am a swift dummy and so I started by looking for some free ebooks, courses or tutorials to make the first difficult steps in the iOS development world. I can tell that Apple has made a good job in promoting Swift and many free resources can be found on apple.com/swift.

I downloaded The Swift Programming Language through iBooks on my phone and read the book in my free time. I haven’t finished it yet, but my goal was to get an overall overview and get used to language’s syntax.

I also downloaded App Development with Swift, which is a great book to start with, even if you are a newbie programmer.

The first chapters cover some programming fundamentals and basic concepts, but it’s good to read them anyway. There are videos that help to follow the described steps and the course comes together with a bunch of files that one can experiment with. This is actually a pretty cool feature and it’s called a playground. The same idea was introduced by xamarin team, they called it a workbook. I saw it in action at Xamarin Evolve 2016 at was really impressed. A playground is like a little test environment where you can type some code, make experiments and where you can see immediate results, without the need to build the whole app.

You can tell that a book refers to a real modern programming language, when after finishing Hello world! you find statements like this:

Congratulations and welcome! It may seem like a lot of fuss over single line of code, but you’re now part of a long programming tradition. Feel free to capture the moment with a selfie of yourself and the screen.

I’m curious how many selfies where made on this occasion ;)

One of Swift features is that strings fully support unicode. I was amused to find the example with polish pasztecik szczeciński:

This goes even further – you can name your variables and constants with unicode characters, look at this:

This is a correct constant declaration. Xcode has even a shortcut for pasting emoji into the code: really funny and completely useless at the same time :)

I have also learned some other interesting facts, like: there’s no need to place semicolon at the end of the line and protocol is what I know as interface in C#. Stay tuned, there’s more to come ;)