---
layout: post
title: Teaching Your Cat About Compilers, episode 1
summary: A practical guide to teaching your cat about compilers
---

When teaching your cat about compilers, the best place to start is with a
vague, abstract definition of what a compiler is.

> Simply stated, a compiler is a program that can read a program in one
> language -- the source language -- and translate it into an equivalent
> program in another language -- the target language.

Aho et al., *Compilers: Principles, Techniques, Tools 2nd Ed.*

Your cat hears this, takes a big yawn, and then inquires as to what **is** a
[programming] language?

The question strikes you because you have never really considered it too
deeply before yourself. *What is a programming language?*

You stare into the abyss for a moment, but only for a moment. You brush off
the question by explaining to your cat that *a programming language is
simply a way to talk to a computer; a way to instruct a computer to do
various tasks.* You quickly move on before your cat can inquire further.
Perhaps you will address the topic in more depth later on.

*Anyway, back to compilers.* You have your cat's waning attention.

You explain that once a program has been written in a programming language
that is easy for humans to read and write, the compiler will process that
program and produce a version of the program that the computer can more
easily read. *You see, as nasty as C might look, it is actually quite easy
for us to read and write in comparison to machine instructions.
High-level programming languages are great!*

Your cat seems intrigued and asks if that is how ruby works.

You are caught off guard not realizing that your cat knows about ruby. You
then quickly begin to backpedal as you try to explain *well, actually, you
see, ruby is an interpreted language. It doesn't have a compiler. It has an
interpreter. Ruby is what we call an interpreted language*

Your cat is not deterred. Eager to put these concepts together, your cat
states that Java must be a good example of a compiled language.

*Well sorta,* you begin to explain as you backpedal even further. *The thing
with Java is that it is sorta a hybrid. It is a compiled language, but the
target program that the compiler gives you is run through an interpreter.*

Running out of familiar languages, your cat wonders about JavaScript.

*Good question. The thing about JavaScript is that it is often run through a
Just-In-Time compiler which is a different hybrid approach that combines
compilation and interpretation. That is a bit off track though.*
You begin to realize how complicated this whole compiler thing is going to
be to explain.

You hug your cat. *Maybe that is enough compilers for one day.*

Add a new post about teaching compilers to your cat.
Add a new post about teaching compilers to your cat.
