News for hackers. Stuff that matters.

Show HN: Spot – Simple, cross-platform, reactive desktop GUI toolkit for Go

https://github.com/roblillack/spot

Hi HN, I’m excited to share Spot, a simple, cross-platform, React-like GUI library for Go. It is just a few days old and has lots of missing features but I'm happy with the results so far, and looking for some design feedback.

Spot is designed to be easy to use and provide a consistent API across different platforms (mainly Mac & Linux). It’s inspired by React, but written in Go, aiming to combine the best of both worlds: the easy tooling & performance of Go with a modern, reactive approach to UI development.

Key features:

- Cross-platform: Leveraging FLTK[1] & Cocoa[2], Spot works on Mac, Linux, and the BSDs with plans for native Windows support in the future.

- Reactive UI: Adopts a React-like model for building UIs, making it intuitive for those familiar with reactive frameworks.

- Traditional, native widget set: Utilizes native widgets where available to provide a more traditional look and feel.

Why I built it:

I was searching for a cross-platform GUI toolkit for Go that had a more traditional appearance, and none of the existing options quite met my needs. I then started playing with Gocoa and go-fltk and suddenly I worked on an experiment to see how challenging it would be to build something like React in Go, and it kinda evolved into Spot. ¯\_(ツ)_/¯

In 2024, is there a still place for classic desktop GUIs—even with a modern spin?

I’d love to hear your thoughts, feedback, and any suggestions for improvement. Also, contributions are very welcome.

Thank you for checking it out!

[1] https://github.com/pwiecz/go-fltk

[2] https://github.com/roblillack/gocoa

