Skip to content

Commit ec36056

Browse files
mohammed90mewmew
andauthored
Fix typos, syntax issues, and spacing
Co-Authored-By: Robin Eklind <[email protected]>
1 parent d38d14b commit ec36056

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

content/advent-2019/go-compilers.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title = "Tour of Go Compilers"
66
linktitle = "Tour of Go Compilers"
77
+++
88

9-
On a high level, compilers are viewed as a single a single, solid, single-step-worker entity. A Gopher, aka Go programmer, interacts with the Go compiler via the abstractions of `go build` or `go install` commands. However, compilers, in their ideal form, consist of three layers creatively named: frontend, middle-end, and backend. The single `go {build,install}` command embarks on journey through the three layers to convert the raw Go source code into machine code.
9+
On a high level, compilers are viewed as a single, solid, single-step-worker entity. A Gopher, aka Go programmer, interacts with the Go compiler via the abstractions of `go build` or `go install` commands. However, compilers, in their ideal form, consist of three layers creatively named: frontend, middle-end, and backend. The single `go {build,install}` command embarks on a journey through the three layers to convert the raw Go source code into machine code.
1010

1111
The frontend ingests the source code, perform lexical, syntactical, and semantical analyses to verify all the language level constraints are met and sensical. The frontend then generates what is known as intermediate representation (IR) to handout to the middle-end. The middle-end does not know the syntax of the language nor does it know the machine language. The middle-end is responsible for optimization via symbolic manipulation. The backend converts the IR into machine code suitable for the intended architecture.
1212

@@ -64,7 +64,7 @@ Further Reading:
6464

