August 01, 2013

No Threshold, No Limit

Why aren't computer languages part of the standard grade-school curriculum?

A big part of the reason is that the computer science community has not standardized on a good learning language. Some elementary educators use Scratch; the FIRST robotics program mandates NXT-G; Kahn Academy teaches Javascript; the AP test standard for high-schoolers is Java; and for the college kids, MIT 6.01 has recently switched from Scheme to Python.

I have taught using all of these languages. Each language has its advantages; but they also all have major drawbacks for teaching. None scales all the way from kindergarten to college. The best advice today is for students to learn half a dozen different languages. The implication is that, to learn programming, you need to be pretty devoted to the task.

Unfortunately, for the routine teaching of regular kids in mainstream schools, the lack of a standard notation means no languages are taught at all.

Remembering LOGO and BASIC

The best "universal learning language" efforts to date have been LOGO and BASIC. BASIC is not a well-loved language today. With line numbers, goto, and a lack of encapsulation, BASIC forced you into bad habits and sloppy thinking.

However, in the years when it was popular, BASIC had the advantage that it was both the first language to learn and a language that was used to write commercial software. BASIC was everywhere. And by taking a peek at big programs written in BASIC, a student could see endless fields of possibility stretching out ahead.

LOGO is a better-designed language. Although LOGO feels abandoned and antiquated in the Internet age, LOGO also got a key thing right: the goal of "No Threshold, No Limit." That slogan meant that LOGO was both easy enough for children who want to see feedback after typing five letters, and powerful enough for advanced learners who want to build an AI.

In 2013 is there any modern equivalent to LOGO or BASIC?

Yes, there is a modern language with the easy elegance of LOGO and the practical hackability of BASIC. A single language that scales from kindergarten to pros. But it is a new language, not listed above. It is a language that does not even aspire to be an educator's language. Yet it is a language that has fortuitously appeared in the "no threshold, no limit" sweet spot.

More thoughts below....

The First Step is a Doozy

Javascript seems like a good candidate because its thresholds are low and its limits are high.

However, when I taught Javascript to a classroom of Dorchester sixth graders last year, I got a terrific lesson in what "no threshold" really needs to mean to be effective for teaching. In my classroom, half the kids stumbled on the first day.

The first lesson of programming is that "the computer will do what you tell it." And to a seasoned programmer, the one-liner below seems like a pretty simple way to teach that lesson.

// Welcome to Javascript.
alert("hello world");

But if you stop and think about it, that is not a great first program. For example, it requires parentheses. That means you need to locate the curvy symbols over the 9 and 0 and hold down the shift key at the same time. Kids raised on mobile texting have no idea where to find parentheses. And if you confuse the smooth parentheses with the square or the curly ones, they don't work!

Our "hello world" program also requires matching quotes (but not backticks!); and there is the odd semicolon, which is not required, but advisable for reasons that are hard to explain. Next, as soon as we introduce conditionals or loops, Javascript code is awash in new punctuation: curly braces for blocks, && for "and"; || for "or" and the exclamation mark for "not".

When half the students are confused by a jumble of symbols that they cannot even find on the keyboard, it is very difficult to get a classroom motivated.

Lowering the Threshold

The design of LOGO anticipates these issues. LOGO is punctuation-free until loops are introduced. For kids who cannot yet spell (or for whom English is a second language), it includes two-letter abbreviations for all important methods.

fd 100
rt 90
fd 100

Scratch and NXT-G go one step further and avoid typing altogether. You just drag blocks on the screen to assemble a program. That is what "no threshold" is all about.

But there is a problem with these visual languages.

Don't Clip My Wings

When I have tried teaching NXT-G, Scratch, and LOGO to my enrichment-program kids in Lincoln, the kids get deflated pretty quickly.

It does not take long for a motivated child to ask the question, "can I embed a Taylor Swift video" or "can I make it say Haaarg?," and no teacher wants to have to say "it can not be done."

The various visual teaching languages have their own drawbacks. For example, as terrific as LOGO was back in the day, LOGO is simply too limited in the modern world. It runs slowly. It runs in an old-fashioned environment. It doesn't connect with the libraries and media and capabilities and communities any kid will find on the internet.

NXT-G is also too limited. Is is incapable of expressing pretty simple programming concepts such as arrays, so an NXT-G program can basically have no memory. Worse, the NXT-G visual editor is buggy and too often results in a corrupted program file. My FIRST lego robotics team kids often tell me they wish they could edit their robot programs as plain text files, to avoid the clumsy visual editor.

Of the three, Scratch is the most up-to-date, but its visual approach is still limiting on the upper end: without natural local variables and data structures, algorithms are a slog in Scratch. And Scratch is not "real." You would not build a website in Scratch. Teaching kids to realize their dreams while working around the limitations of a visual educator's language can feel like teaching algebra using Roman numerals.

So as students advance past drawing spirals on the screen and begin asking questions such as "how would you program tic-tac-toe," a teacher quickly realizes that kids are best off stopping with LOGO or Scratch and learning a more "professional" language like Python or Javascript.

