Hard choices, easy life. Easy choices, hard life. - Jerzy Gregorek
Upon starting building tgpt tool I had to choose where to start. Here's my thoughts.
Disclaimer: this list is opinionated. I develop software for many years and I formed my own taste in languages, frameworks and approaches. If you want debates, my twitter is a good place for it 🙃
Let's start with a list. That's usually a good entrypoint. This time with a list of potential candidates.
I believe there are more options, but these are the ones that I thought about.
What makes language a good candidate for terminal UI?
When I just started to think about it I had to decide what should I look at. Here's my list of things that I value:
These constraints double our list down.
The paradox of choice: why more is less. - Barry Schwartz
What options do we really have?
Swift
Swift was my first language that I "learned". It has own great advantages. Swift is primarily used for implementing interfaces for Apple platforms. So people who wrote tUI frameworks had good references.
SwiftTUI, 1.1k stars. Heavily inspired by (of course) Apple's native
SwiftUI
framework. If you ever wrote iOS application you already know all APIs and how to use them. I tried this one and liked a lot. If you are iOS developer like me, this one is a good choice!TermKit, 451 star. This is a simple UI Toolkit for Swift, a port of my gui.cs library for .NET. This toolkit contains various controls for build text user interfaces using Swift.
Pros
Cons
Golang
I started to use go around 5 years ago for my backends. The main selling point of go is positioning as very easy language to learn and use. And it actually is. So if you are backend developer with previous go knowlege - good choise!
tview, 10.2k stars. Used by huge amount of tools, including popular ones like github own cli tool! This was my second choise. The only reason I haven't picked this one is I personally didn't want to use golang. Too much
if err != nil { return nil, err }
in my life full of writing go 😖.tui-go, 2.1k stars.
tui-go
provides a higher-level programming model for building rich terminal applications. It lets you build layout-based user interfaces that gracefully handle resizing for you. This was created as an experiment and gained a lot of popularity. Unfortunately, no longer maintained.Pros
Cons
Rust
I wanted to learn Rust for a good while. And spoilers: that's what actually I picked for tgpt. Rust is safe, fast and expressive language. It has generics (what lots of libraries in golang lack), macroses, enums, etc.
Ratatui, 8.4k. Ratatui is a crate for cooking up terminal user interfaces in Rust. It is a lightweight library that provides a set of widgets and utilities to build complex Rust TUIs. Ratatui was forked from the
tui-rs
crate in 2023 in order to continue its development. And tui-rs
also was very popular with 10k stars on github. That is de facto go-to choice if you want to build terminal interfaces in Rust.Pros
Cons
So what should we choose?
As always, there is no 100% answer. In conclusion, selecting the best language for terminal UI development hinges on several key factors: familiarity, performance, safety, and the availability of robust UI frameworks. Swift is a strong candidate for macOS-focused projects, especially for those already versed in iOS development. Golang stands out for its simplicity and robust frameworks, making it a solid choice for backend developers seeking an easy-to-learn language. Rust, while more challenging to master, offers unmatched safety and modern expressiveness, making it ideal for those willing to invest in learning it. Ultimately, the choice depends on your specific needs, background, and willingness to embrace new languages. Each option has its strengths and trade-offs, so choose wisely to ensure a smooth development journey and a high-quality terminal UI application.