Is Go a good reference to learn about compilers ?

569 views
Skip to first unread message

EduRam

unread,
Jan 17, 2014, 9:17:18 AM1/17/14
to golan...@googlegroups.com
Is Go a good reference to learn about compilers inner workings ?

Because this feeling of something new, I grew curiosity about it and 
I have been following the Golang development by just following the commit history !!!


I have to admit that I don't understand most of commits log messages, 
and code reviews discussions. After a while I had to buy a book about 
compilers. I am making the exercise of connecting chapters to source code. 
(I am still on parsing code).

Searching the web I have a perception LLVM infrastruture is the good starting 
point as an educational perspective ... but is not Go :(

Is there anyone with a few more compiler background that can give their 
input about this ?

Thanks,

Eduardo

egon

unread,
Jan 17, 2014, 9:27:31 AM1/17/14
to golan...@googlegroups.com
http://compilers.iecc.com/crenshaw/ is quite simple to start with. http://www.nand2tetris.org/ is quite interesting because it also goes through building a computer.


+ egon


Thanks,

Eduardo

Konstantin Khomoutov

unread,
Jan 17, 2014, 10:46:47 AM1/17/14
to EduRam, golan...@googlegroups.com
On Fri, 17 Jan 2014 06:17:18 -0800 (PST)
EduRam <eduardo...@gmail.com> wrote:

[...]
> Is there anyone with a few more compiler background that can give
> their input about this ?

Here's the classic book on the subject:
"Compilers: Principles, Techniques, and Tools" (Aho, Sethi, Ullman)
http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811/

Zellyn Hunter

unread,
Jan 17, 2014, 12:55:24 PM1/17/14
to golan...@googlegroups.com
I recently watched, and can recommend, the Coursera compilers course. I've started (very slowly) working towards building a go compiler for Cool (the teaching language used in the course). I'm currently building a lexer, a la http://cuddle.googlecode.com/hg/talk/lex.html

Zellyn

unread,
Jan 17, 2014, 1:40:05 PM1/17/14
to golan...@googlegroups.com
For what it's worth, a have a belief that in 16+ years from now some of compiler theory and practice will be based on a method of "stepping through one layer in a stack of multiple Turing-complete languages". The primary reason for this to happen is that a single programming language may then be used to quickly and consistently implement multiple other programming languages. A major problem is that such a compiler framework runs very slow and consumes huge amounts of memory.

Zellyn Hunter

unread,
Jan 17, 2014, 1:46:39 PM1/17/14
to ⚛, golang-nuts
I'm not sure I completely understood what you wrote, but I think some small elements of what you're referring to might be present in the nanopass compiler idea, as well as in PyPy's rpython, which has now been used to implement both python and ruby.

Zellyn


--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/9t5tBbVL9KQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

unread,
Jan 18, 2014, 9:11:14 AM1/18/14
to golan...@googlegroups.com, ⚛
PyPy is close to what I meant, but the performance of generated code is relatively low. Java7 has N-times higher performance than PyPy. For example, N equals to 5 in case of a benchmark I run today.

Roberto Waltman

unread,
Jan 18, 2014, 5:05:46 PM1/18/14
to golan...@googlegroups.com
On 1/17/2014 9:17 AM, EduRam wrote:
> Is Go a good reference to learn about compilers inner workings ?
...

The "classic" book mentioned elsethread, "Compilers: Principles,
Techniques, and Tools", is an excellent second read on the subject. (or
a 3rd, or a 4th)
For beginners I would suggest first a book/project that develops a full
compiler for a small language, before jumping into more theoretical stuff.
For example,
Pyster - "Compiler Design and Construction" (Pascal subset)
Hansen - "Brinch Hansen on Pascal Compilers" (Pascal subset)
Wirth - "Compiler Construction" (Oberon subset, early versions used Pascal)

The last one is available online:
http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf

--
Roberto Waltman

Elliott Stoneham

unread,
Jan 18, 2014, 5:45:51 PM1/18/14
to golan...@googlegroups.com
If you like both Go and LLVM, why not get both in the same package?

Have a look at llgo, a "LLVM-based compiler for Go" at https://github.com/axw/llgo

Elliott Stoneham

unread,
Feb 5, 2014, 1:25:16 AM2/5/14
to golan...@googlegroups.com
...or why not "Write your own Go compiler" (about llgo and 2 other projects)


On Friday, 17 January 2014 14:17:18 UTC, EduRam wrote:
Reply all
Reply to author
Forward
0 new messages