Explaining strongly typed and weakly typed languages to a 12-year old

Literally.  My son is 12 and has been working on a Python text adventure this summer (on and off).  The adventure started off as a single script, and he has been transitioning it to use objects.  My husband and I have been helping him figure out what belongs to what object, and how to transition his code.

Blair and I had been thinking in Java terms since neither of us are familiar with Python, and were thinking that our son should move toward some type of interface type system so he could have “weapons” and “monsters” and you could treat any weapon as a generic Weapon.

We realized that since Python is weakly typed, this sort of construct is not really necessary and were discussing this with our son.  This is a rather difficult conversation to have with a child that has only a very basic understanding of programming (and all through hands-on classes that aren’t necessarily teaching the terms).


After a number of attempts to explain what the difference between a strongly typed language is, and a weakly typed language is, an analogy popped into my head that I think was helpful.

As a young child we all played with shape sorters like this one:

shape sorter

I said that a toy like this is like a strongly typed language.  Think of each of the holes as a variable.  Those holes can only hold certain shaped objects.  If you try to put the wrong shape in there, it just won’t work.

A weakly typed language would have holes large enough that any of the shapes could fit.  Like this:



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s