From 519725bb3c075ee2462c929f5997cb068e18466a Mon Sep 17 00:00:00 2001
From: Ondřej Surý
-The 6g
(and 8g
and 5g
) compiler is named in the
-tradition of the Plan 9 C compilers, described in
-
-http://plan9.bell-labs.com/sys/doc/compiler.html
-(see the table in section 2).
-
-6
is the architecture letter for amd64 (or x86-64, if you prefer), while
-g
stands for Go.
-
@@ -201,8 +187,8 @@ document server running in a production configuration on Do Go programs link with C/C++ programs?
-There are two Go compiler implementations, 6g
and friends,
-generically called gc
, and gccgo
.
+There are two Go compiler implementations, gc
+(the 6g
program and friends) and gccgo
.
Gc
uses a different calling convention and linker and can
therefore only be linked with C programs using the same convention.
There is such a C compiler but no C++ compiler.
@@ -320,10 +306,9 @@ exceptional.
Go takes a different approach. For plain error handling, Go's multi-value returns make it easy to report an error without overloading the return value. -A -canonical error type, coupled -with Go's other features, makes error -handling pleasant but quite different from that in other languages. +A canonical error type, coupled +with Go's other features, makes error handling pleasant but quite different +from that in other languages.
@@ -336,7 +321,7 @@ when used well, can result in clean error-handling code.
-See the Defer, Panic, and Recover article for details. +See the Defer, Panic, and Recover article for details.
int
32 bits on 64 bit machines?
The sizes of int
and uint
are implementation-specific
but the same as each other on a given platform.
-The 64 bit Go compilers (both 6g and gccgo) use a 32 bit representation for
+The 64 bit Go compilers (both gc and gccgo) use a 32 bit representation for
int
. Code that relies on a particular
size of value should use an explicitly sized type, like int64
.
On the other hand, floating-point scalars and complex
@@ -1317,8 +1302,7 @@ table-driven, iterating over a list of inputs and outputs defined
in a data structure (Go has excellent support for data structure literals).
The work to write a good test and good error messages will then be amortized over many
test cases. The standard Go library is full of illustrative examples, such as in
-the formatting
-tests for the fmt
package.
+the formatting tests for the fmt
package.
Gc
is written in C using
yacc
/bison
for the parser.
Although it's a new program, it fits in the Plan 9 C compiler suite
(http://plan9.bell-labs.com/sys/doc/compiler.html)
-and uses a variant of the Plan 9 loader to generate ELF binaries.
+and uses a variant of the Plan 9 loader to generate ELF/Mach-O/PE binaries.
-We considered writing 6g
, the original Go compiler, in Go itself but
+We considered writing gc
, the original Go compiler, in Go itself but
elected not to do so because of the difficulties of bootstrapping and
especially of open source distribution—you'd need a Go compiler to
set up a Go environment. Gccgo
, which came later, makes it possible to
consider writing a compiler in Go, which might well happen. (Go would be a
fine language in which to implement a compiler; a native lexer and
-parser are already available in /pkg/go
.)
+parser are already available in the go
package.)
-We also considered using LLVM for 6g
but we felt it was too large and
+We also considered using LLVM for gc
but we felt it was too large and
slow to meet our performance goals.
-A trivial C "hello, world" program compiled and linked statically using gcc
-on Linux is around 750 kB. An equivalent Go program using fmt.Printf
-is around 1.3 MB, but
+A simple C "hello, world" program compiled and linked statically using gcc
+on Linux is around 750 kB,
+including an implementation of printf
.
+An equivalent Go program using fmt.Printf
+is around 1.2 MB, but
that includes more powerful run-time support.
chan
keep things clear.
See the article about -Go's Declaration Syntax +Go's Declaration Syntax for more details.
@@ -1588,7 +1574,7 @@ appear on a line by itself. Some have argued that the lexer should do lookahead to permit the brace to live on the next line. We disagree. Since Go code is meant to be formatted automatically by -gofmt
,
+gofmt
,
some style must be chosen. That style may differ from what
you've used in C or Java, but Go is a new language and
gofmt
's style is as good as any other. More
--
cgit v1.2.3