An Intro to Google’s New Programming Language – Blockly

Unlike Dart — a possible replacement for JavaScript — and Go — a low-level but modern language that’s very suitable for creating servers — Google Blockly is a Web-based graphical programming language that intentionally resembles a jigsaw.

You create programs by joining pieces together, and are restricted in the same way puzzle pieces are, by what fits where. This is an ingenious and easy to understand method of ensuring that the program is correct. It short cuts the process of having to learn correct syntax. If the pieces fit, the program works.

Blockly is something of an experiment in teaching people to program. Instead of having to learn the intricacies of a language like JavaScript, you can show Blockly to teenagers or even younger kids, and visually explain the concepts and engage their brains.

Visual Programming Languages have been around for some time. Wikipedia lists over 100 VPLs. The similarity between Blockly and MIT App Inventor are obvious.

What makes Blockly a little different is that it’s a code editor written in JavaScript, and is open sourced. That means non-Google developers can get involved and contribute back. Most importantly, Blockly programs can be exported as JavaScript, Dart, Python or XML source code. There’s no importing into Blockly at the moment, but I’m sure some clever coder will devise a tool to allow it.

Test Driving

The Maze demo page lets you try Blockly by creating a program that moves a pointer through a maze. Initially it just has a Move Forward piece, and you have to click the Commands or Logic buttons to view all the available commands. You then select a command and drag it into place. This problem can be solved in a variety of ways.

The shape of the pieces dictates what can and can’t be used. When you drag a piece inside another, the enclosing piece expands so they fit cozily together. If there is a + in the shape as in the “if then” piece, clicking the + let’s you configure it. Pieces that have a different colored word inside (like “forward” in “Move Forward”) provide extra options. For example, you click “Forward” to get a popup that lets you select either “Forward” or “Backward” movement.

It’s a delight to play with. As the IDE executes each part of your program, that part is highlighted. It’s not exactly debugging, but it lets you work out where things are going wrong.

I reckon the Maze demo would make an excellent programming interview question. It’s certainly something that would challenge a bright kid. As a way to get them involved, this is wonderful, and something that I’d have loved to have learned with with at an early age.

Related Links

2 Responses to “An Intro to Google’s New Programming Language – Blockly”

  1. “One of these things is not like the others, One of these things just doesn’t belong,
    Can you tell which thing is not like the others, By the time I finish my song?” Sesame Street

    I asked my wife, a non-programmer to watch the video. She said “The key word is play. More of the dumming down of education.”

    If the up-and-coming gen, and the MEllenials, are so tech-savvy, why do they need Blockly?

    “I reckon the Maze demo would make an excellent programming interview question. It’s certainly something that would challenge a bright kid.”

    I reckon a bright kid would be equally challenged by C, APL, Macro, or a bazillion other languages that required learning the syntax.

    • Programming languages are tools. You and I might have the odd screwdriver etc in the home, A professional might have thirty. It’s similar for programming languages (though not 30). Each language has strengths and weaknesses compared to others. Blockly’s is that it’s easy to learn.