diff --git a/doc/go_faq.html b/doc/go_faq.html index a44a35be8f..76a4feb8ce 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -19,7 +19,7 @@ dependency analysis—and fast compilation.
"Ogle" would be a good name for a Go debugger. -
-The 6g (and 8g) compiler is named in the
+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).
-g stands for go.
+6 is the architecture letter for amd64 (or x86-64, if you prefer), while
+g stands for Go.
We considered doing that, but too many of the problems—lack of garbage collection, long dependency chains, nested include files, -lack of concurrency awareness—are caused by the C++ language itself. +lack of concurrency awareness—are rooted in the design of +the C and C++ languages themselves. We felt a viable solution required a more complete approach.
Go is an experiment. We hope adventurous users will give it a try and see -if it provides a viable alternative to the status quo. Not every programmer -will like it but we hope enough will find satisfaction in the approach it +if they enjoy it. Not every programmer +will but we hope enough will find satisfaction in the approach it offers to justify further development.
-There are two Go compilers, 6g and gccgo.
-6g uses a different calling convention and linker and can
+There are two Go compiler implementations, 6g and friends, generically called
+gc, 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. Gccgo is a
-gcc front-end that can, with care, be linked with gcc-compiled
+GCC front-end that can, with care, be linked with GCC-compiled
C or C++ programs. However, because Go is garbage-collected it will be
unwise to do so, at least naively.
-Work is underway to provide a 'foreign function interface' to allow safe -interoperation of languages in a running program. +There is a 'foreign function interface' to allow safe calling of C-written +libraries from Go code. We expect to use SWIG to extend this capability +to C++ libraries. There is no safe way to call Go code from C or C++ yet. -
-Protocol buffers are supported. The next release of the -protocol compiler project will include Go code generators -and a Go library for them. -It is still being tweaked but works well. +Protocol buffers are supported. We plan to have the next release of the +protocol buffer source code include Go code generators +and a Go library for them. The implementation uses data reflection +at run time so it is slow, but a new implementation is planned.
Every language contains novel features and omits someone's favorite @@ -127,8 +130,8 @@ clarity of design, or because it would make the fundamental system model too difficult.
-Before you get too worried about Go not having feature X, -please investigate the features that Go does have. You might find that +If it bothers you that Go is missing feature X, +please forgive us and investigate the features that Go does have. You might find that they compensate in interesting ways for the lack of X.
This and other language design questions are answered in -the separate language FAQ. +the separate language design FAQ.
-The lack of type hierarchy makes "objects" in Go feel much more +Also, the lack of type hierarchy makes “objects” in Go feel much more lightweight than in languages such as C++ and Java.
-We haven't fully defined it all yet, but some details are available in the +We haven't fully defined it all yet, but some details about atomicity are available in the Go Memory Model specification. +Also, some concurrency questions are answered in more detail in the +language design FAQ.
-One point that has come up: at least for now, maps do not guarantee atomic -update from multiple threads of execution. This is not the place for a -full discussion but in essence it was felt that shared maps are usually -part of some larger synchronized object and forcing synchronization in the -map implementation would be too costly considering how rarely it would -actually help. - -
-The sync
-package implements mutexes, but we hope Go programming style will
+Regarding mutexes, the sync
+package implements them, but we hope Go programming style will
encourage people to try higher-level techniques. In particular, consider
structuring your program so that only one goroutine at a time is ever
responsible for a particular piece of data.
@@ -199,48 +198,34 @@ How are libraries documented?
There is a program, godoc, written in Go, that extracts
package documentation from the source code. It can be used on the
command line or on the web. An instance is running at
-http://go/go.
-
+http://golang.org/pkg/.
+In fact, godoc implements the full site at
+http://golang.org/.
-Eventually, there will be a small number of rules that guide things
-like naming, layout, and file organization. We are thinking of
-enforcing layout rules using a pretty-printing program that
-implements the rules, rather than writing a compendium of do's and
-don'ts that allows interpretation.
+Eventually, there may be a small number of rules to guide things
+like naming, layout, and file organization.
+The document Effective Go
+contains some style advice.
+More directly, the program gofmt is a pretty-printer
+whose purpose is to enforce layout rules; it replaces the usual
+compendium of do's and don'ts that allows interpretation.
+All the Go code in the repository has been run through gofmt.
+The library sources are in go/src/pkg.
+If you want to make a significant change, please discuss on the mailing list before embarking.
-
go/src/pkg.
-
-Makefile by following existing examples.
-
-make and make test in the affected
- directories.
-
-cd go/src/lib;
- ./deps.bash to update the Make.deps file included in the Makefile.
- For a new component, update the Makefile and then run
- deps.bash.
-cd go/src; ./all.bash
-
-all.bash succeeds (output like
- "N known bugs; 0 unexpected bugs" is OK),
- submit a CL.
-+See the document +Contributing to the Go project +for more information about how to proceed.
isPrime gives the wrong answer for 2, 3, 5, and 7 (or for
2, 4, 8, and 16) than to report that isPrime gives the wrong
answer for 2 and therefore no more tests were run. The programmer who
-triggers the test failure may be someone editing the code months later
-or even someone editing a different package on which the code depends.
+triggers the test failure may not be familiar with the code that fails.
Time invested writing a good error message now pays off later when the
test breaks.
In testing, if the amount of extra code required to write good errors seems repetitive and overwhelming, it might work better as a -table-driven test instead. Unlike Java (jUnit's home language), +table-driven test instead. Go has excellent support for data structure literals.
We understand that this is a point of contention. There are many things in the Go language and libraries that differ from modern practices, simply -because we feel it's worth trying to do better. +because we feel it's sometimes worth trying a different approach.
-Gccgo has a C++ front-end with a recursive descent parser coupled to the
-standard gcc back end. 6g is written in C using yacc/bison for the parser.
+Gccgo has a C++ front-end with a recursive descent parser coupled to the
+standard GCC back end. 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.
-We considered writing 6g, the original Go compiler, in Go itself but
+We considered writing 6g, 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 rewriting 6g in Go, which might well happen. (Go would be a
+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 /pkg/go.)
-We also considered using LLVM for 6g but we felt it was too large and
+We also considered using LLVM for 6g but we felt it was too large and
slow to meet our performance goals.
Again due to bootstrapping issues, the runtime is mostly in C (with a
tiny bit of assembler) although Go is capable of implementing most of
-it now. Gccgo's runtime uses glibc; 6g uses a custom library,
-compiled with 6c (the Plan 9 C compiler) to keep the footprint under
-control. The version of 6c used supports segmented stacks for
-goroutines; work is underway to provide the same stack management in
-gccgo.
+it now. Gccgo's runtime uses glibc;
+Gc uses a custom library, to keep the footprint under
+control; it is
+compiled with a version of the Plan 9 C compiler that supports
+segmented stacks for goroutines.
+work is underway to provide the same stack management in
+gccgo.