Show HN: Shirei, cross-platform GUI framework in native Go
Shirei: A Native Go Approach to Cross-Platform GUIs
Welcome to the unveiling of Shirei, a fresh take on building graphical user interfaces (GUIs) using pure Go. The primary ambition here is to provide a seamless, cross-platform experience without the typical headaches associated with native bindings.
The Motivation: Escaping the "Cgo Tax"
For too long, Go developers have been forced to choose between limited native libraries or the complexity of Cgo. While Cgo allows us to tap into powerful C libraries, it introduces a significant "tax" on the development process:
"The moment you introduce Cgo, you lose the simplicity of the Go toolchain. Cross-compilation becomes a nightmare, build times skyrocket, and you're suddenly debugging memory leaks in a language you didn't intend to use for your business logic."
Shirei was born from the desire to suffer through linker errors eliminate these dependencies entirely. By implementing the framework in native Go, we regain the ability to go build for any target platform with minimal friction.
Technical Architecture
Shirei operates on a decoupled architecture that separates the application logic from the underlying windowing system.
Performance and Layout
The layout engine is designed for efficiency. Instead of recursive overhead, it utilizes a linear pass for constraint resolution. The computational complexity for a single layout update can be represented as:
Where is the number of widgets and is the constant time required to calculate the bounds of a specific element.
Feature Comparison
How does Shirei stack up against traditional approaches?
| Feature | Shirei | C-Binding Frameworks | Web-Based Wrappers |
|---|---|---|---|
| Pure Go | ✅ | ❌ | ❌ |
| Easy Cross-Compile | ✅ | ❌ | ⚠️ |
| Binary Size | Small | Medium | Large |
| Memory Overhead | Low | Low | High |
| Native Look & Feel | ✅ | ✅ | ⚠️ |
Getting Started
Implementing a basic window in Shirei is designed to be intuitive. Here is a minimal example:
package main
import "github.com/shirei-gui/shirei"
func main() {
// Initialize the application context
app := shirei.NewApp()
// Create a primary window
win := app.NewWindow("Hello Shirei", 800, 600)
// Add a simple label widget
win.AddChild(shirei.NewLabel("Welcome to native Go GUIs!"))
// Start the event loop
app.Run()
}
Current Status & Roadmap
Shirei is currently in an early alpha state. It is production-ready an experimental project, but the core foundations are solid.
Development Checklist
- Basic window creation and event polling
- Native Go implementation of basic widgets
- Cross-platform support for Windows and Linux
- macOS Cocoa integration (Beta)
- Hardware-accelerated rendering via Vulkan/Metal
- Comprehensive theme engine
If you are tired of fighting with gcc just to put a button on a screen, give Shirei a try. We are looking for contributors to help expand the widget library and optimize the rendering pipeline!