smilesforgood
Posted on June 21, 2021
A really super beginner list of vocab words for code, because sometimes as I’m learning, I just want a brief 10 second synopsis on a term. (When language matters, this list is specific to Ruby.) So here goes:
Variable: a placeholder for a value. This is represented by a “bare word” data type. It allows you to access a value (which could be an extremely long bit of information) via your (typically short) variable name. In addition, as the name implies, a variable’s value can vary, though the specific rules on how it can vary, depend on the language. You can think of a variable as a labeled drawer holding some value.
Constant: this is like a variable, in that it is also a placeholder for a value. However, unlike a variable which can vary, a constant will be set equal to a value once in the course of your program and then it should not be reassigned. (You technically could reassign the constant. The language won’t physically stop you, but you shouldn’t reassign it!) Anytime you call the constant’s name, it will (or should!) always point to the value to which it was originally assigned. In Ruby, a constant starts with a capital letter.
Method: a set of instructions for something you want your code to do. Methods must be “defined” before they can be “called” or “invoked” at one (or many!) points later.
#this is the method definition:
def do_something
puts "Hello"
end
#this is the method invocation:
do_something
=> Hello
nil
- Parameters: a method can be defined to take information. The parameters are the placeholders in the method definition for that information. For example, we could make our above method take an argument containing some bit of data, and
puts
out the value of that data, rather than alwaysput
ting “Hello”:
def do_something(data)
puts data
end
- Arguments: these are very similar to parameters. These are the actual bits of data that are passed into a method’s parameter spot(s) when the method is called. An argument can be raw data (like a “string”) or it can be the name of a variable, where the variable name points to the raw data:
#passing raw data in as an argument:
do_something("hi")
//=> "hi"
nil
#assigning a value to a variable and then passing that variable in as the argument:
greeting = "hola"
do_something(greeting)
//=> "hola"
nil
- Return Value: In Ruby, a method implicitly (meaning without you having to say so) returns the value of the last line of code - unless you specifically return at some other point. In all of our examples above,
nil
is the return value of calling thedo_something
method. (Ourdo_something
method is itself invoking theputs
method on its last line. The return value ofputs
isnil
, so our methoddo_something
returnsnil
or the value of the last evaluated line of code. If we wanteddo_something
to simply returnhello
, we could type hello on the last line inside the function (we would still need to useputs
if we also wanted the method to output hello):
def do_something
puts "hello"
"hello"
end
do_something
//=> hello #this is the output 'hello'
hello #this is the return from the last line inside the method
Terminal: the terminal is where code is “run” and evaluated. This allows you to run a program to “test” it with special tests (written to compare expected code results with actual code results) or see the output, especially in the case of a ‘command line program.’
Text Editor This is the place where you create and edit code projects, similar to using Microsoft Word or Google Docs to write a paper. Text editors are loaded up with code languages; they allow you to format code documents based on the language you are writing, as well as package up multiple files into a larger project. Some examples of text editors include Atom and VS Code. You can choose to run a terminal (where you actually run the code) from within a text editor or separately. Regardless of whether you run your terminal separately or inside your text editor, you generally operate the text editor and the terminal hand in hand while you are designing code. You’ll type in the text editor to write or edit code then run that code in the terminal to see what happens.
Keywords: These are reserved words in a code language that have already been assigned meaning by the writers of the language. Because they are reserved (and already have definitions), they should not be used to name variables or methods. Doing so would cause confusion as you would be over-writing existing definitions with special, temporary definitions. Some examples of Ruby keywords are:
if
,else
,def
,yield
,do
,puts
,print
, etc.Program: this is a collection of code that can be compiled and run together. A program can be as simple as one file, or as complicated as you’d like. Ultimately this is a blanket term for a collection of code that performs some (or many) action(s).
And there you have it! These are some quick definitions to a few of the vocabulary words that I regularly found myself Googling at the beginning of my coding journey. This is by no means comprehensive, even for the vocabulary words above. As with everything in code, you could go much (much) deeper into these words, their meaning, and how they interact with so many other aspects of code.
** Originally published April 30, 2021 via github.io
Posted on June 21, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.