TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Gotk3: GTK3 the Go way

111 pointsby djpressplayalmost 12 years ago

12 comments

georgemcbayalmost 12 years ago
Glad to see some more work being done on UI frameworks in Go, though I doubt this will end the splintered nature of all the different (mostly half-baked, honestly) options.<p>I&#x27;ve personally been using a Qt5.1&#x2F;QML based solution with a Go&#x2F;CGO based QML plugin that acts as a bridge between QML and backend Go code. It doesn&#x27;t try to export much of Qt to Go, it basically expects you to write the UI logic in QML&#x2F;QtQuick and then just use Go for the underlying app logic, using the QML plugin bridge to allow Go code to call QML functions and vice-versa. In practice this works somewhat like writing a Go server that manages an HTML UI for doing browser-based UIs with a web-based RPC system, except I can write the UI code in QML which I find much preferable to HTML&#x2F;JavaScript (variable binding Just Works, no need for frameworks like Angular, no need to mess with CSS, can efficiently pass around binary data in byte arrays easily, etc).<p>Currently my solution isn&#x27;t even half-baked, I&#x27;ve been implementing it to serve a specific app, and it currently has some dependencies that force it to be Windows only (these could be trivially removed, but doing so isn&#x27;t important for my app). I may share the code for this sometime in the future after it has matured a bit more, though there&#x27;s really not that much to it.
评论 #6056447 未加载
评论 #6056770 未加载
评论 #6056169 未加载
quackeralmost 12 years ago
Slightly off topic, but something I&#x27;ve been curious about. Go decided on garbage collection to manage memory. Why do so few languages offer something like C++&#x27;s RAII?[1]<p>In C++, when you define a class, you define the constructor(s) and the destructor. Then the destructor is called whenever the object goes out of scope. Easy. This is the gist of RAII. Furthermore, in C++, a default destructor is automatically generated for you, which will ensure all the objects members are destructed with your object,[2] so you can avoid even worrying about the destructor.<p>Yeah, it&#x27;s not as simple as GC, but it seems like a great compromise between manual memory management and garbage collection.<p>[1]: <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Resource_Acquisition_Is_Initial...</a><p>[2]: Provided no members are dynamically allocated. If you allocate an array in your constructor, for example, you need to free it in the destructor. You need to define a destructor to free dynamically-allocated memory, or to do other cleanup.
评论 #6054794 未加载
评论 #6054818 未加载
评论 #6054802 未加载
yebyenalmost 12 years ago
I am on ubuntu raring with the packaged golang and I can&#x27;t compile your example code, copied directly out of <i>Sample Use</i>.<p><pre><code> kbarrett@vernon-linux:~&#x2F;go-work&#x2F;gotk$ go version go version go1.0.2 kbarrett@vernon-linux:~&#x2F;go-work&#x2F;gotk$ go build # github.com&#x2F;conformal&#x2F;gotk3&#x2F;glib glib.go:380[&#x2F;tmp&#x2F;go-build210667265&#x2F;github.com&#x2F;conformal&#x2F;gotk3&#x2F;glib&#x2F;_obj&#x2F;glib.cgo1.go:370]: function ends without a return statement glib.go:743[&#x2F;tmp&#x2F;go-build210667265&#x2F;github.com&#x2F;conformal&#x2F;gotk3&#x2F;glib&#x2F;_obj&#x2F;glib.cgo1.go:741]: function ends without a return statement </code></pre> function ends without a return statement. If this is a problem with my version of go, I will try and fetch the latest head from git. I am interested!<p>sudo go get github.com&#x2F;conformal&#x2F;gotk3&#x2F;gtk -- gives the same error.
评论 #6054552 未加载
评论 #6054360 未加载
acomjeanalmost 12 years ago
I was kinda meh on Go (reminded me of my days in the Ada code), but making native GTK Apps seem really interesting to me. Will have to check this out.
评论 #6054724 未加载
评论 #6055783 未加载
joeshawalmost 12 years ago
No mention of goroutines or concurrency in the post. Is it addressed by the project at all? I can&#x27;t imagine that the GTK main loop will deal well with being cooperatively scheduled -- the UI would block any time another goroutine ran on the same OS thread.<p>Ideally the GTK main loop would run in its own OS thread, and there would need to be a way to ensure that no GTK calls happen in other goroutines. Other (threaded) environments tend to handle this by deferring via a one-off &quot;idle&quot; function that is scheduled and run by the GTK main loop for things like that.
评论 #6058890 未加载
pionaralmost 12 years ago
Does anyone else think we need a new open-source widget toolkit? Qt, GTK, and what else is there? Those guys are old. I&#x27;ve done both, and WPF, and WPF is just so much better. I wish there was an open-source toolkit that didn&#x27;t just suck.
评论 #6056250 未加载
评论 #6056243 未加载
sesteelalmost 12 years ago
How is this different than this? <a href="https://github.com/norisatir/go-gtk3" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;norisatir&#x2F;go-gtk3</a><p>They also set finalizers.
评论 #6055310 未加载
prodigal_erikalmost 12 years ago
Are channels and CSP failing as the favored design approach? I keep seeing frameworks that just seem to use Go as if it were C with closures.
评论 #6055361 未加载
评论 #6055287 未加载
评论 #6055366 未加载
评论 #6055768 未加载
评论 #6055290 未加载
bratschealmost 12 years ago
Nice! Have this queued up to look at after work. :)
jlgrecoalmost 12 years ago
Hmm, does the name &quot;GTK&quot; mean &quot;Gnu Tk&quot;? I thought this was &quot;Go Tk&quot; for a moment when I read the title.
评论 #6054704 未加载
评论 #6055225 未加载
评论 #6055210 未加载
dysocoalmost 12 years ago
I was thinking of writing a small aplication, originally I was going to use Python... but might as well try this. Thanks.
gopheringalmost 12 years ago
Just tested on win7 and everything works great! Really nice work.