Programming may seem like a complex process, but on a basic level it's not hard to comprehend. This video shows how programming works on a basic level.
- [Instructor] Let's talk about some of the basics of programming. When you think of programming, there are actually three main steps. Now, there are different kinds of languages and some languages in which these steps don't apply, but for the sake of this course, programming has three elements. First, writing the code. Second, compiling the code. And third, running the code. Let's talk about how this process works. First, writing the code. When we write code, we write it in a human readable language, in English.
Now, you may be thinking you've seen code before, and it's not English at all. Let me show you what I mean by that, by the code being in English. In here, the first word that we see is "func." "Func" is short for "function," an English word. And you can see "displayScore." And then there's some coding characters that you may not be familiar with like parentheses and curly braces. But inside of there, we see "score = 100." We see the word "label," the word "text." So, programming is indeed based on the English language.
Now for right now, don't worry about what this code is supposed to do. All I want to show you is that there are English words in programming. The second step of programming is to compile the code. What that means is to take your English written code, or your human readable code, and convert that into code that a machine can understand. When you compile the code, it's called "build" in Xcode. It translates the human readable code into machine readable code, so that a computer can understand and execute it.
It also creates an app file known as an executable. Now, while this process may seem complicated, it's all done with the press of a button, and you've already seen it in action by simply hitting that Play button or that Run button in Xcode. In addition, when you're compiling the code, you can optionally designate certain lines of code to be ignored. These lines of code are called comments. They can be created by using two forward slashes, or with forward slashes and asterisks if you have a multiline comment.
Comments are used for notes to yourself, or to other developers, or they can be used to temporarily disable parts of code. Finally, let's talk about running code. This actually launches the application. When you run the code, it opens the executable file from the previous step. In Xcode, it also launches the iOS Simulator if you're building an iOS application. Code is generally processed from top to bottom, and it's guided by events. We'll talk more about how that process works later on in the course.
And usually, all the code is processed before the display is updated. So, it's not running one line of code, waiting a second, running another line of code, etc. Several lines of code or hundreds of lines of code may execute, and then you see feedback on the screen. And this happens so quickly, that we don't even notice it when we're using an application. Again, that Run button in Xcode builds and runs the application. So, you don't have to worry about how this process is working behind the scenes.
You literally just press a button or Command + R on your keyboard, and you're running the app in the simulator. So, to review, programming involves writing code in a human readable language, compiling it to a machine readable language, and running the application, in this case, in the iOS Simulator.
- Installing Xcode
- Creating an Xcode project
- Configuring the iOS Simulator
- Understanding variables
- Connecting visual objects to variables
- Understanding methods
- Connecting a button to a method
- Using conditional statements
- Setting up the user interface (UI)
- Building a complete iOS app