( 59 comments | 38 points | on HN )
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by scosman on Friday May 24, 2024 @04:28PM (#40470222)
Cool!

What does building for cross platform look like? Would love if there was a command that produced my MacOs .app and Windows exe without me having to dive into package management/containers/signing headaches per platform.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Friday May 24, 2024 @04:48PM (#40470365)
The backends (FLTK/Gocoa) are using CGo, which currently does not support cross-compiling as far as I know.

So you still need to have a build pipeline with multiple operating systems, signing/notarization tools, etc. :(

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by mappu on Friday May 24, 2024 @07:09PM (#40471283)
You can cross-compile Cgo, you "just" need a C compiler and linker that works for the target platform. osxcross, xgo have some or maybe you can set CC=zig cc.

For macOS you need signing/notarization tools either when building natively or when cross-compiling, it's not any different. `rcodesign` has made this process much easier in recent years.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by apitman on Friday May 24, 2024 @07:45PM (#40471472)
+1 for `CC=zig cc`. Feels like magic
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by scosman on Friday May 24, 2024 @05:29PM (#40470638)
Too bad.

I swear half the electron apps use it for ease of Xplatform build.

I’d love something like this for giving my CLIs UIs.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by felipefar on Saturday May 25, 2024 @12:10AM (#40472594)
That'd be amazing not only for go apps but for software built on other languages as well. I'd pay for a good, straightforward build packing + crash reporting + autoupdater solution for my apps.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by allanrbo on Friday May 24, 2024 @04:31PM (#40470257)
Was looking for something like this some years back. Though I wanted Windows support too. Ended up switching to C++ to use wxWidgets, giving me small self contained binaries.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by mappu on Friday May 24, 2024 @07:13PM (#40471311)
go-fltk does build and run on Windows, pretty well actually.

For a native toolkit, I was impressed to see FLTK supports Ctrl-+ and Ctrl+- to zoom the entire application like a browser. And https://github.com/fltk-rs/fltk-theme?tab=readme-ov-file#wid... really improved my impression of how "native" FLTK can be made to look.

On a related note, I discovered GoVCL https://z-kit.cc/en/ recently and am interested to try it out.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Friday May 24, 2024 @04:57PM (#40470433)
Big fan of WxWindows, I'm just too invested into Go these days. :)

Self-contained Spot "Hello World" is 2.3MiB on my Mac. Not pretty, but works for me.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by ofrzeta on Saturday May 25, 2024 @02:43AM (#40473096)
So you didn't like to continue on that? https://github.com/dontpanic92/wxGo
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Saturday May 25, 2024 @03:31AM (#40473286)
Geez, look at the build instructions! It all went downhill when they switched from Motif to GTK.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by zerr on Saturday May 25, 2024 @03:43AM (#40473335)
There is wxGo, but sadly the project is not maintained.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by ygnasygnoimqwb on Friday May 24, 2024 @04:24PM (#40470190)
> runtime.LockOSThread()

> https://github.com/roblillack/spot/blob/main/ui/init_fltk.go...

Does this imply GOMAXPROCS needs to be set to at least 2?

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Friday May 24, 2024 @04:51PM (#40470393)
No, it just means that the main goroutine should not be moved onto another OS thread to ensure that it is always the same OS thread which will run UI updates.

This is necessary for most UI libraries and in Spot's case implemented for both the FLTK and the Cocoa backend.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by ASalazarMX on Friday May 24, 2024 @02:51PM (#40469307)
I don't know how to take this in. On one side, it's great to have a cross-platform GUI toolkit that's easy to use; on the other side, it feels like a React-like UI is contrary to the spirit of simplicity and resource efficiency of Go.

I'm sure it has its perfect use cases, though.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Friday May 24, 2024 @04:06PM (#40470027)
While I agree, that the virtual widget tree has a certain overhead, the typical desktop app you would create with Spot probably does not have 1000s of components—more like ten to twenty probably. Compare that to the immediate mode GUIs that currently are en vogue, that re-render all controls all the time.

Spot does not have any optimizations regarding render performance at the moment and it might never be necessary to add them.

On the other hand, due to the reactive programming model, I really like how state management get a lot clearer—especially when working with multiple goroutines.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by jakjak123 on Friday May 24, 2024 @06:35PM (#40471100)
Very cool idea!

If someone implements GTK I would absolutely use it, its just fltk is no fun in Linux world

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by Heliodex on Friday May 24, 2024 @07:58PM (#40471540)
If only I had known about this ~3 weeks ago. I've been saying for ages that either React ported to Go or a React-like framework for Go would be an incredible development experience, so this looks perfect (I used to be a big hater of React.js until I was enlightened by React.lua).
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by apitman on Friday May 24, 2024 @08:14PM (#40471612)
Don't leave us hanging! What did you use instead 3 weeks ago?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by Heliodex on Friday May 24, 2024 @08:34PM (#40471719)
Wails <https://wails.io>. I wanted to use Go but wasn't as familiar with native UI as with HTML/CSS/JS, I tried out most of the other popular Go UI frameworks too though they didn't feel as comfortable to use as Spot's React-like model.

Wails is still pretty epic as well though.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by parlortricks on Friday May 24, 2024 @10:12PM (#40472137)
oh this looks great
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by rkwz on Friday May 24, 2024 @10:25PM (#40472183)
I had the same problem - really liked the way I used to do component composition in React, it was hard to go back.

Eventually found a way to do something similar using just the standard Go html/template.

I’ve written about the implementation here:

https://www.sheshbabu.com/posts/react-like-composition-using...

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by biomcgary on Saturday May 25, 2024 @01:12PM (#40476353)
This a great write-up and similar to an approach that I stumbled upon a few years ago. Have you thought about HTMXing this approach to get away from full page renders?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by shesh on Sunday May 26, 2024 @07:22AM (#40481306)
Thanks! I wanted to use standard Go html/template to see just how bad the re-renders are, and then decide to use htmx. After building the project, I don’t mind the re-renders much as the latency is around 50ms and I don’t see any jank. I might introduce gems in future
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by rkwz on Sunday May 26, 2024 @08:58AM (#40481815)
Thanks! I wanted to use standard Go html/template to see just how bad the re-renders are, and then decide to use htmx. After building the project, I don’t mind the re-renders much as the latency is around 50ms and I don’t see any jank. I might introduce htmx in future
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by heywire on Friday May 24, 2024 @08:18PM (#40471637)
I’ll have to give this a look! I’ve been looking for a simple way to use Go to write an internal development tool which is basically just a form with some buttons and text fields. I tried Gio, but had a hard time with wrapping my head around it. Right now I’m using wails and like it much better. This looks interesting and worth a look!
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Saturday May 25, 2024 @01:14AM (#40472817)
Perfect use-case, IMHO! Looking forward to hear your thoughts ocne you tried it.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by getcrunk on Friday May 24, 2024 @11:53PM (#40472535)
Fltk supports windows. Will you be using another solution and that’s why u don’t support windows yet?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Saturday May 25, 2024 @12:58AM (#40472764)
Given the right C compiler and everything, Spot should work without changes on Windows (and select the FLTK) backend.

My (low prio, though) goal is to implement a Win32-based backend, though, the first step is done: https://github.com/roblillack/spot/pull/4

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by KingOfCoders on Friday May 24, 2024 @11:57PM (#40472548)
I applaud your effort, but cross plattform with no Windows support?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by jppittma on Saturday May 25, 2024 @12:02AM (#40472562)
Here’s a nickel kid. Get yourself a better computer.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by KingOfCoders on Saturday May 25, 2024 @12:03AM (#40472570)
Thanks, I'd wish I could get my G4 Cube back.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by poisonborz on Saturday May 25, 2024 @01:30PM (#40476474)
Why is platform shaming tolerated around here
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by IshKebab on Saturday May 25, 2024 @03:50PM (#40477382)
Oh you mean one that can sleep reliably and has battery life of more than 2 hours?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by KingOfCoders on Saturday May 25, 2024 @11:40PM (#40479628)
My desktop has no battery.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by IshKebab on Sunday May 26, 2024 @08:50AM (#40481769)
Good for you. My laptop does.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by KingOfCoders on Sunday May 26, 2024 @09:23AM (#40481976)
Yes, if you need a laptop for work and can't live without one, there is no other way but to live with the downsides of high costs, small screen and a battery.

Lucky me I no longer have to use a laptop for work and have a desktop without all the downsides.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by jppittma on Saturday June 01, 2024 @03:25PM (#40548396)
My macbook sleeps fine, with a battery life of roughly 18 hours.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by atlas_hugged on Saturday May 25, 2024 @05:23AM (#40473801)
Use WSL
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by RobotToaster on Saturday May 25, 2024 @06:48AM (#40474136)
It looks like it just uses FLTK on windows, they just don't have native support on it.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by felipefar on Saturday May 25, 2024 @12:18AM (#40472625)
I'm curious to hear your take on this: what's the advantage of following the virtual control tree approach compared to instead updating directly the controls that are displayed to the user?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Saturday May 25, 2024 @01:11AM (#40472801)
For complex scenarios (i.e. the user interacting with the UI while there are some long-running processes in the backround doing this, too), managing the state quickly gets unwiedly: You need to write callback code everywhere that carefully has to inspect the current status of all other activities and might then updates 10s of widgets accordingly.

With the reactive approach you are able to write a single rendering function that describes the interface for any given state and the framework takes care of the rest (when to call that function, what "input" to give it).

It's just way easier to wrap my head around this and after working with React it is hard to go back. Hence the experiment to see if something comparable could be done in Go.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by felipefar on Saturday May 25, 2024 @01:32AM (#40472841)
I'm already convinced of the benefit of declarative GUIs over imperative ones. To be clearer, what I mean by declarative GUIs is ones where I can specify that UI elements should be bound to certain values in the memory of my program, so that they don't have to be changed explicitly by imperative code. Ex.:

TextBox { Text: app.currentUser.name }

Instead of having to call setText on that TextBox.

What I'm still missing is why it has to involve a virtual tree being maintained and synchronized with the real GUI tree. The UI engine could implement the above binding by instantiating for the user a callback trigerred when the bound property changes and changing precisely the value currently shown on the screen. Hence, the UI engine is in charge of the callbacks, which keeps the user unburdened by callbacks.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by iainmerrick on Saturday May 25, 2024 @04:18AM (#40473482)
SolidJS works pretty much as you describe, and it’s great. It feels like the best bits of React, but object lifetimes and re-rendering and the real UI behavior are all much easier to understand.

(Or at least, to paraphrase Joseph Heller, “it’s intuitive once you get your head around it”)

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by da_rob on Saturday May 25, 2024 @02:35AM (#40473058)
The virtual component tree is needed as there is no 1:1 mapping of components to widgets.

Using the virtual tree, you are able to build components which dynamically change the rendered subtree based on the current state.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by jdthedisciple on Saturday May 25, 2024 @04:59AM (#40473708)
If I'm not mistaken what you describe is pretty much exactly the approach in .NET app development (WPF, MAUI, ...) with C# for the logic and XAML for declarative UI including Binding and it works well and performantly so.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by dweymouth on Saturday May 25, 2024 @10:36AM (#40475307)
This is exactly how the data binding APIs in Fyne (another Go GUI toolkit) work. And it's also an optional feature, so if you want to handle things by registering callbacks and calling setters yourself you can do that too.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by lenkite on Saturday May 25, 2024 @02:06AM (#40472949)
Thanks for making this library, but IMHO these are distinct concerns. One can leverage a state machine or an ECS library for complex state management. Only basic data binding can be a framework capability if needed.

The web had a lack of options for state management and hence React coupled the two.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by zem on Saturday May 25, 2024 @02:12AM (#40472972)
interesting that this uses fltk; I've seen very few language bindings to it
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by andrewfromx on Saturday May 25, 2024 @05:03AM (#40473721)
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by bsimpson on Saturday May 25, 2024 @10:42AM (#40475339)
It's strange to see "inspired by Material Design," and then a bunch of controls that look nothing like Material.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by iamcalledrob on Saturday May 25, 2024 @06:37AM (#40474090)
I have been looking for something like this in Go for a while. I think there's a real opportunity for Go to provide a great developer experience for cross platform UI due to how simple the build process is. Speaking from experience, half the pain of cross platform development is managing build complexity, which Go basically eliminates.

I'm curious how you'll end up solving for cross-platform layout when native controls have different intrinsic sizes per platform?

This is something I haven't seen solved super well in cross platform toolkits.

Wishing you luck though.

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by kdma on Saturday May 25, 2024 @06:58AM (#40474171)
Just for curioristy why did you adopot a react-like model and not implement react-dom as projects like react native do?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by bsimpson on Saturday May 25, 2024 @10:40AM (#40475324)
React Native runs in JavaScript. This is in Go.
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by kdma on Monday May 27, 2024 @10:47AM (#40491226)
React native runs in the native ecosystem through a js-native-bridge and calls platform specifics system calls. https://reactnative.dev/architecture/xplat-implementation react is the <Components /> stuff in js react-dom is the juice
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by sandreas on Saturday May 25, 2024 @07:00PM (#40478463)
Looks great! Thanks for sharing.

Would you consider listing the supported platforms in the readme? I think that would be a pretty interesting piece of information:

  - Windows
  - Linux
  - macOS
  - *BSD
  - Android
  - iOS
  - Web
  - Tizen
Maybe like it's on flutter docs: https://docs.flutter.dev/reference/supported-platforms
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by Fire-Dragon-DoL on Sunday May 26, 2024 @12:10AM (#40479732)
Main problem is that when you release on desktop, a web version is usually desirable (except for very niche apps that interact a lot with the OS).

Alternatively, something that targets many platforms, including mobile.

I've been searching for something for quite a while and the closest is qt and react native, both painful choices for various reasons

Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by gloosx on Sunday May 26, 2024 @02:58AM (#40480230)
This looks really cool but a bit incomplete and messy without XML-like syntax sugar for composing component functions. Is it even possible to extend Go like the JSX?
Re:Show HN: Spot – Simple, cross-platform, reactive desktop ... by jerf on Sunday May 26, 2024 @10:09PM (#40487024)
"Cross-platform: Leveraging FLTK[1] & Cocoa[2], Spot works on Mac, Linux, and the BSDs with plans for native Windows support in the future."

I'd seriously recommend that you consider cutting this. Perhaps keep the lessons you've learned to retain future flexibility, but get good on one toolkit first. GUI toolkits, GUI bindings, GUI in general drowns you in details as it is, volunteering to drown in several different underlying toolkit's details may sound appealing because you may feel like you're growing your metaphorical market, but what you will almost certainly end up with is doing all toolkits badly instead of even one toolkit well, and that won't be good.

We've all heard about how the first 90% is 90% of the work, and then the remaining 10% is another 90% of the work. GUIs make that look like hopeless pie-in-the-sky optimism, where the first 10% is 90% of the work, and then the next 10% is ten times the work, and then the next 10% is another ten times the work. Trying to be cross-platform will strangle you.

However, based on my experience with some similar previous discussions, I don't expect you to immediately buy and agree with my arguments. What I'll really suggest then is to keep what I've said here in the back of your mind, and when you find you're staring down the three toolkits that rigidly require a three-way mutually contradictory way of handling rich text or something, then think back to this post and consider giving yourself permission to drop all but the best-supported and/or most popular underlying toolkit.