Getting Started in Computer Programming

Welcome to the class in computer programming. There are just a few things you need to do to get started.

The language we will be learning is called JavaScript. It is primarily used to add interactive functionality to web pages, but it's now also starting to be used for other things, including robotics. We will start by learning to create web pages, using HTML (HypterText Markup Language) and then learn to use JavaScript by putting JavaScript in web pages that you create. This page itself is a good first example of a web page.

Textbook

There are many resources on the web for learning JavaScript, so you can do fine in this course without a textbook. But having a book to follow and a reference source you can carry and page through can be useful. I can suggest two. The first is very complete:

Sams Teach Yourself HTML, CSS and JavaScript All in One
by Julie C. Meloni (2015, Pearson Education, 2nd Edition)
The second covers just JavaScript. It's the book I've used in the past before Meloni's book became available:
Sams Teach Yourself JavaScript in 24 Hours
by Michael Moncur (2002, Sams Publishing, any edition)
It may help you to know that the 24 hours means 24 lessons, each about an hour long; it doesn't mean that you can stay up all night and know how to write programs in JavaScript the next day.

One-time setup

We will use a web browser to view the web pages you create and the results of your JavaScript programs. But we also need another application, called an "editor", to edit the file that contains the web markup and JavaScript. And we need to make some small changes to your computer to make it easier to use the editor.

It has been a long-standing convention in computer operating systems to use an "extention" to a file name to indicate what's in the file. Image files end in ".jpg" or ".png" while text files end in ".txt". Web pages end in ".html". And when you double-click on the file to open it the application chosen to do the job matches the extension. The problem is, Windows and Mac both try to hide the file extension from the user. So you'll need to make some adjustments to make the file extensions visible.

Windows

The editor you will use in Windows is called Notepad.

To make file extensions visible in Windows open the Control Panel and go to "Appearance & Personalization". Select "Folder options" and press the "View" tab. Then uncheck the box marked "hide file extensions".

After this you will notice file extensions on all your files. PDF documents will end in ".pdf" and Microsoft Word documents will end in ".doc" or ".docx". This is a useful distinction, but it may be confusing at first. You'll get used to it.

Mac OS

The editor you will use on a Mac is called TextEdit.

On the Mac you have to tell TextEdit to not put the ".txt" file extension on all text files. You'll be editing HTML files as text files, but they should have the ".html" extension.

To do this, open TextEdit and select "Preferences". With the "New Document" tab selected, set the Format for a new document to be "Plain text" (not rich text). (Optionally, you can also set the window size to be 80×48, and select other options.) Then press the "Open and Save" tab and do the following:

  1. Under "When Opening a File:" check the box for "Display HTML files as HTML code instead of formatted text", and
  2. Under "When Saving a File:" uncheck the box for "Add '.txt' extension to plain text files"

Linux

You don't have to do anything special with Linux. You should use the emacs editor in a terminal window and everything will be fine. Linux is a version of Unix, and Unix always shows file extensions.

One thing you should be aware of is that Unix implements line endings differently, so if you copy your files to a Mac or Windows computer there won't be any line endings. You can fix this by running the command dos-to-unix once while editing the file.

Some Style hints

The following suggestions will make your life easier while working on computer programs and web pages: