Ask HN: JavaScript with Begin End
Hi coding enthusiasts,
I run a small JavaScript coding site for code newbies: codeguppy.com
What I've noticed is that most beginners have a hard time to properly open and close the { ... } for functions, code blocks, etc.
I was playing with the idea of introducing a simpler "javascript" to codeguppy.com -- where basically the symbols { } are replaced with begin ... end.
A simple pre-processor will replace begin ... end with the proper { ... } before sending the code to execution to the JavaScript engine.
Looking forward to your feedback on this. Do you think this will make coding more approachable to beginners or will create confusion later on when they will have to remove the "training wheels"?
Please see below how a function will look like (converted from the Breakout project on the codeguppy site):
function createBricks() begin let noBricks = Math.floor((width - brickSpace) / ( brickWidth + brickSpace )); let arBricks = [];
for(let row = 0; row < 3; row++)
begin
for(let col = 0; col < noBricks; col++ )
begin
let x = col * ( brickWidth + brickSpace ) + brickSpace;
let y = row * (brickHeight + rowSpace) + rowSpace;
let brick = { x : x, y : y };
arBricks.push(brick);
end
end
return arBricks;
end
Thanks for the comments! I know that is a little bit verbose but so tempting seeing that sometime young coders have hard time with {}. I'm concerned though with "unlearning" this trick once they are ready to switch to regular JavaScript.
I think it's batter something like Rainbow Brackets, that use colors to mark each block and their delimiters. In the rare occasions I use a new editor, I waste a lot of time until the bracket highlighting is nice.
(Disclaimer: My main language is Racket.)
No, it shouldn't be that hard to understand braces means a block. Why would 'begin'/'end' be easier? Just teach that { = begin, and } = end.
Alternatively use a different language that is simpler but will translate back to JS, like coffeescript or something like that, maybe there's a python equivalent.
> Do you think this will make coding more approachable to beginners
Yes, a little
> will [it] create confusion later on when they will have to remove the "training wheels"?
Yes, a lot
Please NO! That would be like Pascal. At uni I wrote keyboard macros to type the begin and end for me.
This feels like coding via telegram STOP What's wrong with learning to use punctuation QUESTION MARK
You would do better to redesign regular expressions.