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.

Building Bubbletea Programs

148 pointsby paranoidxprod9 months ago

15 comments

terminaltrove9 months ago
This was a great read.<p>Bubble Tea (a Go TUI framework) recently hit 1.0 [1] and the author&#x27;s tool that is built with it is called pug [2] which is an awesome terminal user interface for terraform which we featured on Terminal Trove [3] a while back.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;bubbletea&#x2F;releases">https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;bubbletea&#x2F;releases</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;leg100&#x2F;pug">https:&#x2F;&#x2F;github.com&#x2F;leg100&#x2F;pug</a><p>[3] <a href="https:&#x2F;&#x2F;terminaltrove.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;terminaltrove.com&#x2F;</a>
评论 #41409340 未加载
评论 #41410559 未加载
wonger_9 months ago
The author describes the same TUI app workflow I&#x27;ve settled on. Three notes:<p>- entr is a good livereload tool: <a href="https:&#x2F;&#x2F;eradman.com&#x2F;entrproject&#x2F;" rel="nofollow">https:&#x2F;&#x2F;eradman.com&#x2F;entrproject&#x2F;</a>. I prefer to wrap the livereload scripts in a Makefile, under something like `make dev`.<p>- Managing layout arithmetic by yourself is a real pain. A widget abstraction like Bubbletea&#x27;s is very helpful. Also, don&#x27;t forget about weird Unicode characters (eg. emoji) potentially breaking width calculations.<p>- Since this follows the Elm architecture, consider storing your data the Elm way into one big, flat Model. Elm webapps turn into headaches when you split state among submodels. I think the same happens in TUI apps. I&#x27;m glad the author found a solution with a tree of models and message passing. But personally, I&#x27;d rather have a Model with 100 fields than the complexity of sumbodels.
sweeter9 months ago
I love the way Bubbletea looks, but it is nightmarishly hard to do anything more than what is outlined in the examples.
评论 #41413451 未加载
评论 #41411632 未加载
评论 #41411630 未加载
评论 #41413398 未加载
评论 #41411721 未加载
klabb39 months ago
From section 5:<p>&gt; go func() { […] m.content = &quot;initialized\n&quot; }() […]<p>&gt; …but only once a key is pressed several seconds later does it return:<p>&gt; initialized<p>&gt; For this reason, making changes to the model is best done in the normal message flow, either in Update() or via a tea.Cmd.<p>Not just best practice, but absolutely necessary because the code has a proper race condition. It must absolutely be avoided at all cost. Fortunately, it’s easy to do: never mutate the model outside of the event loop (ie a separate goroutine). Fortunately Go’s race detector is generally excellent at detecting this at runtime as well, so it’s always a wise idea to add -race to your testing&#x2F;QA process. It surprises me Google built such an awesome and easy-to-use tool yet few seem to use it.<p>Great post btw. I use a homegrown similar architecture myself. I do wish Go had better dispatch architecture than a switch statement but it’s not the end of the world.
评论 #41409889 未加载
aliasxneo9 months ago
I&#x27;ve wanted to write a TUI with Bubbletea, but as the author points out, getting started with it is very intimidating. I feel the brute-force approach of &quot;just doing it&quot; is probably the only way to produce something as nice as pug.<p>That said, I&#x27;ve bookmarked this excellent resource should I decide to pursue that path soon. Thanks for the write-up!
isoprophlex9 months ago
Not the main focus of TFA, but damn, the tool they built looks useful and polished.<p><i>A terminal user interface for terraform power users</i>: <a href="https:&#x2F;&#x2F;github.com&#x2F;leg100&#x2F;pug">https:&#x2F;&#x2F;github.com&#x2F;leg100&#x2F;pug</a>
paranoidxprod9 months ago
I’ve been writing small web apps for internal teams and Bubble Tea has been super helpful for building TUI managers for these apps. The article does a good job explaining some of the finer details of the library.
评论 #41409906 未加载
fnordlord9 months ago
This couldn&#x27;t have come at a better time. I just started my first Bubbletea based app earlier today. Thanks for writing!
sim7c009 months ago
good stuff thanks. even though i dont use go nor bubbletea for my tui app work in progress this had a lot of good insights. might even consider go and bubbletea if i get really stuck :D
tomohawk9 months ago
We&#x27;ve been able to be very productive with bubbletea. Didn&#x27;t know about teatest - we&#x27;ll have to look at that.
winterqt9 months ago
From point 1: how does the function returned from model.update confirm to (tea.Model, tea.Cmd)? Is that a typo?
评论 #41410335 未加载
bionhoward9 months ago
I really like the variable font size by indent, is this an established style we could achieve in VS code?
Instantnoodl9 months ago
Bubbletea is great and fun to work with. Even building a terminal game with it since a while :)
stranded229 months ago
Well, that was disappointing.<p>Was hoping for an affiliate program guide for bubble tea advertisers
Gualdrapo9 months ago
How come so many people is writing cli programs in Go? What happened to C?
评论 #41409732 未加载
评论 #41408624 未加载
评论 #41408023 未加载
评论 #41408770 未加载
评论 #41410204 未加载