5 ms·
Show HN: WIP C compiler in Go, inspired by 8cc
- acqq 12y agoAnd WIP just means "work in progress."
- andrewchambers 12y agoYeah, there is still a lot to do. I posted because sometimes showing others helps keep yourself motivated. I'd love to find collaborators too, though I don't expect anyone to help until less trivial programs are running.
- acqq 12y agoAt first I thought "WIP C" meant something related to the kind of C or of the C compiler, that's why I commented. If you can still change the title, writing "work-in-progress" instead of WIP would be much less confusing. And good luck in your efforts, you've set some really serious goals.
- andrewchambers 12y agoThanks, Its a marathon type of project, not a sprint.
- rikkus 12y agoThe code is very easy to read, so I think this would be great for those who want to learn how one might go about implementing a C compiler.
- andrewchambers 12y agoI personally struggled to work with other compilers, I think TCC is too terse, and GCC/Clang have too much code. https://github.com/rui314/8cc https://github.com/rui314/8cc Got things right, and I am trying continue with it's style. I will be happy if a student can take my compiler and port it to his own invented cpu with a modest amount of work.
- userbinator 12y agoTerseness is quite a subjective thing, as I think TCC is not all that small among all the C (and C-subset) compilers that exist like Small-C; on the other hand, OTCC is in realm of "too terse" for me. This one is more agreeable with my style (and I think the parser in it is amazingly concise and elegant): https://github.com/rswier/c4/blob/master/c4.c https://github.com/rswier/c4/blob/master/c4.c
- andrewchambers 12y agoTCC packs a C compiler, assembler and linker together, So it has a large amount of functionality, even if it is no longer so tiny. The code style is really dense too. Frequently using single letter function and variable names. e.g. Outputting data into the final data segments uses functions named o() and o32().
- bombless 12y agoAn amusing way to bootstrap Go... Cheers :)
- iso8859-1 12y agoHow does this compare to vbcc and pcc?
- andrewchambers 12y agoThis still as a long way to go before it could be compared to them in terms of completeness,
- deleted 12y ago[deleted]
- userbinator 12y agoThe reason why this isn't a Go compiler in Go is probably the same reason why it's a C compiler - the complexity of the language. C seems to be the sweet spot for a language that is relatively easy to write a basic compiler for, but also powerful enough to be used for writing nontrivial software (including compilers.)
- andrewchambers 12y agoIts not too bad to write a Go compiler in Go, simply because of this package https://godoc.org/golang.org/x/tools/go/ssa https://godoc.org/golang.org/x/tools/go/ssa by the Go team. I really hope someone writes a Go to C compiler in Go, as combined with my C compiler, they would create an entirely new and self hosting implementation of Go.