英文:
Why does semicolons make Go complier faster
问题
我正在阅读Jon Bodner的《学习Go》一书,他说:
“分号插入规则是使Go编译器更简单、更快速的一项特性,同时也强制执行一种编码风格。这真是聪明的设计。”
英文:
I am reading the Learning Go by Jon Bodner and he says:
"The semicolon insertion rule is one of the things that makes the Go compiler simpler and faster, while at the same time enforcing a coding style. That’s clever."
答案1
得分: 0
根据Semicolons in Go中的内容:
信不信由你,这样做会减少规则。Robert在解析器和语言规范中进行了尝试,并对简化后的情况感到惊讶。我现在正在6g编译器中进行同样的转换,我正在删除的死代码是编译器中最丑陋的部分之一。我已经忘记了写它,但它真的很丑陋。很快它将会消失。
分号插入规则可以使解析器简单化。然而,编译器可以插入分号,但没有证据表明这会使编译器更快。
另一个观点来自Line Break Rules in Go:
对于分号插入规则,有赞扬也有批评。一些程序员不喜欢这些规则,因为他们认为这些规则限制了代码风格的自由。赞同者认为这些规则使代码编译更快,并使不同程序员编写的代码看起来相似,以便更容易理解彼此编写的代码。
英文:
Per the Semicolons in Go
> Believe it or not, this removes rules. Robert played with
this in the parser and the language spec and was surprised
how much simpler things got. I am doing the same conversion
in the 6g compiler right now, and the dead code I'm cutting
away is one of the ugliest parts of the compiler. I'd
forgotten writing it, but boy is it ugly. And soon it will
be gone.
The semicolon insertion rule could make the parser simple. However, the compilers could insert semicolons, and there is no evidence to make the compiler faster.
Another opinion from Line Break Rules in Go
> there are both praises and criticisms for the semicolon insertion rules. Some programmers don't like the rules, for they think the rules limit the freedom of code styles. Praisers think the rules make code compile faster, and make the code written by different programmers look similar, so that it is easy to understand the code written by each other.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论