Live data from Hacker News

Google Blockly - a visual programming language

code.google.com

81–90 of 129 posts

Re: Google Blockly - a visual programming language

#81
post #18
post #4

Can this program be made any shorter? http://www.dodaj.rs/f/1K/vW/2gLz63rl/blockly.png

takes awhile... hard to tell whats "shorter" while !wall(AHEAD): move forward turn left while wall(AHEAD): turn right

If you started off facing a wall your code would just not do anything. You can both simplify it and fix this bug by reorganizing the loop.

    while true:
        turn left
        while wall(AHEAD):
            turn right
        move forward
However, while this algorithm happens to work on this maze, it will not work against other mazes (if you care).

Imagine a 5x5 square race track, with spokes coming from the outside of the wheel to the center, where there was a flag. Your algorithm (and my modified one) would just spin clockwise around the track without ever realizing it should take a right towards the center.

Re: Google Blockly - a visual programming language

#82
post #75

I noticed something interesting and disturbing after reading some of the answers: people are more concerned with the length of the code rather than the optimal solution (no extra turns / backtracking). This reminds me of interviewing at MS about 12 years ago and all they cared about was the ability to write recursive code. IMO, yes, elegant code is fantastic, but don't lose track of why we write code in the first pla…

So, I'm more disturbed that most of the answers people are posting aren't general solutions: they happen to solve this maze, but don't handle corner-cases (hah! I guess that's a pun ;P) of other mazes. You may as well just hardcode the answer to this one.

I actually found a similar bug in yours: you will get trapped in a square and be unable to exit, as you will constantly keep hugging the column along the left, without ever deciding to finally exit off to the right. S=Start, G=Goal, O=Empty

    S-O-O
      | |
      O-O-G

Re: Google Blockly - a visual programming language

#83
post #43

https://imgur.com/VBsht while (true) do if not (wall to the left) then (turn left) while (wall ahead) do (turn right) (move forward) This uses the general maze-solving logic of following the outer wall in one direction until you find the exit. It never turns then turns back or runs into a wall.

This will not solve general mazes. S=Start, G=Goal, O=Empty

    O-O-O
    |   |
    O S-O-G
    |   |
    O-O-O

Re: Google Blockly - a visual programming language

#84
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…

Take some of that time to figure out the math and the code becomes trivial:

  for (n = 1; n 
A short explanation: http://mathbin.net/98435

Re: Google Blockly - a visual programming language

#86
post #51

Earlier quoted context omitted.

have you tried BYOB [1]? It's "an advanced offshoot of Scratch" [1] http://byob.berkeley.edu/

That website is glorious :). Yeah, I think this might go a bit far. Scratch's community sadly isn't so big, further fragmentation won't help that much I think. And the platform doesn't make a very solid impression to me. That's why I like google's idea, I hope they pour some money into this.

> Scratch's community sadly isn't so big

This might change your idea: http://day.scratch.mit.edu/

Re: Google Blockly - a visual programming language

#87

The UI for this reminds me a lot of Scratch from MIT.

You should've seen the enthusiasm of children during the International Scratch Day: http://day.scratch.mit.edu/ (Well, at least the ones I taught introductory programming using Scratch https://fatherinastrangeland.wordpress.com/2012/05/27/how-ca... )

Re: Google Blockly - a visual programming language

#88

Reminds me of Sprog - http://sprog.sourceforge.net/ Back in the day I was looking at Sprog for some client-facing project so probably worth looking back at it again. Here's a nice example of Data Munging with Sprog - http://www.perl.com/pub/2005/06/23/sprog.html

Big thumbs up for Sprog. Also, MIT Scratch, and Yahoo! Pipes.

Re: Google Blockly - a visual programming language

#89
post #39

I need "comment" block.

Right-click any block, add comment.

Interestingly, that causes an "Aw, snap!" in Chrome (beta channel) for me. (Fresh load of the maze demo; right-click on the only block on the screen, click "add comment".)

Re: Google Blockly - a visual programming language

#90

Earlier quoted context omitted.

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...

Same here, I was already going crazy hehe
Post reply on HN