Speaking Code – A Complete Review of The Basics

programming for beginners

In no way is learning to code a natural or intuitive process. Like any other skill or hobby, the best way to expedite a new learning process is by first familiarizing yourself with the basics; here’s a brief overview.

Why is programming sometimes referred to as “Coding”?

Because a programmer’s “source code” is like a set of instructions that the CPU cannot initially decipher. That’s why “higher” language – your source code – is often considered to be an “encoded” sequence of instruction for the CPU to read. The “higher” programming language that you choose – and there are many – is then translated from your source code into a “lower language” that your CPU can actually register via a compiler program.

Compilers

A compiler is essentially the middle-man between you and the CPU that’s included in a Software Development Kit. It takes all of the source code that you’ve written in a higher language and transposes it into a stream of numbers that the CPU can read – machine code. As a rule of thumb, a program is compiled before it’s run.

Software Development Kits

An SDK is exactly what it sounds like: a package of software that a programmer uses in order to create programs with an integrated programming language. Each kit contains compilers, debuggers, and any other facilities needed to develop apps for a specific platform. For the most part, it’s highly uncommon to simply code using an SDK; it’s typically coupled with something called an Integrated Development Environment.

Integrated Development Environments

An IDE contains an SDK; most IDEs are tailored to function around a particular SDK. An IDE’s purpose is to make coding with an SDK more manageable. What an IDE is to a programmer is essentially what an instrument is to a musician: although all instruments can play music, certain instruments allow a musician to express him or herself in more desired or preferred format; although all IDEs can be used while coding, one IDE and its included SDK might be preferred or even necessary for creating a program that is compatible with a particular platform.

Android and iOS IDEs

Java and Objective-C are both programming languages used for coding Android and iOS apps respectively. Developers interested in developing apps for iOS devices should first familiarize themselves with the IDE called Xcode, which uses the iOS-compatible language of Objective-C. As for Android devices, Eclipse and Android Studio are both the go-to IDEs for coding in the Android-compatible language of Java. This also means that Android devices cannot run apps that are coded in Objective-C, and an iOS device cannot run apps that are coded in Java. There are, however, a few up-and-coming IDEs which are considered cross-platform compatible, such as Xamarin.

HTML and CSS

Both HTML (Hyper Text Markup Language) and CSS (Cascading Style Sheets) are programming languages that function in web development. HTML is used to structure a website with links, images, texts, videos and other “elements”; CSS is used in tandem with HTML to further stylize the layout of the webpage by re-arranging the colors, fonts, and positioning of HTML elements.

The three control structures of programming

  1. Sequential Execution: Instructions in your source code that are compiled and executed in the same order as they appear. When ending a line of code, instead of using a ‘period’ mark like you normally might in English, you’ll be using a semicolon. After each semicolon, it is standard procedure to start the next instruction one line away from where the previous line ended. Check out the image below and notice how each instruction that’s ended with a semicolon is followed by another on the next line. The instruction on line 57 begins at “font-family” and ends at the next semicolon, and a new instruction is created on line 58 in a similar fashion.
*Written in CSS

Some languages don’t delegate the semicolon with this purpose, such as HTML and Python, but most do: Xcode, C++, Java, CSS, etc.

  1. Conditional Statements: A more specialized instruction, known informally as the “if-then” statement: if a certain condition is met, then the included set of provided instructions will follow. In the image below, the phrase between the first parenthesis “(denom == 0 || num == 0)” is the conditional statement which, in this case, is testing whether or not the variable “denom” or the variable “num” is holding a value that is equal to 0. If it is, then the instruction below the conditional statement which is positioned between the two brackets are run, and the two variables are, again, set to the value of 0.
*Written in C++

Note: variables are assigned in C++ like so: “int denom = 0”. “int” designates the variable “denom” as an integer, and “= 0” sets the variable “denom”‘s value to 0. The variable can be changed at any time once it’s created by typing the variable’s name and resetting its value, such as the conditional statement does above: “denom = 0”

  1. Looping: Another specialized instruction, a looping statement is a sequence of instructions that is repeated until the specified condition is met. In the image below, the conditional statement is checking if the value inside of the variable ‘i’ is less than the value inside the variable ‘n.’ For every time the condition is NOT met, the loop will continue to repeat itself, starting with the conditional statement. That is until the value inside of the variable “i” is greater than the value inside the variable ‘n’ (‘n’ is given a value at an earlier line in the source code), the loop will continue to run, and the instruction enclosed in brackets “cout << a[i] << “ “;” (which displays a number into a separate console window) will run once every time the loop’s condition is NOT satisfied. The phrase “i++” means that the value inside of the variable “i” is being increased by one whole integer each time the loop is run. Eventually, the value of the variable “i” will be greater than that of the variable “n,” and the instruction listed between the brackets will stop being triggered.
*Written in C++

Queue vs Stack (FIFO vs LIFO)

Both queues and stacks are ordered arrays (lists), meaning that the order of their contained variables is significant. Ordered arrays are useful tools to have for problem-solving at all levels of coding.

  • Queue: an array of variables in which the first variable (a phone number, for instance) that is inputted into the array (a list of phone numbers) will also be the first variable that the queue will output when it’s commanded to do so. The image below illustrates that concept through the similar notion of waiting in line at the check-out aisle: the first person on the line will be the first person to get their groceries checked out.
  • Stack: an array (a list) of variables (phone numbers) in which the last variable to be inputted into the array is also the first variable that will be outputted. The image below illustrates how the entrance of the array is also its exit.