Chapter 1.  What is Programming?

We use programming to instruct a computer. Computers include smartphones (such as the iPhone), tablets, game consoles (such as the PlayStation), and a lot more. We say that a computer runs a program, which means that when you open your favorite game or application (also referred to as an app) on your PlayStation or on your iPhone, the device will know how to interpret and execute the program, which in this case is your game or application. A program is simply a set of instructions that your device is able to understand. We can also consider these instructions as a recipe for the device. The recipe will tell your iPhone what your favorite game is all about-everything from the colors of your avatar, to the text in the menus, to what happens when you tap on an enemy or on an animal in a game. This recipe can be written in many ways depending on your personal preference and the device that is supposed to run it. The programming language refers to the language you choose to write your program in. 

This chapter will go through the following topics:

  • Introducing the Swift programming language
  • Why is programming important?
  • What the reader can expect from this book

What is Programming?

The Swift programming language

Swift is a programming language introduced by Apple, which you can use to create apps for the most common Apple devices, including the iPhone. The language and device you choose defines the possibilities for your program, for example, using Swift and targeting an iPhone as your device, you will be able to access the camera of the iPhone to take photos in your application, or the speaker of the iPhone in order to play sounds in your application. If you choose JavaScript as your programming language, HTML as your markup language and target the browser on your computer as your device, then you will be able to create interactive web pages. A programming language can differ much from language to language, and although the languages can share common concepts, it does not mean that one will master every programming language just by learning one. This leads to what programming is: it is the act of creating a program or recipe for your device to run. What is the result? The result is your program, your application, or your game.

The Swift programming language

Let's imagine this simple application for an iPhone-Movie Night, which has a list of your favorite movies. If the list is longer than the height of your device, you are able to scroll through the list by swiping up and down. You can add movies to your list by tapping a button and entering a name for the movie and you can delete them again by swiping left on the movie in the list. The idea of the app is to keep a list of your favorite movies so that you can remember them when having a movie night. In this case, the program is the application (called Movie Night), the device is the iPhone, and the instructions of the application could be the colors of the background and texts, the list in which you can scroll, and the add and delete functionalities. Programming is about creating these set of instructions so that we are able run our application on our iPhone. If you're excited about creating your own Movie Night app that you can use with your friends, then read along as this is an application we will build together in Chapter 14, Movie Night - iOS App.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.107.149