6565
- Iskander Sharipov in a [neat blogpost](https://quasilyte.dev/blog/post/go_ssa_rules/) goes through the SSA optimization rules used in the Go compiler.
6666

67-
- The $GOROOT/src/cmd/compile directory tree contains the [Introduction to the Go compiler](https://github.com/golang/go/blob/master/src/cmd/compile/README.md) and [Introduction to the Go compiler's SSA backend](https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/README.md) READMEs for those interested in the inner lives of the Go SSA-based compiler.
67+
- The `$GOROOT/src/cmd/compile` directory tree contains the [Introduction to the Go compiler](https://github.com/golang/go/blob/master/src/cmd/compile/README.md) and [Introduction to the Go compiler's SSA backend](https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/README.md) READMEs for those interested in the inner lives of the Go SSA-based compiler.
6868

6969
- [Go: Overview of the Compiler](https://medium.com/a-journey-with-go/go-overview-of-the-compiler-4e5a153ca889) by Vincent Blanchon.
7070

@@ -149,7 +149,7 @@ apt install git gcc ninja-build
149149
mkdir workarea
150150
cd workarea
151151

152-
// Sources
152+
# Sources
153153
git clone https://github.com/llvm/llvm-project.git
154154

155155
cd llvm-project/llvm/tools
@@ -175,10 +175,10 @@ CC=gcc CXX=g++ cmake \
175175
-G Ninja \
176176
../llvm-project/llvm
177177

178-
// Build all of gollvm
178+
# Build all of gollvm
179179
ninja gollvm
180180

181-
// Install gollvm to /usr/local
181+
# Install gollvm to /usr/local
182182
ninja install-gollvm
183183

184184
export LD_LIBRARY_PATH=/usr/local/lib64
@@ -201,21 +201,21 @@ As it stands, gccgo & gollvm have a few limitations and/or concerns:
201201

202202
### Gopherjs
203203

204-
Before the Go compiler (gc) learning how to target wasm [in Go 1.11](https://github.com/golang/go/wiki/WebAssembly), the only way to write Go code targeting JavaScript runtimes was via [gopherjs](https://github.com/gopherjs/gopherjs). The commandable effort results in a [list where the majority of stdlib package are supported](https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md). Not only are there [bindings](https://github.com/gopherjs/gopherjs/wiki/Bindings) for some of the most common JavaScript libraries and frameworks, there's [Vecty](https://github.com/gopherjs/vecty) for anyone who would like to write their app in Go end-to-end. If you would like to have a peek at something familiar and digestable, you can take a look at the [TodoMVC implementation with Gopherjs](https://github.com/gopherjs/todomvc).
204+
Before the Go compiler (gc) learning how to target wasm [in Go 1.11](https://github.com/golang/go/wiki/WebAssembly), the only way to write Go code targeting JavaScript runtimes was via [gopherjs](https://github.com/gopherjs/gopherjs). The commandable effort results in a [list where the majority of stdlib package are supported](https://github.com/gopherjs/gopherjs/blob/master/doc/packages.md). Not only are there [bindings](https://github.com/gopherjs/gopherjs/wiki/Bindings) for some of the most common JavaScript libraries and frameworks, there's [Vecty](https://github.com/gopherjs/vecty) for anyone who would like to write their app in Go end-to-end. If you would like to have a peek at something familiar and digestable, you can take a look at the [TodoMVC implementation with Gopherjs](https://github.com/gopherjs/todomvc).
205205

206206
### TinyGo
207207

208-
Go programmers who are also into programming microcontrolleres and are tired of C/C++ and assembly have the [TinyGo](https://tinygo.org/) project to the rescude. TinyGo is a Go compiler whose tagline is "Go compiler for small places." The compiler relies on LLVM to do the heavy lifting, and supports a decent amount of [the language features](https://tinygo.org/lang-support/) and [the standard library](https://tinygo.org/lang-support/stdlib/). Now you can use Go in your next Arduino Uno project.
208+
Go programmers who are also into programming microcontrolleres and are tired of C/C++ and assembly have the [TinyGo](https://tinygo.org/) project to the rescue. TinyGo is a Go compiler whose tagline is "Go compiler for small places." The compiler relies on LLVM to do the heavy lifting, and supports a decent amount of [the language features](https://tinygo.org/lang-support/) and [the standard library](https://tinygo.org/lang-support/stdlib/). Now you can use Go in your next Arduino Uno project.
209209

210210
### TARDIS Go
211211

212-
This is perhaps the most fun compiler. The [TARDIS Go](https://github.com/tardisgo/tardisgo) compiler generates the SSA form of the Go code, then uses the SSA to generate Haxe code conforming to the behavior of the Go code. Wait there's more. The Haxe toolchain can then be invoked to translate the Haxe code to C++, C#, Java, or JavaScript, thus allowing Go packages to be used on the respective platforms (.e.g. JVM).
212+
This is perhaps the most fun compiler. The [TARDIS Go](https://github.com/tardisgo/tardisgo) compiler generates the SSA form of the Go code, then uses the SSA to generate Haxe code conforming to the behavior of the Go code. Wait there's more. The Haxe toolchain can then be invoked to translate the Haxe code to C++, C#, Java, or JavaScript, thus allowing Go packages to be used on the respective platforms (e.g. JVM).
213213

214214
The [demo page](https://tardisgo.github.io/) of the project is still running the same JavaScript code generated from Haxe that's in turn generated from Go via TARDIS Go. Sadly, the project hasn't been updated since 2016, thus its implementation of the Go runtime is at Go 1.4. It would be nice to see the project resurrected and extended to add Go as Haxe target, thus enabling interoperability across all the supported languages and enriching the entire ecosystem.
215215

216216
## In Sum
217217

218-
This list is definitely not exhaustive nor should it. Different compilers serve different goals. New implmentations put both the spec and the implementations to the test, more tests means more eyeballs, and "given enough eyeballs, all bugs are shallow." Even compilers that aim at unconventional targets, namely TARDIS Go, managed to [find](https://github.com/golang/go/issues/12196) [three](https://github.com/golang/go/issues/7166) [bugs](https://github.com/golang/go/issues/10127) in Go toolchain.
218+
This list is definitely not exhaustive nor should it. Different compilers serve different goals. New implementations put both the spec and the implementations to the test, more tests means more eyeballs, and "given enough eyeballs, all bugs are shallow." Even compilers that aim at unconventional targets, namely TARDIS Go, managed to [find](https://github.com/golang/go/issues/12196) [three](https://github.com/golang/go/issues/7166) [bugs](https://github.com/golang/go/issues/10127) in Go toolchain.
219219

220220
Ian Lance Taylor himself has an answer to the question in his Quora response to the prompt [Why are there multiple compilers and interpreters for each programming language?](https://www.quora.com/Why-are-there-multiple-compilers-and-interpreters-for-each-programming-language-How-do-you-go-about-choosing-the-best-interpreter-or-compiler-for-your-project/answer/Ian-Lance-Taylor)
221221

0 commit comments

Comments
 (0)