An Educational Wishlist

In the end, it seems, there is no winning.

Learning programming today is a fundamentally multilingual process. Start with Scratch or NXT-G; then move on to Python or Javascript, and then onward to other languages. Being multilingual is a tall order for both students and teachers. Perhaps that is why programming languages are not taught in grade school.

I have long dreamt of designing a new teaching language with the "no threshold" sensibility of LOGO, but modernized to have "no limits" in today's terms. My wishlist:

  • No install. Program in the browser.
  • Punctuation-light syntax like LOGO or Python or Ruby.
  • Turtle graphics, with animated turtles that are easy to follow.
  • Expressive enough for recursion, data structures, and concurrency.
  • The speed of a jitted runtime like V8 or SpiderMonkey or Chakra.
  • Rich libraries for media, visualization, and so on.
  • Connected to active programming communities in 2013.

The dream would be to make a language that serves kids from kindergarten to college. For the littlest ones, the language should serve as a game that teaches the concept of automation. In grade school, they would use it to learn arithmetic and geometry. In middle school, it would become a tool to introduce algebra, visualization, and graphing. And in high school and beyond, it would be used for simulation, multimedia productions, or building the next big kickstarter-funded app.

The Perfect Language Already Exists

What I imagined was something like Skulpt: python in the browser. But then I realized that something better already exists.

The ideal learning language was designed by Jeremy Ashkenas in 2009, and it has a very active and enthusiastic following in the Ruby community. It a language used by Dropbox and many hipster Silicon valley web hackers. It is a language that does not even aspire to be a first language. That ideal learning language is Coffeescript.

Let's take a brief look.

Coffeescript has an intuitive, punctuation-light syntax that looks like LOGO when you are a beginner.

# This is Coffeescript.
fd 100
rt 90
fd 100

Then it reads like ordinary algebra as you start building logic. The concepts for "if", "then", "else", "is", "and", "or", and "not" can all be spelled out instead of coded as cryptic punctuation:

factorial =
  (x) -> if x is 0 then 1 else x * factorial(x - 1)

Finally, Coffeescript looks like streamlined Ruby or Python for larger programs, with reasonable syntax for list comprehensions and array slicing, and with a very clean indent-block syntax for functions, control flow, classes, closures, and JSON.

choices = (menu, sofar = []) ->
  if menu.length is 0
    write sofar.join ' '
  else for item in menu[0]
    choices menu[1...], sofar.concat item
choices [
  ['small', 'medium', 'large']
  ['vanilla', 'chocolate']
  ['cone', 'cup']

Because Coffeescript translates directly into Javascript, it runs fast in the browser where it is easy to take advantage of HTML5 and v8, and where you have access to libraries that do everything from physics engines to 3d rendering to image analysis.

At the upper end, there are no limits: Coffeescript is a language used by pros. Even though it uses a syntax that looks like LOGO for beginners, it attracts old-timer programmers who have migrated over the years from C to Java to Python to Ruby to Javascript to Coffeescript. The design of the language is attractive to all levels of programmers.

Next time: Filling the Gaps

The main problem with the language is that Coffeescript is new, which means that, for beginners, Coffeescript still missing a a few things.

So let's fill those gaps!

More on that next time...

Posted by David at August 1, 2013 07:49 PM

It seems like CoffeeScript has much less material available aimed at beginners than, say, Python. Do you think that's a mark against it?

Also, what do you think about static vs. dynamic typing for beginners?

Posted by: Austin at August 5, 2013 02:33 PM

You are right: there is less material written about Coffeescript. I think this is just due to the fact that Coffeescript was only created in 2009 and Python has been around since 1989: 30 years longer.

The solution, I think, is that we just need to write some books about CoffeeScript.

On static vs dynamic typing: I think dynamic typing is much better for beginners - it means having fewer concepts to learn before writing a program.

Static types are nice for gigantic programs, but even for programs of pretty high complexity, you can get by perfectly well with dynamic types, as long as you test carefully.

Posted by: David at August 8, 2013 09:57 AM

I've been struggling with the same problem since I've decided that my kids will learn to code. I think the Roy language is quite cool, with the easy to write haskellish syntax and the ability to run and compile in the Browser. I even wrote a Logo-ish learning environment for it:

Posted by: Juha Paananen at August 12, 2013 03:03 PM

Thanks for the pointer to the Roy language - it looks very pretty! For my own reference, here is a list of other Haskell-inspired Javascript variants:

Do you think strong typing is important for a learning language? (I'm not convinced - e.g., I think Python is great for learning.)

To me, the key requirement is that there be be a community of programmers who are creating and discussing code on the web, so that students can broaden their horizons with a quick Google search. Perhaps in some years a typed language like Roy will emerge to replace Coffeescript (or Javascript).

Posted by: David at August 18, 2013 06:48 AM
Post a comment

Remember personal info?