News for hackers. Stuff that matters.
Re:Google Blockly - a visual programming language by ch on Thursday May 31, 2012 @10:08PM (#4051543)
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?
Re:Google Blockly - a visual programming language by NeilFraser on Friday June 01, 2012 @12:27AM (#4051969)
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 by ch on Friday June 01, 2012 @05:30AM (#4052649)
Still, the blocky code reads "count with i from 0 to (get n)", but the loop generated is accessing A[0-1]..A[n-1]. JavaScript is forgiving here, but A[0..n] is not the same as A[-1..(n-1)] (at least I'm not familiar enough with JavaScript to think otherwise).
Re:Google Blockly - a visual programming language by jmaygarden on Friday June 01, 2012 @06:22AM (#4052739)
If they are mapping index 1 to index 0, then it makes sense that 0 would map to -1 since it is one less than the first index. The bug is in the blockly sieve.

As an aside, Lua also uses 1-based indexing.

Re:Google Blockly - a visual programming language by ch on Friday June 01, 2012 @10:29AM (#4053537)
I understand why they are offsetting the index, it just makes things somewhat unintuitive. In most programming languages A[-1] is the same as A[len(A)-1] (assuming zero based indexing) ... so in Blocky is A[0] expected to mean the same thing as A[len(A)-1]? Nothing here is a show stopper, just a detail that could use a bit of tightening up.
Re:Google Blockly - a visual programming language by ianbishop on Friday June 01, 2012 @08:06AM (#4052962)
Yeah, I didn't realize it was 1-indexed until you guys pointed it out.

Unsurprisingly, it still works (it just loops a few too many times).