gpt4 book ai didi

go - Go 的修订历史背后的故事是什么?

转载 作者:IT老高 更新时间:2023-10-28 13:04:50 25 4
gpt4 key购买 nike

我注意到 Go 源代码的前 4 个修订版 f6182e5abf5eb66d0bf8da3eac3363d7e788172d32922e72 是早在 Golang 被提出之前,the oldest being from 1972 .他们也都归功于 AWK-ward 成名的 Brian Kernighan。它们似乎是 C 中的 hello, world 实现。这是复活节彩蛋还是有什么实际用途?

最佳答案

那个 thread提及:

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

所述线程引用this commit为起点,还指出到actual first commit Golang 项目的 first revision of the Go spec .

前四次提交的(据称)“作者”是 Brian Kernighan .
Rob Pike 1980 年代曾在 Bell Labs 与 Brian 合作过。 ,所以这可以看作是对他的职业出身的引用。

这个复活节彩蛋的想法是用 C 来说明 Hello World 程序的演变:

(通过最近的 GopherCon 2014 年 4 月演讲 hellogophers.slide - Rob Pike 了解更多信息)


你好,世界

hg log -r 0:4
changeset: 0:f6182e5abf5e
user: Brian Kernighan <bwk>
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 <bwk>
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 <research!bwk>
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 <stdio.h>

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

最后一刻修复:转换为 ANSI C

changeset:   3:172d32922e72
user: Brian Kernighan <bwk@research.att.com>
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 <stdio.h>

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

Go 规范起点

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

关于go - Go 的修订历史背后的故事是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21979690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com