hacker news Hacker News
  1. new
  2. show
  3. ask
  4. jobs

Ask HN: JavaScript with Begin End

2 points

by codeguppy

2 hours ago

4 comments

story

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

loading...