Computer Skills for Research
Programming Concepts
By Mark Ciotola
First published on February 27, 2019
A computer program is a series of steps. They tend to be excellent for repetitive and automated tasks. There are several concepts that can be understood without writing actual code.
Statements
A statement tells the computer to do, including what logic to use. For example, a statement can tell the computer to print something, or how one value is related to another value.
Variables
In a computer, a variable is a place in the computer’s memory that is reserved for data. In mathematics, a variable is typically a number. However, in computers, variables can represent numbers, letters, words, entire graphics and other objects. Further, even computer variables for numbers come in specific types for different types of numbers (depending on the amount of memory required). Each programming language has its own variable types and ways of handling variables. (Operating systems have their own ways, but don’t worry about those unless you really need to know).
Common variable types are:
- Integer (the number must be an integer. So don’t use integer variables if you want to divide 3 by 8, and care about the fractional part).
- Decimal (keeps the decimal part of numbers)
- Double decimals (may be needed if your numbers will get really large)
- String (used for short phrases of text)
- Text (used for any size of text)
- Object (can store objects such as graphic).
Why use a “short” variable type, such as string, when you can have the flexibility of using a “long” one, such as text? Short variables require less memory and processing and can improve the performance of a program.
Variable types will differ among programming languages. Each program will use their own names for these variable types. They may not use all of them, and will likely include additional types.
Control Structures
An great advantage of programs over mere calculators if the ability to make decisions and take alternative paths of action. For example, a computer might decide to add or subtract a variable from the sum depending on the value of that variable. Or a program might continue to interactively run a process until a variable reaches a certain value.
Programs use control structures to make decisions. A control structure typically contains one or more conditions, and then one or more action paths depending on whether the condition(s) are met. Keywords that often indicate the presence of a condition are for, if, when and while. Examples of terms that indicate action paths are do, or operators such as +.
Loops
Programs tend to be great at repetitive tasks. A loop tells the computer to sum the talk contained in the loop over and over again, until some limit or respecified condition is met.
Input/Output
You will often want to enter data into a program and get data out. The program can be written to simply ask the user to type in the data, and the program can print out data to the screen. That is fine for many purposes.
However, you will also often want to read in and out files. This allows the program to repeatedly operate upon large quantities of data without manual entry. Most programs can read files, as long as they are in the proper format. Data entry can be often entered into a spreadsheet and exported as a comma separated value (CSV) file, as long rows and columns are used strictly consistently. Most programs can also write files.
Programming Languages
Programs are typically written in a programming language. HTML and CSS are akin to programming languages but lack many of the above features that make programming languages so powerful.
Some programming languages are similar to human verbal language while others are not. For learning, it is better to start with a language that is more similar to spoken language. This author recommends learning the Ruby language first. It is a full-featured modern language but is easier to read and write than many other languages.
Some computers come with many languages pre-installed. (Mac OS comes with Ruby pre-installed, although if your computer is older, you might not be running the most up-to-date version). To find out if a language is installed, go the your command line utility and type:
language name --version
If your language is installed, the language version will be displayed. If the language is not installed, your utility will probably display “command not found”. There can be exceptions to this approach.
Resources
- CS Unplugged (for school children, but the concepts are valid).
- Scribble provides a graphical way to learn programming and create art and graphics.
- Use Scribble in a web browser (available features may vary due among different web browsers)
« Styling a web page with CSS | COURSE | Scripting in JavaScript »