8 ms·
Ink: React for interactive CLI apps
- insane_dreamer 2y agoNice accomplishment! However, React seems overly complex for a TUI, unless you already work with React in the browser and love JS?
- klysm 2y agoObviously that depends on the complexity of the TUI. React is the best tool I’ve used to build UIs out of all the tools I’ve ever tried. I don’t love JS at all.
- akie 2y agoI'm unsurprised, disappointed, excited, and surprised at the same time. It's clear that the React paradigm works really well to model user interfaces, and as such it's no surprise that it can be used to build anything from desktop software to apps to websites to command line apps. Amazing work!
- seanw444 2y agoSaving the world, one GitHub project README banner at a time. I don't know how I feel about writing CLIs in JS. Just seems a little bit janky to me, and I don't know why. I wonder if there's any push to have something JSXish in Go, even if it requires a pre-compiler to achieve the syntax, just for CLI apps like this. Then again, maybe I'd just rather stick with something like Nim where you can just have a first-class DSL through the macro system.
- captnasia 2y agothere's a few attempts, templ[0], gomponents[1]. Not for cli apps per se but for web dev. 0: https://github.com/a-h/templ https://github.com/a-h/templ 1: https://github.com/maragudk/gomponents https://github.com/maragudk/gomponents
- seanw444 2y agoI've seen gomponents, but it seems very verbose. Although I guess that's what you're stuck with if you're doing it within Go.
- kaba0 2y agoI don't know, go has lackluster expressivity, and these pre-compile tools always feel like a hack in its case.
- ipsum2 2y agoI don't think its a Go-specific issue, its useful syntactic sugar. I would love an updated JSX for Python.
- russellendicott 2y agoThis is my side hobby, a server side TUI protocol with a light browser like client that can navigate any TUI. http://uggly.bytester.net http://uggly.bytester.net The primitives are good enough to build anything you want. Right now I'm trying to figure out how to make better libs and tooling for creators (mainly myself) so I can crank out lots of examples apps that showcase the power of TUIs where you don't need a dedicated executable for each one.
- bartekpacia 2y ago> Saving the world, one GitHub project README banner at a time. I can feel snarkiness in this response. I don't like it. From Ink's author [0] post: > The time has come though to move on from Ink. Since russia’s full-scale invasion of Ukraine in 2022, everything in my life revolves around the war. And anything else has lost all meaning to me. I no longer have the mental and physical capacity to maintain Ink and give it the attention it deserves. [0]: https://vadimdemedes.com/posts/moving-on-from-ink https://vadimdemedes.com/posts/moving-on-from-ink
- ProfessorZoom 2y agoa cli that has a useEffect is so cursed
- klysm 2y agoIt’s there as an escape hatch :)
- teaearlgraycold 2y agoI like useEffect though
- cupofjoakim 2y agoI get that there's a lot of people only comfortable in the js-landscape, but I still think this is a weird tool for the job. If performance is a concern there's no way node is the right thing to start, and react just seems silly to me here. Should be noted that I do a big portion of my day to day work in react - no hate on the framework.
- slashdave 2y agoNode.js is not necessarily bad, but React? What makes React great is the ability to embed the DOM in your app. For CLI? Square peg, round hole.
- lowboy 2y agoReact enables declarative UI code instead of imperative. That's one of its biggest values. Even in the terminal, especially as the complexity of a tool increases.
- hombre_fatal 2y agoWhat makes React great is that you write a UI tree that updates when state changes instead of imperative code like a clearRect() + drawLine() cycle. This project and others like React Native show that it works outside of the DOM: you just render something else instead. Thinking that React is only helpful for DOM UI seems like a misunderstanding of what React is and what makes it great.
- MrJohz 2y agoI'm not sure that's true. There's lots of ways to use and manipulate the DOM. But React is particularly special because it turns out to be a simpler way to think about UI components. A TUI has nothing to do with the DOM, but it's got a lot to do with rendering UI components. So taking the ideas from React and applying them to drawing elements in a terminal makes a lot of sense. Arguably it makes even more sense than with React. One of the problems with React is that the underlying DOM is a stateful, imperative system, whereas React wants to behaves much more like an immediate-mode system, where the whole UI can be dropped and re-rendered at any time. But the terminal is not stateful like the DOM, and a more immediate-mode paradigm arguably works better in this context than in the browser.
- sirtimbly 2y agoJS will eat the software world. So having better tools on par with charm in the go world would be great.
- haolez 2y agoOr it will be the (huge) technical debt of tomorrow.
- TikTikFook 2y ago[dead]
- throwaway106382 2y agojust because you can doesn't mean you should
- EddieRingle 2y agoSee also, Mosaic, experimental terminal UI using Jetpack Compose: https://github.com/JakeWharton/mosaic https://github.com/JakeWharton/mosaic Since it's Kotlin, it has backends for the JVM, LLVM, and JS/Wasm, though curiously Jake recently removed the JS target because it wasn't seeing much usage.
- seveibar 2y agoInk is great for CLI tools and enables really great tools. People who are saying React only belongs on DOM are missing out- React is the world's most popular and powerful declarative programming paradigm. It's being used for native apps, VR, 3d, CAD and electronics. React allows you to mix declarative and imperative programming concepts together in an effective way. To give a sense of why this is important: Imagine a CLI built with XML. It'd probably be pretty verbose and have a lot of domain-specific configuration. There also wouldn't be a great typechecker. React combines the most robust type-system in the world (Typescript) with declarative style. It has issues, but being "built for DOM/web" is not one of them. RE: Ink. A simple example of where it is better than most tools is you can simply import a re-usable "ranger-style" file browsing component, and adapt it for things like exploring a database, a spreadsheet, or an API spec. The potential is very high. Hats off to the author and contributors!!
- cupofjoakim 2y ago> the most robust type-system in the world (Typescript) This is very high praise for something that only provides safety at compile time and not runtime.
- oorza 2y agoSure, but ten years ago, if I told you the concept of a "bottom type" would be common knowledge with web developers or they'd consider type algebra second nature, you'd have laughed at me. If I were to tell you they pushed a Turing complete type system into the mainstream and then abused its computational power to do things like create value types, you'd ask me where I was buying my LSD. TS might not be the most robust type system in the world with no qualifiers. And it might not even try to be sound. And it might disappear at compile time. But none of that changes the fact that it took a bunch of concepts that only programming language dorks knew or cared about and turned them into every day utilities that the junior most developers use. And it doesn't change the fact that it is the only mainstream programming language with a fully Turing complete type system. Give credit where it's due. I say all of this as one of the aforementioned programming language dorks who took a really long time to get on board with TS, as I thought Flow's focus on purity made it a better choice.
- taskylizard 2y agoSee also the blog post by the author: https://vadimdemedes.com/posts/moving-on-from-ink https://vadimdemedes.com/posts/moving-on-from-ink
- magicmicah85 2y agoIf your use case is mainly consuming web APIs or providing helper tools around your web framework, I can see why using this would be useful as you could reuse the same libraries you use in your application.
- d4mi3n 2y agoI don’t get all the hate. Sure, JS isn’t the most popular language for TUI apps, but there’s always room for more TUI tools and I’d you’re automating things for your JS project this is a pretty natural fit to make your project scripts friendlier to their users. I think I’d much rather have more nice TUIs than not, regardless of the language they’re written in.
- deleted 2y ago[deleted]
- bcherny 2y agoInk is awesome, but it does have some rough edges. For example, want to absolutely position something on screen? Not possible. The UI also tends to flicker when you’re doing anything complicated, in a way that can be hard to debug.
- yesthisiswes 2y agoThis! I hit both of these issues. I tried building a solitaire game using ink. I couldn’t stack and offset the cards on top one another so they took up a lot of screen real estate. Then when I had re-renders the screen would flicker. Other than that it was a joy to use. I think I even tried flipping the solitaire board horizontal but that felt too weird.
- oscb 2y agoI like Ink as an idea for how to use React creatively. It’s very well done. At the same I think most CLIs do not need this kind of interaction. It is better to keep them simple and verbose rather than fancy and obscured. I spent a long time removing Ink from an enterprise tool where it didn’t fit as it was meant more for CI/CD. Not this tools fault of course.
- hinkley 2y agoHalf the tools I write end up being used in CI/CD so even if I do fancy in a terminal you have to do simple for non interactive shells.
- itronitron 2y agoI'm curious how developers that use React, but have never written an application using the MVC paradigm, would describe React.
- klysm 2y agoI’ve used both. MVC is too limiting
- cyberax 2y agoReact is nice, but it has some sharp edges. Basically, you're logically re-rendering _everything_ on every render. The React engine then diffs it with the last state, and then applies necessary actions to reconcile them. As a consequence, your rendering code is invoked by React, and you have to follow some rules to make sure that React doesn't have to _physically_ re-render everything. Another consequence is that physical component creation is taken out of your hands. This works great, if you're doing something with tons of simple components. It works less great if the actual rendering is a complicated task. E.g. you're making a map widget, or a 3D editor. You might be better off not using the reactive approach, and fall back onto the classic MVC.
- synergy20 2y agovery nice, write some js/ts with React and use node to run them to get a CLI.
- evantbyrne 2y agoLooks like someone reported a dependency vulnerability back in June and never got a response. Seems like one of those projects that is a pretty neat experiment, but users should probably expect to maintain their own fork if they plan to use it.
- gausswho 2y agoThe creator handed over control in May due the invasion of Ukraine.
- revskill 2y agoReact is a kind of declarative programming, not just for the UI !!!! I could take React as a kind of FP design pattern.
- adamscybot 2y agoOdd to see this come up. I used it about 6 years ago to produce a CLI for devs. It worked very well and React concepts map cleanly to pretty much any "UI" target as said targets can also be well represented by declarative & composable trees. Probably, other Ui frameworks could also map, seeing as the declarative/composable tree pattern is ubiquitous now. So it's important to note it's that pattern which enables this, and not a specific framework. But React is one of the ones that is also more removed from the web target than others.
- jacobp100 2y agoI used this at a company that was going all in on micro frontends. You’d clone whatever MFE repos you want, and it would manage package installs, building, and restarting the server after a rebuild. Worked great!