llgo is an innovative Go compiler built on LLVM, designed to enhance collaboration between Go, C, and Python. With rich integration possibilities including game development, AI, and more, llgo opens new horizons for developers by connecting familiar languages through a robust Application Binary Interface. Experience the future of cross-language development.
llgo is an advanced Go compiler built on LLVM, designed to seamlessly integrate Go with the C ecosystem, including Python. As a subproject of the Go+ project, llgo opens up new horizons for developers in various fields, such as game development, AI and data science, WebAssembly, and embedded systems.
Key Features
-
Enhanced Compatibility: llgo leverages Go's syntax (source code) and the Application Binary Interface (ABI) to offer compatibility with both C and Python, enabling versatile application development.
-
C/C++ Standard Library Support: Easily import and use C/C++ libraries in your Go code, including:
Example - C Integration
Here's how you can call a C function within your Go code:
package main
import "github.com/goplus/llgo/c"
func main() {
c.Printf(c.Str("Hello world\n"))
}
This code demonstrates using C's printf
function to print Hello world
. The c.Str
is a built-in llgo instruction that converts Go strings to C string constants.
Python Integration
llgo allows you to import Python libraries seamlessly through the llpyg
tool. Currently supported libraries include:
Here’s a sample demonstrating Python library usage in Go:
package main
import (
"github.com/goplus/llgo/py"
"github.com/goplus/llgo/py/math"
"github.com/goplus/llgo/py/std"
)
func main() {
x := math.Sqrt(py.Float(2)) // x = sqrt(2)
std.Print(py.Str("sqrt(2) ="), x) // Output: sqrt(2) = 1.414...
}
This integrates Python's math.sqrt
functionality with Go syntax, providing a powerful combination for developers.
Versatile Library Support
llgo supports various libraries from C and C++ ecosystems, expanding your development possibilities. You can explore libraries such as c/sqlite or cpp/llvm.
Complete Go Syntax Support
All standard Go syntax is supported except for cgo. This ensures developers can utilize familiar constructs without cumbersome workarounds. Some features include:
- Goroutines
- Deferred function calls
- Error handling
Efficient Garbage Collection
LLGo implements garbage collection using bdwgc (libgc), with an option to disable it by specifying the nogc
tag if desired.
As an open-source project, llgo stands at the intersection of Go and the C/Python ecosystems, offering developers an unprecedented level of flexibility and power in application development. Whether you're building cutting-edge AI solutions, games, or embedded systems, llgo enriches your development journey with limitless possibilities.