183
Chapter 5 Collision Theory and Logic
Pseudo Code
Writing logic statements is not actual computer code, but is a form of
pseudo code.
Pseudo code
is similar to, but not actual computer code. It helps
by breaking down the interactions into the logical steps that will be converted
into the final code statements of a specific computer language. Using the
framework of the pseudo code, many programmers can work on the same
project at the same time by converting segments of pseudo code into computer
language.
Another benefit of pseudo code is that it can be used as the structure for
many different computer languages. A program may need to be created for
different platforms. The choice of computer language used for each platform
may be different. With pseudo code, a team could create the program in Java
while another team created the program in Python. A programmer that can
write and understand pseudo code only needs to learn the syntax of a specific
computer language to program in many different languages.
Syntax
The programming words and symbols and their arrangement is called
syntax.
Your language arts teachers have been teaching you proper English syntax for
years. The first thing your language arts teacher made you learn were definitions
of words like the objects around you. Most high-level programming languages use
syntax that reads like a regular sentence. A line of programming code contains
some words that act like nouns, others that act like verbs, and some numbers and
adjectives to help make it all work. Read this line of Ruby code.
5.times { print “Hello World!” }
This is a command. Just like in
language arts class, the word you
is often omitted from a command.
When your mom says, “Wash the
dishes!” she is omitting the word
you. For programmers, the word
you refers only to the computer,
and it takes commands well
without having to call it by name.
Reading the
Ruby
command as a sentence states:
Five times print “Hello World!”
Converting this broken English to a working sentence makes it:
Computer, print “Hello World!” five times.
The syntax of the English language is familiar to you and you understand the syntax
of this sentence. The computer understands the syntax from the Ruby code better.
The syntax of the Ruby code includes some symbols like a period,
quotation marks, and curly brackets. These symbols all mean things in a
computer program. Additionally, lowercase and capital letters in front of
words often have special meaning. In English, punctuation symbols are part of
CHEAT CODE: RUBY
Ruby is one of many computer
programming languages. It is a
general purpose, object-oriented
language.
Previous Page Next Page