Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go as a backend for my compiler?

I want to make a compiler for my own programming language. Popular backend choices seem to be C, Java, LLVM, JVM bytecode, .Net bytecode, gcc, assembly... Here, I am considering the possibility of Go as a backend.

Go is apparently a fast language, with garbage collection, and fast compile times. It is also portable and free (BSD-style licence). All those would make Go a good choice as a target of code generation, I think, maybe even better than the other options... So I am surprised I can't find anybody doing that already.

Would Go be a good choice for code generation? Can you point at existing projects doing so, or explain why there are none? Or even better, do you have experience with using the Go language as a backend? Are there any downside I am unaware of?

(I'm specifically interested in Go here. Don't just point at alternative backend options, there are questions answering that already.)

like image 519
Eldritch Conundrum Avatar asked Aug 18 '12 09:08

Eldritch Conundrum


People also ask

Should I use Go for my backend?

Go makes an ideal choice for backend web development, particularly for high-performing concurrent services on the server side. It can be used for building the server side of your mobile app too. For instance, the GUI part of an Android app can be written in Java while the app backend can use Golang.

What is a compiler backend?

Known as the back-end of the compiler, the synthesis phase generates the target program with the help of intermediate source code representation and symbol table. A compiler can have many phases and passes. Pass : A pass refers to the traversal of a compiler through the entire program.

Is Go backend or frontend?

Go, also called Golang, is an open source, statically typed, compiled, cross-platform, and lightning fast programming language first introduced by Google in 2009. Go is multi-purpose, it is a good language for backend development.

Why is Go good for servers?

Go brings the best of both worlds. Like lower-level languages like C/C++, Go has compiled language. That means performance is almost nearer to lower-level languages. It also uses garbage collection to allocation and removal of the object.


1 Answers

  • I'm not aware of any language project using Go as a back-end.
  • Go is not designed to be a compiler back-end and or an IR.
  • Go is low level enough (bit like C except for e.g. the GC) to IMO be usable as a back-end for some languages/class of languages with semantics similar/comparable/close to what Go offers.
  • Would love to know more about the language you're designing ;-)
like image 88
zzzz Avatar answered Oct 03 '22 17:10

zzzz