---------------------------------------------------------------------------
                  Beginner's Guide to Computer Language
                            Gorboth, 2017
---------------------------------------------------------------------------
INTRODUCTION:
~~~~~~~~~~~~

Learning to "code" is typically very daunting, because we are not taught
to think like a computer. We generally think of computers as fool-proof
machines that can do things with amazing speed and precision. In fact,
they are fantastically stupid, and will not be able to do even the most
simple thing unless you talk to them, without mistakes, in the very
limited manner in which they expect and can interperet as a language.

There are many of these "languages" that have been developed over time
which let us tell computers what we want them to do. One such language
is LPC, which is what we use when we create things in Genesis, or any
of the many other MUDs that have been developed with its use. As with
any language, it is important to understand the relationship between
the author and the reader. You, as the coder, are the author, and the
computer (or interpreter, in the case of LPC) is the reader.

HOW CODE IS WRITTEN AND READ:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Lets say you give the computer a file containing the following code:

   1     string   my_name;
   2     int      amount;
   3
   4     my_name = "Gorboth";
   5     amount  = 100;
   6
   7     write("Supposedly, " + my_name + " can eat " + amount + "pies.\n");

Firstly, I've used line numbers so we can discuss what is written. Code
editors use line numbers so you can reference different parts of your
code according to what line it is written on. You don't actually have to
type in the numbers, but rather your code is written on the different
lines. Line numbers are also used by the computer in error messages to
tell you on which line you might have confused the computer if it tried
to read your code and failed.

When the computer gets this, it starts at line 1, and scans from
left to right (just like you would when reading a book, unless you are
from an Asian tradition) to see what the code says. When it gets to
a semicolon ";" it treats that sort of like we would treat a period "."
when we read a book. It is the end of a statement, and tells the
computer to process the commands that preceeded it. What is interesting
is that the processor does not care how much "white space" you use
between the different parts of a statement. So, the code could look
like this, and mean exactly the same to the computer:

   1 string my_name;int amount;my_name="Gorboth";amount=100;write("Supposedly,
"+my_name+" can eat "+amount+"pies.\n");

This gets the job done in just one line, but is far harder to read by
a human who is trying to understand what they are looking at. Space and
newlines are our friend, and so we use them to our advantage to make the
code both easily readable to the computer *and* to our fellow coders!

As a particularly annoying example, the following would also work:

   1 string                                             my_name    ;
   2                  int          amount            ;
   3
   4    my_name=           "Gorboth"                         ;
   5                                      amount               =100;
   6
   7     write("Supposedly, " + my_name + " can eat " + amount + "pies.\n");

Ugly, and no one would do that unless they were being silly. But! It does
illustrate further the point that the computer doesn't care how we use
space and newlines to line up our code. That is only important to we
humans who must also be able to read it. The computer only cares that
the interpreter-specific communication is correctly in place.

For example, let us return to the nicely aligned example from before, but
make a very simple mistake that we might miss but the computer would
completely choke on:

   1     string   my_name;
   2     int      amount;
   3
   4     my_name = "Gorboth";
   5     amount  = 100
   6
   7     write("Supposedly, " + my_name + " can eat " + amount + "pies.\n");

Do you see the mistake? Well, the computer would! It would choke on line 5.
Look again at line 5 and see if you can find the mistake. You might notice
that we have forgotten to put the semicolon ";" at the end of that line.
This would completely halt the computer's ability to read the code, and
the computer would insist that we fix that before it could understand
what we were trying to have it do. If this code existed in a file that was
called, for instance, gorboth_eating.c you might see something like this
as a result of trying to load the file:

> load gorboth_eating
/w/gorboth/open/new_wiz/gorboth_eating.c line 5:syntax error
Error loading: /w/gorboth/open/new_wiz/gorboth_eating.c
Message: *Error in loading object

Of course, as a human, we look at that and think, "but if I was reading
a book and there was a period missing, I would still be able to understand
what the book was saying!" Very true! We return again to the fact that
computers, though capable of amazing things when programmed correctly, are
devastatingly simple and stupid at their basic levels, and do not possess
the human ability to see past mistakes. For this reason, one of the first
skills you need to develop as the author of code is patience with your
reader (the computer.) Frustration can mount quickly when your code isn't
working, and it often will require you to take a step back and carefully
sift your code for the tiniest error that has caused the poor stupid
computer to get confused. It is for this reason that using all that good
space and newlines to get things nicely lined up for humans to read is
so vitally important. Finding mistakes in sloppy code is darn near
impossible, which has lead to the development of standards for how to
write code neatly. <man code_standards> to see them, and know that you are
now a much better person and are guaranteed entry into heaven someday.

