News for hackers. Stuff that matters.
Re:Writing a Compiler in Go by etatoby on Tuesday May 03, 2016 @08:37AM (#11619990)
I would like to mention that most, if not all, of the Go compiler and related utilities is written in Go itself, with high quality, open source code that can be found in the "go" package of the standard library:

https://golang.org/pkg/go/

I would recommend using that as a template for one's own compiler, because it's written in idiomatic Go (originally by the language creators) and is cleanly split across abstraction boundaries (packages "scanner", "parser", "ast", and so on.)

There's also a smaller, simpler parser in the "text/template/parse" package, that is used to parse the templating languages in "text/template" and "html/template". As an introduction to it, I recommend the talk "Lexical Scanning in Go" by Rob Pike:

https://www.youtube.com/watch?v=HxaD_trXwRE

Re:Writing a Compiler in Go by jerf on Tuesday May 03, 2016 @09:58AM (#11620672)
Actually, after a quick examination of the Go libraries, I'm not sure I can agree that it's "idiomatic Go". I still see many things that strike me as "artifacts of the C conversion" more than "the way someone would have written this from scratch".

The careful package split is something to be copied, though.

Re:Writing a Compiler in Go by iso-8859-1 on Tuesday May 03, 2016 @10:48AM (#11621140)
The conversion from C to Go was done in 2014, so it is surprising that it is not complete yet.

See "Go, From C to Go by Russ Cox" (with video) at https://github.com/gophercon/2014-talks

Re:Writing a Compiler in Go by f2f on Tuesday May 03, 2016 @11:44AM (#11621639)
it is complete, but it's a conversion, not a rewrite. i doubt anyone will spend the time to rewrite the compiler in idiomatic Go soon. bigger fish to fry :)
Re:Writing a Compiler in Go by stcredzero on Tuesday May 03, 2016 @02:01PM (#11622855)
Where is a good place to read "idiomatic Go?"
Re:Writing a Compiler in Go by jerf on Tuesday May 03, 2016 @02:26PM (#11623046)
Much of the rest of the standard library. The compiler portion is a special case.
Re:Writing a Compiler in Go by freyr on Tuesday May 03, 2016 @02:27PM (#11623049)
The standard library.
Re:Writing a Compiler in Go by coldtea on Tuesday May 03, 2016 @07:55PM (#11625184)
>I would like to mention that most, if not all, of the Go compiler and related utilities is written in Go itself, with high quality, open source code

High quality? Isn't the compiler since 1.5 auto-generated from C for the most part, and quite crap with regards to optimizations/readability?