Foundational Concepts of Programming
Being able to code is an exceptionally useful skill, but learning that first language can be challenging. Generally the first step to learning to code is finding a tutorial, opening an editor and start coding. I understand and sympathize with this instinct entirely, but I believe there are some important concepts everyone should understand before learning to code.
One challenge when learning programming is the foundational knowledge that in some cases is assumed. By understanding these concepts your ability to learn to code will be much easier and more productive.
Concept #1 : type
To understand how something behaves and how something can be interacted with, you must understand its type. As an example, let's take a cup.
- I can fill a cup.
- I can empty a cup.
- int - Number without a decimal place
- float - Number with a decimal place
- char - A single character
- string - Multiple characters
Concept #2 : value
- 5 is a value with type int
- 26.8 is a value with type float
- c is a value with type character
- hello is a value with type string
Concept #3 : variable
A variable is a name with a type and a value. You express actions when programming using the names of variables. So let's define a variable with type cup which refers to the value of the Baby Yoda mug. The name of the variable is yourBabyYodaMug.
Now with yourBabyYodaMug variable which is of type cup your program can take actions on the value Baby Yoda mug. Hopefully these kind of contrived descriptions start give you a understanding of the foundational concepts.
All programming languages have ways to define a variable. Some languages require you to declare the type and name of a variable:
int myInteger
type variable
In these languages requiring variables to be declared with type, those variables can only hold values with the type defined.
Other languages have ways of just declaring variables with just a name:
myInteger
variable
In those languages, only requiring variables to be declared with just a name, then the type of the variable is defined by the type of the value the variable refers to.
Concept #4 : assignment
Variables are only useful when they refer to a value. A variable refers to a value through the action of assignment. Assignment is generally communicated by using the equal symbol =, with a variable left of the = and a value to the right of the =.
int myInteger = 5
type variable assignment value
This code describes a variable with the name myInteger with type int, is assigned to the value 5 which has a type of int. An important point is the type of the variable and the type of the value is the same.
Thank you for taking the time to read Part 1. I will describe a few more important concepts in Part 2, scope, functions and references.


No comments:
Post a Comment