Hour of Code: Programming with Karel

Karel the Dog

undefined

Our introduction to Computer Science curriculum starts out very simply with Karel the Dog. Karel is a great way to get started coding, and you might wonder what Karel is, why we study Karel, and how it relates to CS as a discipline. This post is here to provide some answers!

What is Karel?

Karel is a dog that lives in your browser, in a Karel world. Karel understands four commands:

move();

putBall();

takeBall();

turnLeft();

With these four commands, you can help Karel solves problems of increasing complexity, from simple problems such as “go pick up that tennis ball!” to more complex problems, such as “for any world, of any given size, with any random placement of tennis balls, write a program so that Karel can identify and remove all tennis balls from the world.”

Why Karel

Programming, simply, is giving commands to a computer. And as it turns out, giving commands to a computer is a lot like giving commands to a dog. The commands that you give must be from a defined list of learned commands, they must be simple, and you must say them in a very specific way.

By limiting the number of commands our “computer” can take, we can focus on concepts of computer science that exist in every single programming language, such as loops, conditionals, and data structures. The way that you use these concepts in different programming languages will be different, but they are your underlying mechanisms for solving problems and are present in every programming language you will encounter. Understanding these concepts allows you to solve problems independent of programming language. Programming with Karel allows you to gain an objective knowledge of computer science without getting bogged down with syntax, or trapped into a single programming language.

You can apply the concepts that you learn in Karel to javascript, Python, C++, Swift — you name it. This is why we teach Karel — so that you can take that knowledge and apply it to ANY programming language you’d like to learn and ANY project that you’d like to make.

Ok, but really. What is Karel? A (kind-of) technical explanation.

That’s all well and good — we get that Karel is a dog, and we understand why we learn Karel, but what is going on underneath the hood? Is Karel a programming language we can use outside of CodeHS?

Karel is really just a thin library over javascript. A library is a collection of resources that computer programs use, at the direction of the programmer, to accomplish complicated tasks more easily. In our case, the library knows the commands that Karel knows and knows how to interpret those commands as changes to Karel’s world.

Feeling inspired to try Karel? Check out our Karel Hour of Code and start coding today!