[HN Gopher] Bubble Tea: fun, functional and stateful way to buil... ___________________________________________________________________ Bubble Tea: fun, functional and stateful way to build terminal apps Author : ingve Score : 196 points Date : 2022-05-10 15:22 UTC (7 hours ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | dangets wrote: | This and the surrounding ecosystem was recently featured on an | episode of The Changelog podcast. | https://changelog.com/podcast/481 | jerodsanto wrote: | Thanks for sharing the show! Here's a transcript for those | who'd rather read: | | https://changelog.com/podcast/481#transcript | | And a couple audiogram snippets from the conversation: | | https://www.youtube.com/watch?v=8-5WAKrt9GQ | | https://www.youtube.com/watch?v=OE5LzZbojX8 | cosmotic wrote: | Clippy: It looks like you're trying to make a GUI, would you like | help with that? | BaconPackets wrote: | We recently did a quick POC with py-cui for a TUI app. It worked | pretty well but you quickly see the limits. | | This looks really interesting and could be a fun way to get into | the Go landscape! | nepeckman wrote: | I've seen the charm suite on HN before, and everytime I see them | I wish they had bindings to other languages. I'm just not | interested in Go, but I'm really interested in learning to create | ssh applications. Its an application runtime with a lot of | potential for the dev space, but almost no quick-start | frameworks! | kelvie wrote: | Why not? There's a lot to hate about every language, but one | advantage about Go is that it's fairly easy to context switch | in/out of, which makes it great for side projects, because it's | cognitive load while using it is really low. | | Unlike say, Rust. I do love Rust though. | nepeckman wrote: | I'm only really interested in learning a language if it | excites me, or if I'm getting paid to do it. I don't hate Go, | and would be fine to learn it on company time for company | projects, but there is no spark that would lead me to learn | the language on my own. I've written some basic Go, but if | I'm using it in personal projects, I'd would have to invest | time to understand the ecosystem, runtime, standard lib, best | practices, etc. | pstuart wrote: | It's not exciting but it is pleasing. The ecosystem is | refining well (e.g., $GOPATH deprecated and workspaces just | added). | | Now with generics there's even less to complain about. | mfarstad wrote: | One of my favorite TUI frameworks. I made | https://github.com/mathaou/termdbms with it. A very pleasant | experience. | throwawayboise wrote: | That looks pretty cool, but as most/all DBMSs come with a TUI | utility*, what is the advantage? | | *(psql, sqlplus, isql, etc....) | pstuart wrote: | Ha, I checked it out and it was definitely worthy of a star -- | then I noticed I'd already done so. Now I just need to get | around to playing with it. | shriphani wrote: | I've been using dialoguer [1], indicatif [2], and colour [3] for | the rust ecosystem. Really high quality libraries: | | [1] https://docs.rs/dialoguer/latest/dialoguer/ [2] | https://github.com/console-rs/indicatif [3] | https://docs.rs/colour/latest/colour/ | ivantse1 wrote: | Loved this framework as it helped me build my ssh app idea really | quickly (https://github.com/ivantsepp/ssh-slides)! In fact, it | pushed me to finally learn golang haha. Would love seeing more | and more ssh apps in the wild. | simulate-me wrote: | One thing that I like about this is the implementation of | returning state from the Update function. My only experience with | Elm-style architecture is with react / redux which involves | meticulously copying pieces of the state object to return two | distinct before / after states. Using a Go struct with copy | semantics makes this extremely easy and more natural to write in | an imperative fashion. One limitation of this is that the model | structure can only contain value type (e.g. no pointers, arrays, | or maps). | mordechai9000 wrote: | Just curious, I'm not familiar with Go. Will it copy the | references anyway, meaning both structures now have a pointer | to the same object? That's the way it works in other languages | I'm familiar with, so you have to be careful about what you | copy and how you use it. | kgeist wrote: | >Will it copy the references anyway, meaning both structures | now have a pointer to the same object? | | Correct. A value copy is a simple shallow copy. Deep copy | requires use of reflection (if you don't want to manually | manage copying). | arccy wrote: | yes, that's what it does in go | tonyhb wrote: | Yes, but it doesn't actually matter. You can use pointers for | models, return the same pointer, and it will re-render fine. | We do this for our CLI at https://www.inngest.com for | creating new serverless functions via a quick walkthrough. | | It's actually the `tea.Msg` that causes re-renders. Here's | the code: https://github.com/charmbracelet/bubbletea/blob/v0. | 20.0/tea..... | | tea.Msg is, in Redux land, an "action" that triggers some | state updates and _always_ triggers a re-render, even if | nothing changes. | | This is elm-like, but we have to understand the limitations | of what we're working with: a terminal with no way of | (nicely) updating elements in place. It's essentially an | immediate-mode UI, and so it always paints. | sriram_malhar wrote: | Well, it does matter, or rather, it could matter. | | For example, say you needed an undo/redo mechanism. If the | model were guaranteed to be immutable model, you could | simply hang on to the previous models as a sequence of | state changes; undoing/redoing is trivial. If the model is | mutable, then the undo/redo system has to defensively make | a copy before update is called | christianrocha wrote: | Do note, however, that paints will only occur if the output | changes, and only lines that have changed will be redrawn. | kgeist wrote: | >One limitation of this is that the model structure can only | contain value type (e.g. no pointers, arrays, or maps) | | How does one manage dynamically sized lists of elements, if | arrays are disallowed? | simulate-me wrote: | You can use arrays, but if you want to maintain the Elm-like | model of before and after states, then you need to explicitly | copy the array into the new state rather than rely on Go | copying just the pointer. | substation13 wrote: | This looks like a really cool project, however I have to say that | the Go language seems like a _terrible_ match for the Elm | architecture. | aarpmcgee wrote: | I'm not overly familiar with Go and would be curious to hear | more details about this. | anderspitman wrote: | I spent a good chunk of time last week looking for a solid cross- | platform GUI toolkit. I came to the conclusion that the terminal | is the most portable GUI platform available. You can create an | app that has windows, buttons, mouse support, etc, statically | compile it for Windows, Linux, and Mac, and run it over SSH. The | closest you can get to that with real graphics is using a toolkit | built on OpenGL, and you'll be forced to dynamically link to X11 | or Wayland on Linux. | | The achilles heel of terminal UIs is that they can't display | images. | Hamcha wrote: | This is so sad. Every time I boot up Plan9 for fun I'm reminded | their remoting solution (drawterm) does graphics just fine | (since everything is just files, and graphics is done by | writing to a software framebuffer device file). | | Sure, it's something you can do with SSH via X11 forwarding | since forever, but it seems the ecosystem never quite stuck the | landing, and now we're here trying to figure out how to make | CLI more like GUI for our own sanity. | | Maybe we should give it another shot? It seems Windows is | trying to do something similar with WSLg to achieve seamless | integration of Linux apps within Windows 11 (using RDP under | the hood), what is everyone else doing? | oddlama wrote: | I'm actually kind of glad that X11 forwarding didn't stick. | TUIs are generally efficiently navigatable using just the | keyboard, a property I very much enjoy and frequently miss in | "real GUI" apps. | digisign wrote: | They can display images, though the resolution is not very | high, even with sixels. | qbasic_forever wrote: | I'd look at Qt or Electron if you need to do cross-platform | desktop apps, if for no other reason than accessibility. Sure | you can make wacky midnight commander like GUIs in the console, | but no screen reader is going to be able to make heads or tails | of them and you'll shut out users. | cmroanirgo wrote: | Less modern systems have been running cross platform forever. | Eg Free Pascal/lazarus. | | TUI/GUI (qt,gtk,cocoa,...) & even has pas2js | akkartik wrote: | Lately I'm all in on LOVE (https://love2d.org). No dynamic | linking required, cross-platform, less bloat than mainstream | toolkits. Anything it can't do I just accept as a constraint I | can't change. | ghosty141 wrote: | Disagree, there are a ton of differences, especially when it | comes to fancier stuff like ncurses provides for example. | | QT and Electron are the most capable cross platform tools for | building UIs in my opinion. Both have their drawbacks of | course, QT is a pain to work with and electron is famous for | being not responsive enough for some users | throwawayboise wrote: | Almost every language has an ncurses library or module. Isn't | ncurses fairly cross-platform? | djmips wrote: | I don't like things that pollute our natural language namespace. | Couldn't you have named it something unique? | tsm wrote: | An overwhelming number of programming-related things "pollute | our natural language namespace". Off the top of my head: | | Ruby, Python, Java, Rails, React, Go, Rust, Elm, Dart, C, C#, | Node, Next, Nest, Kafka, LaTeX, bash, fish, cat, Android, | Apple, Windows... | | I'd be happy to search for this with "bubble tea framework" or | "bubble tea tui" or similar and it doesn't bother me. | dvngnt_ wrote: | elm? | kube-system wrote: | It's a type of tree. | fwip wrote: | Yes, an elm is a kind of tree. | djmips wrote: | All Terrible. | mrtranscendence wrote: | I'm having trouble thinking of a single example of a | language, library, or piece of technology that is not either | an acronym, a name of something that exists, or a combination | of such names. Be it an object (Flask), a concept (Scheme), a | letter (C), a person (Sinatra), or an animal (Python). | | Maybe we need explicit namespacing in English? I'll start | saying stuff like "programming languages colon colon ruby" so | people can be absolutely sure what I'm talking about. | keithnz wrote: | erlang | hkt wrote: | Alas, people might get the wrong idea about what kind of | colon you mean. | bbkane wrote: | I bet you HATE the Go language name. | neltnerb wrote: | I myself just don't understand why any reasonable person | would pick an existing common word for a project in 2022 | instead of using the plethora of name generators that can | give you something original without even trying. | | But like, people that work for Google _surely_ know something | about search term collision. Or just don 't care about making | anything else that has "Go" in the query gets confusing | results. Which is an odd stance for Google employees, but | none of my business I guess. | | Of course it's common anyway, I just don't see why you'd do | this to yourself. You either bury your own project, or you | are so successful with branding that no one can find what | used to have that name. Google can push something hard enough | with perfect SEO to make sure that Go the language shows up. | A github page? | | I mean, it's not Google but: | https://duckduckgo.com/?t=ffab&q=go&ia=web First hit -- | https://go.dev | | https://duckduckgo.com/?t=ffab&q=bubble+tea&ia=places This | project is not anywhere near the front page and I can't | imagine it ever being. Too many different companies are | selling boba tea. | | I never really _like_ it when companies use existing common | words, but unless you 're a huge project or a company that | can push the SEO and marketing it's actively burying your | work from anyone finding it. | er4hn wrote: | I call it "Golang". I also _hate_ the use of 1 letter | variables in Golang. Give me three and make it easy to search | for symbol names in my no-frills editor. | | /derail. | djmips wrote: | I do. ___________________________________________________________________ (page generated 2022-05-10 23:00 UTC)