Hide

FAQ

What is Blockly?

Blockly is a visual editor that allows users to write programs by plugging blocks together. Developers can integrate the Blockly editor into their own web applications to create a great UI for novice users. A user might create a program like this:

Then Blockly would generate the corresponding code in JavaScript, Python, Dart, or some other language:

if (Count > 256) {
  Count = 0;
  alert("Game Over");
}

The application can then execute the code as desired. From the application developer's point of view, Blockly is basically a textarea into which the user types syntactically perfect code.

Can I use Blockly to teach programming to my child?

Blockly is a tool for application developers, it is not a tool for children. If you want to introduce programming to a child, you don't want to use Blockly -- you want to use an educational application that uses Blockly. There are many such applications listed on the examples page.

How does Blockly relate to Scratch, App Inventor, etc.?

Blockly was influenced by App Inventor, which in turn was influenced by Scratch, which in turn was influenced by StarLogo. As a result, children who are familiar with one have no difficulty moving to another.

However, Blockly was designed with developers as the primary audience. We wanted to create an editor than could be easily customized and integrated into any application. Instead of writing one educational application, we built the plumbing to allow hundreds of applications to be written. See more on the alternatives page.

Why are graphics better than text?

Novice programmers are fighting two battles at once: the fight to translate their ideas into logical statements, and the fight to keep the syntax legal. Blockly makes it completely impossible to make a syntax error. There are no unbalanced parentheses, no unescaped strings, no missing semicolons. Blockly allows novice programmers to concentrate on the logic.

Additionally, many non-programmers find a blank screen with a blinking cursor to be daunting. How does one start? Blockly allows these users to browse through the menu of blocks and start plugging things together.

Even seasoned programmers can benefit by starting a script with Blockly. If one is writing a quick script using an unfamiliar API (such as office suite automation) it can take a long time to learn that API. With Blockly one can plug the blocks together for a first draft, then switch to the generated code to keep going.

How does Blockly scale to large programs?

It doesn't, at least not yet. Blockly is currently designed for creating relatively small scripts. We have ideas for semantic zooming and other techniques that would allow Blockly to scale. But that is not our current focus. Please do not attempt to maintain the Linux kernel using Blockly.

Why not use a data-flow metaphor?

Data-flow is often a simpler way to represent certain common tasks. However we chose not to use it for two reasons. The first is that data-flow languages usually fail badly when attempting to solve tasks outside their domain. The second is that the generated code looks nothing like the visual data-flow representation, which serves as a barrier for the user graduating from the visual programming language to a text-based code editor. We feel strongly that users should not be locked in.

Isn't Blockly too low level?

If the user wants to do anything truly original, they must have access to basic math and logic operations. However, once the basics are taken care of, Blockly offers a rich (and constantly growing) set of higher-level blocks. Such as computing the standard deviation of a list, using a single block.

Additionally, most of the high-level features would reside in the domain-specific API blocks provided to Blockly by host applications. For example a game engine using Blockly could have a block that moves a sprite until it hits a wall.

Can Blockly import from code?

Blockly can export from blocks to JavaScript, Python, and Dart. However we have no plans to import from one of these languages to Blockly. The main issue is that modern programming languages are fearsomely complex, with closures, list comprehension, operator overloading, etc. Importing arbitrary code would have a high development cost compared with a limited real-world utility.

Can I run Blockly without an Internet connection?

Yes, Blockly is 100% client side. Just load the HTML and JavaScript files straight from disk.

Can I run Blockly without a web browser?

If you are developing a mobile app, or a desktop executable and wish to incorporate Blockly, the easiest approach is to load Blockly inside a web widget in your app. Microsoft calls it a WebBrowser, Android calls it a WebView, iOS calls it a UIWebView.

The Blockly team can't support these non-web installations, but we've heard from developers who have found embedding Blockly in this way to be straight-forward.

Is this a 20% project?

This get asked a lot. People assume that anything this much fun must be an unofficial side project. No, Blockly has been under full-time development at Google since 2011. Google is hiring!