• Complain

Finn A. - Learn Swift

Here you can read online Finn A. - Learn Swift full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Finn A. Learn Swift
  • Book:
    Learn Swift
  • Author:
  • Genre:
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Learn Swift: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Learn Swift" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

AFinn, 2015. 165 p.Swift is a wonderful language that gives you an easy entry-point into the Apple developer ecosystem. If youve been put off developing for OS X and iOS because of the need to learn Objective-C, now is the time to start. Swift offers a relatively smooth transition from languages like Ruby and Python. This short book offers you a whirlwind tour of Swift.
Topics included:
Introduction
Running Code
Basics
Constants and Variables
Static Typing and Type Inference
Arrays
Dictionaries
Tuples
Control Flow
Optionals
Functions and Closures
Classes
Structures
Enumerations
Protocols
Extensions
Memory Management
Generics
What next?.

Finn A.: author's other books


Who wrote Learn Swift? Find out the surname, the name of the author of the book and a list of all author's works by series.

Learn Swift — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Learn Swift" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Learn Swift A whirlwind tour of the Swift programming language Aidan Finn - photo 1
Learn Swift
A whirlwind tour of the Swift programming language
Aidan Finn
Contents

Ever since iOS was first released, the default way to develop apps for it was using Objective-C. There have been a several other frameworks for creating apps that involve some variation of html/css/javascript embedded in an app container. But they all suffer from various problems including worse performance, limited functionality and general buginess. Building a native app is still the best way to go when it comes to Apple devices.

Then at Apples World Wide Developer Conference in 2014, Apple announced a new programming language: Swift, a language

drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU .

Swift 1.0 was released on September 9th, 2014 with version 6 of Xcode. With that release, a new era of development for Mac and iOS began. For anyone who has been programming in a modern language such as Ruby, Python, Clojure, Haskell.

If youve been programming in one of those languages for that last few years, youve probably become accustomed to a lot of the conveniences that they provide. Youre used to doing high-level programming in a dynamic language. As such, objective-c was probably not a good fit for you. Ive been programming professionally with Ruby and Python for over 10 years now. When the iPhone first came out I built a couple of apps for clients using Objective-C, but I didnt enjoy the experience and I quickly went back to Ruby development. But that has changed with the release of Swift.

Swift is a wonderful language, that combines many of the benefits of modern dynamic languages with the benefits of a strong type system, in a language that produces fast code. Its a joy to program in. And with its release, I think well see a lot of programmers who previously avoided programming for Apple hardware become more interested in coding for that platform. In short, the jump from languages like Ruby and Python to Swift is much smaller than the jump from those languages to Objective-C.

Swift is in the main an Object-Oriented language with some interesting features inspired by functional-style languages. Here are some of the highlights:

  • c-like syntax.
  • Type safe. Its strongly, staticly typed and checks types at compile time. It uses type inference so you dont need to declare types for everything.
  • Supports lots of data-types natively, including lists, dictionaries, tuples, enumerations, structs and classes.
  • Uses automatic reference counting for memory management.
  • Strong support for closures. Functions are first-class objects.
  • Supports interactive programming and scripting using repl and playgrounds.
  • Compiles to fast native code.
  • Object-Oriented: classes, protocols (similar to java interfaces), extensions (similar to ruby mixins).
  • Generics for generic programming.
  • Some limited support for pattern matching.
  • Functional. Theres enough functional goodness in Swift that you can eschew OO and program in a functional style if you want to.

Each chapter focuses on a specific feature of the language. Ill assume you already know how to program and so I wont go into great detail of various programming concepts. Instead Ill assume understand the basic language constructs from other programming languages and just show how various language constructs are implemented in Swift.

This book is for people who can already program in another language and are intrigued by Swift and want to learn it. It will outline all the various language features are implemented in Swift.

Learn Swift. Copyright (c) 2015 by Aidan Finn. All rights reserved.

All source code in the book is available under the MIT License.

  1. http://www.appcelerator.com/
  2. http://phonegap.com/
  3. React Native was introduced at React.js Conf 2015. It looks interesting but its too early to tell how it compares to native development and what compromises are involved in using it.
  4. http://nondot.org/sabre/
  5. I mention these languages specifically because I think practitioners in those languages will find a lot to like in Swift and will find the transition relatively easy. Specifically, if you tend towards using a functional-style when programming in those languages youll find that many of the idioms you are used to can be translated to Swift. The jump from these langyuages to Swift is much less painful than the jump from these languages to Objective-C.
  6. While its possible to entirely develop your app in Swift, youll still be making heavy use of the Apple Cocoa libraries. These have been heavily incluenced by years of Objective-C development so using them from Swift can often be somwhat ungainly.

The first thing you need to do with any new language is figure out how to get some code running. In this chapter well create a simple hello world program and run it in Swift. Well go through multiple ways of running a program: interactively at the REPL, interactively using playgrounds, and as a standalone executable program (using both Xcode and the swiftc command).

Figure 21 Installing Xcode using the App Store To get started youll need - photo 2
Figure 2.1: Installing Xcode using the App Store.

To get started youll need to have the latest version of Xcode installed (At the time of writing the latest version is 6.1). You can install Xcode through the Mac App Store (See ). To install it open up the app store, search for Xcode, and then install it. Its quite a large download so you may want to start the install now and go get a cup of tea.

A REPL is a read-eval-print-loop, and is a way of interactively running and inspecting code. If youve come from a dynamic language such as Ruby, Python or Clojure the REPL probably forms an important part of your development workflow. Youll often use it to try out libraries, debug existing code and inspect whats going on in your program.

Swift also has a REPL, although youll find it quite a bit different to the REPL youre used to (For playing around with Swift code, playgrounds - covered in .

You can run the Swift REPL from the command line and enter Swift code directly into it.

$ swiftWelcome to Swift! Type :help for assistance. 1> println ( "Hello world" ) Hello world 2> :quit

Whenever you enter valid Swift code in the REPL, it will immediately compile and run it.

Lets play around with the Swift REPL a bit.

$ swiftWelcome to Swift! Type :help for assistance. 1> 3.14 * 2.5 * 2.5 $R0 : Double = 19.625 2> println ( "The area of the circle is \($R0)" ) The area of the circle is 19.625 3> 4> $R0 * 2 $R1 : Double = 39.25 5> println ( "And double that is \($R1)" ) And double that is 39.25 6>

You can access previous lines that youve entered using $R0 etc. Each result in the REPL gets assigned to a $RN variable so you can later refer back to that result.

You can enter multi-line code and the REPL wont evaluate it until the code block is finished.

$ swiftWelcome to Swift! Type :help for assistance. 1> 3.14 * 2.5 * 2. 2.5 $R0 : Double = 19.625 3>

If we make a mistake when we enter our multi-line code, then we can edit the multiple lines as a single block. Here we enter a function to double an integer thats given as an argument, but we incorrectly declare the return type (well get to functions later, but for now just focus on the ability to correct multiple lines at once.)

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Learn Swift»

Look at similar books to Learn Swift. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Learn Swift»

Discussion, reviews of the book Learn Swift and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.