Expand Your Programming Vocabulary
You’re learning to program and you’re writing some code, then you hit a problem.
You go to search google for a solution, but you’re not exactly sure what to search for. “Problem with JavaScript”? That’s too vague. “JavaScript while loop not looping any more”? Lots of search results, but none of them are about your particular problem.
You look at some documentation. The are so many unfamiliar words and concepts that it might as well be written in another language.
In Angular, a Controller is defined by a JavaScript constructor function that is used to augment the Angular Scope.
Are they just making up words and mashing them together into a sentence? It’s indecipherable. You start googling for “controller” and “constructor function” and “angular scope,” trying to make sense out of the documentation. It just leads to more documentation, filled with more unfamiliar terms.
You decide to post a question on stackoverflow, and get an answer like this:
This is a minification related issue. Angular’s injector locates it’s in built services, such as $scope, $http etc. by name, so if your $scope or $http being injected into a controller, or service or whatever, gets minified to something like x or c or whatever, then angular will not be able to detect that it needs to create a $http service instance or provide a $scope, breaking everything. Stringifying $scope and other dependencies while creating controllers/directives etc. makes your code minification safe, because you’re saying whatever the first parameter that is passed into this function is minified to, it’s really called $scope, since minifiers don’t mangle strings.
You thought it couldn’t get any worse than the documentation, but it did. The answer is probably correct, but it’s effectively useless to you.
Does this scenario sound familiar?
Why You Need to Learn the Terminology
Consider a medical analogy:
I’m going to use the electric shock that’s a form of medicine if you’re very ill, but can make you sort of ill if you’re fine. Clear! Oh no. He was fine. Now he’s poorly from too much electric.
Doctors do not discuss diagnoses with each other in simple terms. Medical schools don’t teach in simple terms, either. Medicine is complicated, so they communicate with a complicated set of terminology. Everyone understands the term “broken leg,” but that is too vague for a medical diagnosis. Using precise terminology like “transverse compound fracture of the tibia” allows medical staff and students to communicate accurately.
Programming is not as complex as the human body, but it is still complex. This complexity is why programming has so much terminology. There are lots of concepts, and all of those concepts have names. Just like in medicine, we use terminology to communicate accurately, because simple terms are often too vague.
I’d love to give you: This man shares his three quick tips to understand programming – software developers hate him! But there are no three tips that will fix this problem. You just have to invest time into learning the vocabulary.
A List of Basic Programming Terms
Here are the definitions for some basic programming terms, with usage examples. These terms are applicable to most programming languages.
I’ve tried to keep the definitions as simple as I can. This means that some definitions will be missing details and nuances, but they are correct in a general sense. For the practical purposes of a beginner programmer, the minor technicalities aren’t that important.
Where a term from this list is used in a definition, it will link to the term and look like this. Where a term can be used as both a noun and a verb (e.g. assignment/assign), I’ve only included a single definition – both usages should be deducible from the one definition.
- algorithm
- (noun) a step-by-step procedure to achieve a specific goal.
Can be implemented with code.
Example: I used the quicksort algorithm to sort the array alphabetically. - argument
- (noun) a value that is passed into a function when it is called.
Arguments are said to be “passed” into a function, and functions are said to “take” arguments.
Also known as a “parameter.”
Example: That function takes two arguments. - array
- (noun) a type of value that contains a sequence of other values.
Example: I put all our names into an array of strings. - assignment
- (noun) the act of putting a value into a variable.
Example: I assigned the number22
to theage
variable. - brackets
- (noun) characters often used to surround text.
The different types of brackets are:
- Parenthesis/parens/round brackets:
(
)
- Curly brackets/braces:
{
}
- Angle brackets:
<
>
- Square brackets:
[
]
The bracket at the beginning is called the “opening” or the “left” bracket. The bracket at the end is called the “closing” or “right” bracket.
Example: Your code won’t compile because you forgot a closing bracket. - Parenthesis/parens/round brackets:
- bug
- (noun) a mistake in a program.
Example: There must be a bug because the output is wrong. - call
- (verb) to run the code in a function.
Also referred to as “running,” “executing,” or “invoking” a function.
For the noun, see function call.
Example: I called therand
function and it returned42
. - class
- (noun) a type that can be defined by the programmer.
Classes are defined in order to create objects of that class.
See object.
Example: I made aPerson
class that holds a person’s name and age. - comment
- (noun) arbitrary text written around code, but which is never run, and is generally ignored by the computer.
Used to leave notes and documentation for people who read the code later.
Also used to stop code from running (see comment out).
Example: I wrote comments in my code so I could understand it later. - comment out
- (verb) to turn code into a comment so that it does not get run.
Example: I commented out this line of code, and it doesn’t crash any more. - compiler
- (noun) a program that converts code into an executable, and checks that the syntax is correct.
Sometimes compilers convert code into other code.
Example: The compiler is giving me an error, so I must have incorrect syntax somewhere. - constant
- (noun) a variable that never changes its value.
Example: ThePI
constant has the value3.14
. - crash
- (verb) to cause a running program to stop due to an error.
Example: I tried to divide a number by zero, which made the program crash. - data structure
- (noun) a value that contains other values.
Example: Arrays are one kind of data structure. - debug
- (verb) to investigate and fix bugs.
Example: I spent all day debugging a complicated error. - declaration
- (noun) code that declares that something exists – usually a variable, function or a class.
A declaration might not fully define the thing it is declaring.
E.g. a constant may be declared to exist, without actually defining what it’s value is.
Not all programming languages allow for declarations.
Example: My code won’t compile because I wrote a function declaration, but I forgot to write the actual function. - definition
- (noun) code that fully implements something – usually a variable, function or a class.
The code that implements a class is called the “class definition.”
The code that implements a function is called the “function definition.”
Example: The function wasn’t doing what I expected, so I had a look at its definition. - double
- (noun) a float that can represent a wider range of numbers than a normal float.
Short for “double-precision floating-point number.”
See float.
Example: The number was so tiny I had to use a double instead of a float - execute
- (verb) Synonym for run.
Example: I can’t execute my program because it won’t compile. - executable
- (noun) a program, usually a single file, ready to be run.
Example: Give me the executable so I can try out your program. - float
- (noun) a type of value that represents numbers with fractional parts.
Short for “floating-point number”.
Example: The value3.14
is a float. - function
- (noun) a piece of code that is not run until it is called.
Functions take zero or more arguments.
When a function finishes running, it returns a return value back to the code that called it.
Example: I wrote a function that takes an array of numbers as an argument, and returns the average. - function call
- (noun) code for calling a function.
Function calls specify which function to call, and all of the arguments that the function requires.
The result of a function call is a return value.
Not all functions have a return value.
Example: The function calladd(1,2,3)
returns the value6
. - implement
- (verb) to write all the code to complete something – usually a function or a class.
Example: I finished implementing those functions. - instance
- (noun) Synonym for object.
Example: I created an instance of thePerson
class. - instance variable
- (noun) a variable that is attached to an object.
Also known as a “member variable” or just a “member.”
Example: On thetom
object, I assigned the value"Tom Dalling"
to thename
instance variable. - instantiate
- (verb) to create an object from a class.
Example: I instantiated an object of thePerson
class. - integer
- (noun) a type of value that represents whole numbers.
For fractional numbers, see float.
Example:42
is an integer value. - interpreter
- (noun) a program that runs code.
For languages that are not compiled, the source code is run directly by an interpreter.
Compiled programming languages do not usually have an interpreter.
Example: I installed the Ruby interpreter so I can run my Ruby code. - invoke
- (verb) Synonym for call.
Example: I invoked the function with the wrong arguments, and it crashed. - iterate
- (verb) Synonym for loop.
Example: I iterated over all the values in the array. - loop
- (noun) a piece of code that runs itself repeatedly.
Commonly used to run a piece code for every value in an array.
Also known as “iteration”.
Example: The code loops until the user types in “quit.” - member function
- (noun) Synonym for method.
Example: This class has three member functions. - member variable
- (noun) Synonym for instance variable.
Example: This class has two member variables. - method
- (noun) a function that is attached to an object.
Methods belong to, and are defined in, a class.
Also known as a “member function.”
Example: Thelength
method returns the number of characters in a string object. - nested
- (adjective) contained within something like itself.
E.g. a nested array is an array that is inside another array, and a nested class is a class defined inside the definition of another class.
Example: I used a nested loop to loop over a grid – the outer loop for thex
coordinate, and the inner loop for they
coordinate. - object
- (noun) a value created from a class.
E.g. If you want to represent your family in code then you might make a class called
FamilyMember
, and create several objects from that class – one object for each person in your family. Objects usually contain other values inside instance variables, and have methods attached to them. E.g. eachFamilyMember
object might have aname
instance variable. Objects combine the concept of variables and functions into a single value. Also known as an “instance.”
Example: I make the enemy move by changing theposition
instance variable of theenemy
object. - object-oriented
- (adjective) designed using objects.
Example: Ruby is an object-oriented programming language because all values are objects in Ruby. - parameter
- (noun) Synonym for argument.
Example: That function takes two parameters. - parenthesis
- (noun) A type of bracket.
Example: Lisp-like programming languages use a lot of parenthesis in their syntax. - procedure
- (noun) Synonym for function.
Example: That procedure takes two arguments. - program
- (noun) a full piece of software that is ready to be run.
Usually an executable.
Example: I wrote a program that keeps track of my todo list. - read
- (verb) to retrieve input data values from an external source – usually from a file.
Can refer to retrieving data over a network, such as the internet.
The opposite of writing.
Example: I read the contents of file into a string. - return
- (verb) to immediately stop a called function from running, possibly providing a return value.
A function automatically returns once all of its code has been run.
However, the code in the function definition can force the function to return at any point.
Example: If the array is empty, the function returns early without running the rest of its code. - return value
- (noun) the value that results from a completed function call.
Example: The return value of therand
function is a random float between0.0
and1.0
. - run
- (verb) to perform the instructions written in code or an executable.
Code is a set of instructions, and “running” code is when the computer actually performs those instructions.
To “run” a function means to call that function (see call).
Example: I wrote a new feature, and ran the code to check that it works. - string
- (noun) a type of value that represents text.
The word “string” derives from the phrase “string of characters.”
E.g. The string
"cat"
is a string (a.k.a. sequence) of the characters ‘c’, ‘a’, and ‘t’.
Example: I represented my name as a string in the code. - syntax
- (noun) the grammatical rules of a programming language.
Every programming language has different syntax.
Syntax determines whether code is written correctly or incorrectly, and is enforced by the compiler or interpreter.
Code will not compile or run unless the syntax is correct.
Example: I forgot to write the brackets, so the compiler gave me a syntax error. - type
- (noun) the kind or category of a value.
Every value has a type.
- The value
5
is of the integer type. - The value
5.2
is of the float type. - The value
"cat"
is of the string type.
Simple types, like integers, are usually provided by the programming language. The programmer can define more complicated types using classes. The type of an object determines what methods and instance variables are attached to that object.
Example: I got a crash because the variable contained the wrong type of value – I thought it would be an integer, but it was actually a string. - The value
- value
- (noun) a piece of data that can be contained inside a variable.
Every value has a type.
Values represent information, in a way that code can work upon.
Code can:
- send and receive values over the internet
- save values into files
- convert values into different values
- etc.
Example: My program asks a user for the year they were born, then uses that value to calculate their age.
- variable
- (noun) a named container for a single value.
Variables are not values themselves, they are merely containers for values.
Putting a value into a variable is referred to as assignment.
Variables are named after the fact that their value can vary – a different value can be assigned to a variable at any time.
Example: I assigned the string value"Tom"
to thename
variable. - write
- (verb) to send output data values to an external destination – usually to a file.
Can refer to sending data over a network, such as the internet.
The opposite of reading.
Example: The program writes all its data to a file before it quits, so it can read the data back again next time it is run.
How Terminology Is Used in the Book
The first few chapters are written without much terminology. This part of the book is designed to get you to write your first program without overloading you with unfamiliar words.
At the start of Chapter 3, much like this article, the book defines eight fundamental terms, mostly relating to functions. Functions are probably the most important concept in all of programming, so an understanding of these terms is absolutely required. The eight terms are:
- argument
- assign
- call
- function
- function call
- return
- return value
- value
The rest of the book is written in these terms. Firstly, this allows the book to explain concepts more accurately. Secondly, it repeatedly demonstrates correct usage of the terms, hopefully allowing them to sink in and become part of your own vocabulary.
The term “function” is left a little bit ambiguous, up until you are required to implement one yourself. At that point, the book revisits the eight terms above. You have written a few programs by this point, so the terms should be clearer, and you should be able to absorb the more-detailed explanations.
Notice that there are more definitions in this article than in the book. This is on purpose. The book aims to drill in the most fundamental terms, as a first priority. Other terms are explained, but they are not given as much emphasis.
If this sounds good to you, give the book a try!