Live data from Hacker News

Google Blockly - a visual programming language

code.google.com

61–70 of 129 posts

Re: Google Blockly - a visual programming language

#61
i solved a problem featured on the yc company interviewstreet.com codesprint.

the problem: Count the number of one-bits from 0 to 2^n - 1, for n from 1 to 20.

my solution: http://i.imgur.com/hUxt0.png

when you run the solution:

     Number of one-bits in 1 bit numbers from 0 to 1 = 1
     Number of one-bits in 2 bit numbers from 0 to 3 = 4
     Number of one-bits in 3 bit numbers from 0 to 7 = 12
     Number of one-bits in 4 bit numbers from 0 to 15 = 32
     Number of one-bits in 5 bit numbers from 0 to 31 = 80
     Number of one-bits in 6 bit numbers from 0 to 63 = 192
     Number of one-bits in 7 bit numbers from 0 to 127 = 448
     ....
JS:

    var list;
    var x;
    var prev;
    var onebits;
    var doubleatprev;

    list = [];
    list[0] = 1;
    list[1] = 4;
    for (x = 2; x 
Took 15 minutes to code up and 45 minutes to debug the array indexing :) One of these days I'll be able to write the JS and get the Blockly instead of the other way around - that'd be super awesome!

Re: Google Blockly - a visual programming language

#62
Hey, you can create new maze puzzles for your fun from the JavaScript console (WebKit Inspector, Firebug,...)! First create a new function to paint the custom map by pasting this code into the console: https://gist.github.com/2848451

Next setup Maze.MAP matrix with value 1 for empty cell, 0 for path and 2/3 for start/finish positions.

Now run loadMazeMap() to load your new challenge ;)

Example: http://www.dodaj.rs/f/f/nM/4w3wop7u/custommaze.png

Re: Google Blockly - a visual programming language

#63

I made a prime sieve: http://i.imgur.com/Elk5A.png It was pretty fun. JS generated isn't so bad.. var n; var A; var i; var x; var j; n = 100; A = []; for (i = 0; i

You win the prize for most impressive Blockly program yet. Looking forward to what you will write once we get procedures landed. -- The Blockly Team.

Taking advantage of JavaScript-translation-specific behavior allows procedures to work right now: just use arguments[1], arguments[2], and so on.

Re: Google Blockly - a visual programming language

#65

I made a prime sieve: http://i.imgur.com/Elk5A.png It was pretty fun. JS generated isn't so bad.. var n; var A; var i; var x; var j; n = 100; A = []; for (i = 0; i

You win the prize for most impressive Blockly program yet. Looking forward to what you will write once we get procedures landed. -- The Blockly Team.

So that explains why I couldn't figure out how to call a procedure...

Re: Google Blockly - a visual programming language

#68
post #55

I made a prime sieve: http://i.imgur.com/Elk5A.png It was pretty fun. JS generated isn't so bad.. var n; var A; var i; var x; var j; n = 100; A = []; for (i = 0; i

Interesting that in the initialization loop it sets A[0 - 1] to true, yet in your blocky code it appears to be iterating from 0 to n. In fact it always seems to be offsetting by one in array access ... 1 based indexing maybe?

Correct, you should see the looks on non-programmers' faces when you tell them that the first element in a Java list is #0, the second is #1, etc. It's approximately the same look as you see on programmers' faces when you tell them that the first element in a Blockly list is #1, the second is #2, etc.

Re: Google Blockly - a visual programming language

#69
post #61

i solved a problem featured on the yc company interviewstreet.com codesprint. the problem: Count the number of one-bits from 0 to 2^n - 1, for n from 1 to 20. my solution: http://i.imgur.com/hUxt0.png when you run the solution: Number of one-bits in 1 bit numbers from 0 to 1 = 1 Number of one-bits in 2 bit numbers from 0 to 3 = 4 Number of one-bits in 3 bit numbers from 0 to 7 = 12 Number of one-bits in 4 bit numbers…

Took 15 minutes to code up and 45 minutes to debug the array indexing :) One of these days I'll be able to write the JS and get the Blockly instead of the other way around - that'd be super awesome!

Does Blockly support turning JavaScript into blocks? That could be useful for visualizing minified or unfamiliar source code.

Re: Google Blockly - a visual programming language

#70
Cool beans.

My suggestion based on no evidence what-so-ever is that I'd like to see something like this in a richer environment.

To give a bad example, VB. The original VB had forms (maybe it still does). You'd make a form. Double click the button and add code for "onclick" basically. I guess maybe that was inspired by Hypercard.

In any case it was really easy to see how to make a useful program because of the structure a form plus code snippets gave. If those code snippets were Blockly that might be better for learning.

A maybe better example is Unity3D. You add a 3d object, attach a Script and start editing code to move that object by supplying an Update() function or something along those lines. Maybe a Step() where you can define state change code snippets?

All I'm saying is a language like Blockly that removes the syntax errors, attached to a larger framework (games, graphics, or webapps), seems like it would make it far more approachable. You could actually make something useful or fun in a less steps.

Post reply on HN