Debugging your code
Debugging is going to be a natural part of creating an application. The computer always follows
your instructions exactly, yet no program ever works as you expect it to. Debugging can be
frustrating. Three of the more common mistakes to watch out for are
» Syntax errors: These are errors caused by misspelling words/commands, by omitting
characters, or by including extra characters. Some languages, such as HTML and CSS, are
forgiving of these errors, and your code will still work even with some syntax errors;
whereas other languages, such as JavaScript, are more particular, and your code won’t
run when even one such error
is present.
» Logic errors: These are harder to fix. With logic errors, your syntax is correct, but the
program behaves differently than you expected, such as when the prices of the items in
the shopping cart of an e-commerce site don’t add up to the correct total.
» Display errors: These are common mainly in web applications. With display errors,
your program might run and work properly, but it won’t appear properly. Web apps
today run on many devices, browsers, and screen sizes, so extensive testing is the only
way to catch these types of errors.
The word debugging was popularized in the 1940s by Grace Hopper, who fixed a
computer error by literally removing a moth from a computer.
Picking Tools for the Job
Now you’re ready to actually start coding. You can develop websites either offline, by
working with an editor, or online, with a web service such as Codecademy.com.
Especially if you haven’t done any coding before, I strongly recommend that you code with
access to an Internet connection using the Codecademy.com platform, because you don’t have
to download and install any software to start coding, you don’t have to find a web host to serve
your web pages, and you don’t need to upload your web page to a web host. As you code, the
Codecademy.com platform does these tasks for you automatically.
Working offline
To code offline, you need the following:
» Editor: This refers to the text editor you use to write all the code this book covers,
including HTML, CSS, JavaScript, Ruby, Python, and PHP.
The editor you use will depend on the type of computer you have:
se the preinstalled Notepad or install Notepad++, a free editor
• PC: U
available for download at http://notepad-plus-plus.org.
• Mac: Use the preinstalled TextEdit or install TextMate 2.0, an open-source
editor available for download at http://macromates.com.
» Browser: Many browsers exist, including Firefox, Safari, Internet Explorer,
and Opera.
I recommend you use Chrome, because it offers the most support for the latest HTML
standards. It’s available for download at www.google.com/ chrome/browser.
» Web host: In order for your website code to be accessible to everyone on the
Internet, you need to host your website online. Freemium web hosts include Weebly
(www.weebly.com) and Wix (www.wix.com); these sites offer basic hosting but charge
for additional features such as additional storage or removal of ads. Google provides
free web hosting through Google Sites (http://sites.google.com) and Google Drive
(http://drive.google.com).