Why Is HTML Not A Programming Language?

HTML is not a programming language. While some may point out that HTML is a “markup language”, this doesn’t clarify how that is different from a programming language. I’d like to provide a simple reasoning that is easy to understand by the layperson. (This isn’t meant to be a thorough argument, but rather a brief explanation that goes just a bit more in detail than “HTML isn’t a programming language but instead a markup language.”)

Here is a point I’d like to make: HTML is no more a programming language than Microsoft Word is. With Word (or any other word processor software), you can write out text and format it with different fonts, sizes, and colors. Images and tables and bullet points can be added as well. This is all done through the word processor’s graphical user interface.

An HTML file is similar, except it does not have a GUI. Instead, it is entirely written out in plaintext, so all the formatting instructions must be typed out as HTML tags (for example, <b> or <center>.) This “language” of tags is how we can format the appearance of a webpage.

Programming languages, on the other hand, can process data and make decisions. You can store data such as text strings and integers, and then manipulate these values to perform calculations. For example, doing some math or sorting text alphabetically are kinds of data processing that you cannot do in HTML.

Programming languages can also make decisions about what instructions they should execute. Depending on if a certain condition is true or false, a set of instructions may be executed or skipped by a program. Here is a Python example of such code:

if password == 'rosebud':
    print('Access granted.')
else:
    print('Access denied.')

Programming languages also have ways of executing instructions over and over again in loops. Loops, if-else statements, and other such instructions are called flow control statements. All programming languages have these flow control statements, but HTML (and Microsoft Word) do not.

JavaScript is a programming language. It has all these features of flow control and data processing. While JavaScript is used in many web pages, it is a distinctly separate thing from HTML. You can write HTML without JavaScript, and you can write JavaScript code without HTML.

Because HTML lacks these features, it cannot be called a programming language. One does not “program in HTML” nor could one “write HTML code”. You should never list HTML on your resume under “programming languages”.

The difference is not just a snobbish opinion of elitist software developers. While this post is by no means the definitive and complete reasoning of what a “programming language” is, it is good to know the general difference between a programming language and HTML.

Read More

“Invent with Scratch” Screencast Series

I’ve created a series of video screencast tutorials for Scratch. Scratch is a block-based programming environment from MIT. It is a programming education toy that is made for kids between the ages of 8 and 16. The screencasts can be found at:

“Invent with Scratch” Screencast at http://inventwithscratch.com

Scratch itself is hosted at http://scratch.mit.edu

I highly recommend Scratch as a teaching tool for younger kids who may not be ready for Python programming or are frustrated by their slow typing. Scratch is a drag-and-drop environment with code “blocks” that snap together.

Read More

Downloading Imgur Posts Linked From Reddit with Python

UPDATE – I have updated this article to use BeautifulSoup to parse the HTML rather than regular expressions. This makes it much easier.

Reddit is a popular site that allows users to post and vote on interesting web links. It is divided into several topical subreddits. Many Redditors use Imgur to host their images (and I highly recommend it: Imgur is free and easy to use). This tutorial tells you how to write a Python script that can scan Reddit and download images from Imgur submissions you find. This tutorial is for beginner-level programmers with a small amount of Python experience.

You can download the source code directly or view the GitHub repo.

This post will cover:

  • Basic web scraping concepts.
  • Command line options.
  • Accessing Reddit with the PRAW module.
  • Using regular expressions to find text patterns in a web page.
  • Downloading files with the Requests module.
  • Detecting which files are on our computer with the os and glob modules.
  • Opening files using Python’s with statement.

(more…)

Read More

Decimal, Binary, and Hexadecimal Odometers

It can be difficult to see how other number systems (such as binary and hexadecimal) work since they have a different amount of numerals than the ten numerals of decimal. But imagine that you are counting in these number systems using an old-fashioned analog odometer that has a different amount of numerals for each digit.

The following three odometers always show the same number, but they are written out differently in different number systems:
(more…)

Read More