summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2014-09-27 11:56:54 -0700
committerRob Pike <r@golang.org>2014-09-27 11:56:54 -0700
commitba02a044f3aac725d0c04f421348313fa3cb6590 (patch)
tree4d0bcea252138fb228e16d098bb81b92d30545fb /doc
parent778b1c77131fb5f7c58b4f22951bdc07eebed899 (diff)
downloadgo-ba02a044f3aac725d0c04f421348313fa3cb6590.tar.gz
doc/faq: update for 1.4
LGTM=iant R=golang-codereviews, bradfitz, iant CC=golang-codereviews https://codereview.appspot.com/150190043
Diffstat (limited to 'doc')
-rw-r--r--doc/go_faq.html53
1 files changed, 38 insertions, 15 deletions
diff --git a/doc/go_faq.html b/doc/go_faq.html
index 4e90d3907..5813e1d04 100644
--- a/doc/go_faq.html
+++ b/doc/go_faq.html
@@ -889,6 +889,11 @@ type is generic; if you care about how many bits an integer holds, Go
encourages you to be explicit.
</p>
+<p>
+A blog post, title <a href="http://blog.golang.org/constants">Constants</a>,
+explores this topic in more detail.
+</p>
+
<h3 id="builtin_maps">
Why are maps built in?</h3>
<p>
@@ -971,7 +976,7 @@ It is a handy reference for people doing code reviews for Go projects.
How do I submit patches to the Go libraries?</h3>
<p>
-The library sources are in <code>go/src</code>.
+The library sources are in the <code>src</code> directory of the repository.
If you want to make a significant change, please discuss on the mailing list before embarking.
</p>
@@ -1590,30 +1595,40 @@ and uses a variant of the Plan 9 loader to generate ELF/Mach-O/PE binaries.
</p>
<p>
-We considered writing <code>gc</code>, the original Go compiler, in Go itself but
+We considered using LLVM for <code>gc</code> but we felt it was too large and
+slow to meet our performance goals.
+</p>
+
+<p>
+We also considered writing <code>gc</code>, 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&mdash;you'd need a Go compiler to
set up a Go environment. <code>Gccgo</code>, 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 the <a href="/pkg/go/"><code>go</code></a> package
-and a type checker is in the works.)
+consider writing a compiler in Go.
+A plan to do that by machine translation of the existing compiler is under development.
+<a href="http://golang.org/s/go13compiler">A separate document</a>
+explains the reason for this approach.
</p>
<p>
-We also considered using LLVM for <code>gc</code> but we felt it was too large and
-slow to meet our performance goals.
+That plan aside,
+Go is a
+fine language in which to implement a self-hosting compiler: a native lexer and
+parser are already available in the <a href="/pkg/go/"><code>go</code></a> package
+and a separate type checking
+<a href="http://godoc.org/code.google.com/p/go.tools/go/types">package</a>
+has also been written.
</p>
<h3 id="How_is_the_run_time_support_implemented">
How is the run-time support implemented?</h3>
<p>
-Again due to bootstrapping issues, the run-time code is mostly in C (with a
-tiny bit of assembler) although Go is capable of implementing most of
-it now. <code>Gccgo</code>'s run-time support uses <code>glibc</code>.
-<code>Gc</code> uses a custom library to keep the footprint under
+Again due to bootstrapping issues, the run-time code was originally written mostly in C (with a
+tiny bit of assembler) although much of it has been translated to Go since then
+and one day all of it might be (except for the assembler bits).
+<code>Gccgo</code>'s run-time support uses <code>glibc</code>.
+<code>Gc</code> uses a custom C library to keep the footprint under
control; it is
compiled with a version of the Plan 9 C compiler that supports
resizable stacks for goroutines.
@@ -1637,8 +1652,8 @@ A simple C "hello, world" program compiled and linked statically using gcc
on Linux is around 750 kB,
including an implementation of <code>printf</code>.
An equivalent Go program using <code>fmt.Printf</code>
-is around 1.2 MB, but
-that includes more powerful run-time support.
+is around 1.9 MB, but
+that includes more powerful run-time support and type information.
</p>
<h3 id="unused_variables_and_imports">
@@ -1695,6 +1710,14 @@ func main() {
}
</pre>
+<p>
+Nowadays, most Go programmers use a tool,
+<a href="http://godoc.org/code.google.com/p/go.tools/cmd/goimports">goimports</a>,
+which automatically rewrites a Go source file to have the correct imports,
+eliminating the unused imports issue in practice.
+This program is easily connected to most editors to run automatically when a Go source file is written.
+</p>
+
<h2 id="Performance">Performance</h2>
<h3 id="Why_does_Go_perform_badly_on_benchmark_x">