Go语言的修订历史背后有什么故事?

huangapple go评论70阅读模式
英文:

What's the story behind the revision history of Go?

问题

我注意到Go源代码的前4个修订版本f6182e5abf5eb66d0bf8da3eac3363d7e788172d32922e72都是在Golang提出之前很久的时候创建的,其中最早的版本可以追溯到1972年。它们都归功于AWK-ward的Brian Kernighan。它们似乎是用C语言实现的"hello, world"程序。这是一个彩蛋还是有一些实际用途呢?

英文:

I noticed that the first 4 revisions f6182e5abf5e, b66d0bf8da3e, ac3363d7e788, 172d32922e72 of the Go source are all from long before Golang was even proposed, the oldest being from 1972. They are also all credited to Brian Kernighan of AWK-ward fame. They seem to be hello, world implementations in C. Is this an easter-egg or is there some practical purpose?

答案1

得分: 21

那个帖子提到:

<!-- language-all: lang-c -->

> 致敬、复活节彩蛋、内部玩笑,随你喜欢 :). 注意相关提交的作者

该帖子引用了这个提交作为起点,但也指出了Golang项目的实际第一个提交,以及Go规范的第一个修订版

这四个最初提交的(所谓的)“作者”是Brian Kernighan
Rob Pike在1980年代与Brian一起在Bell Labs工作,因此可以将其视为对他职业起源的参考。

这个彩蛋的想法是用C语言来演示一个“Hello World”程序的演变:

(在这个最近的GopherCon 2014演讲中可以了解更多信息hellogophers.slide - Rob Pike


Hello, World

hg log -r 0:4
changeset:   0:f6182e5abf5e
user:        Brian Kernighan &lt;bwk&gt;
date:        Tue Jul 18 19:05:45 1972 -0500
summary:     hello, world

$ hg update -r 0
$ cat src/pkg/debug/macho/testdata/hello.b

main( ) {
    extrn a, b, c;
    putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';

转换为C语言

changeset:   1:b66d0bf8da3e
user:        Brian Kernighan &lt;bwk&gt;
date:        Sun Jan 20 01:02:03 1974 -0400
summary:     convert to C

$ hg update -r 1
$ cat src/pkg/debug/macho/testdata/hello.c

main() {
    printf("hello, world");
}

转换为草案-拟议的ANSI C

changeset:   2:ac3363d7e788
user:        Brian Kernighan &lt;research!bwk&gt;
date:        Fri Apr 01 02:02:04 1988 -0500
summary:     convert to Draft-Proposed ANSI C

$ hg update -r 2
$ cat src/pkg/debug/macho/testdata/hello.c

#include &lt;stdio.h&gt;

main()
{
    printf("hello, world\n");
}

最后一分钟修复:转换为ANSI C

changeset:   3:172d32922e72
user:        Brian Kernighan &lt;bwk@research.att.com&gt;
date:        Fri Apr 01 02:03:04 1988 -0500
summary:     last-minute fix: convert to ANSI C

$ hg update -r 3
cat src/pkg/debug/macho/testdata/hello.c


#include &lt;stdio.h&gt;

int
main(void)
{
    printf("hello, world\n");
    return 0;
}

Go规范起点

changeset:   4:4e9a5b095532
user:        Robert Griesemer &lt;gri@golang.org&gt;
date:        Sun Mar 02 20:47:34 2008 -0800
summary:     Go spec starting point.
英文:

That thread mentions:

<!-- language-all: lang-c -->

> Homage, Easter egg, inside joke, take your pick :). Notice the authors of the commits in question too

Said thread references this commit as the starting point, but also points out to the actual first commit of the Golang project, with the first revision of the Go spec.

The (alleged) "author" of the four first commits is Brian Kernighan.
Rob Pike has worked with Brian in the 1980's, at Bell Labs, so this can be viewed as a reference to his professional origin.

The idea of this Easter egg is to illustrate an evolution of an Hello World program in C:

(See more with this recent GopherCon April 2014 talk hellogophers.slide - Rob Pike)


Hello, World

hg log -r 0:4
changeset:   0:f6182e5abf5e
user:        Brian Kernighan &lt;bwk&gt;
date:        Tue Jul 18 19:05:45 1972 -0500
summary:     hello, world

$ hg update -r 0
$ cat src/pkg/debug/macho/testdata/hello.b

main( ) {
    extrn a, b, c;
    putchar(a); putchar(b); putchar(c); putchar(&#39;!*n&#39;);
}
a &#39;hell&#39;;
b &#39;o, w&#39;;
c &#39;orld&#39;;

Convert to C

changeset:   1:b66d0bf8da3e
user:        Brian Kernighan &lt;bwk&gt;
date:        Sun Jan 20 01:02:03 1974 -0400
summary:     convert to C

$ hg update -r 1
$ cat src/pkg/debug/macho/testdata/hello.c

main() {
    printf(&quot;hello, world&quot;);
}

Convert to Draft-Proposed ANSI C

changeset:   2:ac3363d7e788
user:        Brian Kernighan &lt;research!bwk&gt;
date:        Fri Apr 01 02:02:04 1988 -0500
summary:     convert to Draft-Proposed ANSI C

$ hg update -r 2
$ cat src/pkg/debug/macho/testdata/hello.c

#include &lt;stdio.h&gt;

main()
{
    printf(&quot;hello, world\n&quot;);
}

Last-minute fix: convert to ANSI C

changeset:   3:172d32922e72
user:        Brian Kernighan &lt;bwk@research.att.com&gt;
date:        Fri Apr 01 02:03:04 1988 -0500
summary:     last-minute fix: convert to ANSI C

$ hg update -r 3
cat src/pkg/debug/macho/testdata/hello.c


#include &lt;stdio.h&gt;

int
main(void)
{
    printf(&quot;hello, world\n&quot;);
    return 0;
}

Go spec starting point

changeset:   4:4e9a5b095532
user:        Robert Griesemer &lt;gri@golang.org&gt;
date:        Sun Mar 02 20:47:34 2008 -0800
summary:     Go spec starting point.

huangapple
  • 本文由 发表于 2014年2月24日 13:37:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/21979690.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定