TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: JavaScript with Begin End

2 点作者 codeguppy4 个月前
Hi coding enthusiasts,<p>I run a small JavaScript coding site for code newbies: codeguppy.com<p>What I&#x27;ve noticed is that most beginners have a hard time to properly open and close the { ... } for functions, code blocks, etc.<p>I was playing with the idea of introducing a simpler &quot;javascript&quot; to codeguppy.com -- where basically the symbols { } are replaced with begin ... end.<p>A simple pre-processor will replace begin ... end with the proper { ... } before sending the code to execution to the JavaScript engine.<p>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 &quot;training wheels&quot;?<p>Please see below how a function will look like (converted from the Breakout project on the codeguppy site):<p>function createBricks() begin let noBricks = Math.floor((width - brickSpace) &#x2F; ( brickWidth + brickSpace )); let arBricks = [];<p><pre><code> for(let row = 0; row &lt; 3; row++) begin for(let col = 0; col &lt; 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;</code></pre> end

7 条评论

proc04 个月前
No, it shouldn&#x27;t be that hard to understand braces means a block. Why would &#x27;begin&#x27;&#x2F;&#x27;end&#x27; be easier? Just teach that { = begin, and } = end.<p>Alternatively use a different language that is simpler but will translate back to JS, like coffeescript or something like that, maybe there&#x27;s a python equivalent.
gus_massa4 个月前
I think it&#x27;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.<p>(Disclaimer: My main language is Racket.)
codeguppy4 个月前
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&#x27;m concerned though with &quot;unlearning&quot; this trick once they are ready to switch to regular JavaScript.
bhaney4 个月前
&gt; Do you think this will make coding more approachable to beginners<p>Yes, a little<p>&gt; will [it] create confusion later on when they will have to remove the &quot;training wheels&quot;?<p>Yes, a lot
gibbitz4 个月前
This feels like coding via telegram STOP What&#x27;s wrong with learning to use punctuation QUESTION MARK
GianFabien4 个月前
Please NO! That would be like Pascal. At uni I wrote keyboard macros to type the begin and end for me.
beardyw4 个月前
You would do better to redesign regular expressions.