3 ms·
Asciinema 3.0 will be rewritten in Rust
- nickstinemates 3y agoNow it'll be even better.
- djha-skin 3y agoIncorrect link. Just goes to the list of open requests. Here is a ticket which mentions the Rust rewrite, perhaps this was what was intended: https://github.com/asciinema/asciinema/pull/579 https://github.com/asciinema/asciinema/pull/579
- OccamsMirror 3y agoI'm impressed that the reasoning was more than just "Rust is super cool."
- booi 3y agoRust is wicked fast?
- notRobot 3y agoMy understanding is that there are lots of functional reasons to use rust in such situations, which are why it's considered "super cool".
- djha-skin 3y agoNot really though. He keeps pointing out that he wants to integrate with Rust libraries, but it's actually pretty easy to write integrations between Rust and Python[1][2]. If that were the actual reason, there is a much better path of least resistance available. The only other type of given argument for moving to Rust was that the author enjoyed it, so it appears to be another "Rust is super cool" rewrite. It really speaks to the power of developer experience. People are willing to rewrite their entire application to be more comfortable. I know I am, only my language of choice is Common Lisp. 1: https://saidvandeklundert.net/learn/2021-11-18-calling-rust-from-python-using-pyo3/ https://saidvandeklundert.net/learn/2021-11-18-calling-rust-... 2: https://www.infoworld.com/article/3664124/how-to-use-rust-with-python-and-python-with-rust.html https://www.infoworld.com/article/3664124/how-to-use-rust-wi...
- moyix 3y agoThe startup time mentioned is actually a big deal for me – I do record all of my terminal sessions (I even wrote a tool that uses his avt library to grep through the terminal logs, although I never got around to making it fast enough to be really useful: https://github.com/moyix/termgrep https://github.com/moyix/termgrep), and with the Python version I often lose the first few characters of my first command in a new terminal because asciinema is still starting up...
- infogulch 3y agoYou record all of your terminal sessions?! Sessions that are open for days? Commands that accidentally spew huge amounts of garbled nonsense to stdout multiple times because you're figuring a command out?
- ku1ik 3y agoMaybe the new `asciinema convert demo.cast demo.txt` command (in 3.0, develop branch) would be useful to you? It converts the session to plain text using avt (which is now embedded in the CLI). You could grep like this: asciinema convert demo.cast /dev/stdout -f txt | grep foo
- kelnos 3y agoI'd usually agree, but the list of reasons involve integrating with Rust libraries, all of which it appears were written by the same author of asciinema. I think it just boils down to the author feeling a lot more productive and less frustrated in Rust than Python. Which is a perfectly fine reason to switch!
- djha-skin 3y agoDoes anyone have information on the success of Rust rewrites? Rewrites in general have a bad reputation, but I'm wondering if it's better for Rust since this course of action is so popular.
- mmastrac 3y agoI've rewritten two personal, non-trivial projects in Rust and both have been successful. The most recent Python -> Rust conversion did take a bit more time than expected but it's stable and has already saved me a few hundred in AppEngine hosting bills.
- djha-skin 3y agoI'd be interested in some elaboration. How did switching languages save you money?
- Jtsummers 3y agoPresumably the normal way (since they're talking about hosting bills). Rust is faster than Python assuming you don't go out of your way to make an inefficient program, and typically consumes fewer resources (though not always, but for roughly equivalent programs it should). This means you can get away with either fewer instances to perform the same amount of work, or the same number instances but for less total time. (Which benefit you get depends on the style of your system, but both will save you money.)
- mmastrac 3y agoI moved from AppEngine hosting to self-hosting (on a Pi). The server was expensive to run on AppEngine and effectively free to run at home. The CPU barely ticks up, even when running a load test.
- timClicks 3y agoI didn't realize that AppEngine supported Rust. Are you compiling to wasm and then using their JavaScript runtime?
- RcouF1uZ4gsC 3y agoHappy to see this. In my experiences, cargo run works a lot more reliably than messing with Python virtual environments and trying to figure out what system wide dynamically linked dependencies you need to install.
- INTPenis 3y agocargo run just defaults to your home dir? Because pip install --user is the same principle.
- kelnos 3y ago'cargo run' doesn't install anything; it just builds and runs directly from the source tree. 'cargo install' does install to (usually) ~/.cargo/bin/. The useful difference, though, isn't in where things get installed, it's that a Rust binary doesn't really care where it lives, and most don't have shared library dependencies that aren't commonly installed already. So things tend to just work, unlike with Python venvs.
- stusmall 3y agoCargo run just builds and runs the produced binary. It doesn't even install it
- jvanderbot 3y agoVcpkg, Conan, and even CMake (kinda) attempt to do similar things. It's almost like static linking is new technology
- steveklabnik 3y agoIt’s not about static linking, it’s about an ecosystem and build tool that specifies dependencies directly rather than ambiently.
- jvanderbot 3y agoVcpkg, Conan, and even CMake (kinda) do this. That's why I mentioned them. They're all trying to replicate pip, npm, cargo' success. The second sentence was not clearly a second unrelated thought, but it was.
- infogulch 3y agoThe fact that the demo is an Asciinema recording that demos how to record and upload an (inner) Asciinema demo is unreasonably amusing. https://asciinema.org/a/85R4jTtjKVRIYXTcKCNq0vzYH?autoplay=1 https://asciinema.org/a/85R4jTtjKVRIYXTcKCNq0vzYH?autoplay=1
- grimgrin 3y agonow you can compare asciinema (rust) to vhs (go) I still use and love asciinema, but will eventually check out vhs. It records terminal activity, outputs a gif, and you can publish to their[1] server. Alternative you can feed it a "tape" file, aka a text file with a few configuration options and your ordered commands to run. My workflow with asciinema sometimes has me cancelling out to redo w/ some minor change, so this tape concept is really attractive 1. https://github.com/charmbracelet/vhs https://github.com/charmbracelet/vhs
- pstuart 3y agoThe charmbracelet team is rocking the command line with Go.
- pests 3y agoDoes VHS have a way to add commands? I do like the concept but one charming feature of asciinema is it captures natural input hesitation, typing candence, deletions and fixing mistakes, etc. The VHS tape replay seems so artifical. I could see how to fake it with the current commands, but I could imagine a "HumanType" or something which increases the delay variance or includes typos that are backspaced and fixed etc, automatically. Just a quick ponder.
- grimgrin 3y agoI think it'll cover your needs. You can configure typing speeds, send commands for backspacing, if you were driving vim you could obv record doing search/replace/deletions The fact you can iterate at all is its appeal to me https://github.com/charmbracelet/vhs?tab=readme-ov-file#vhs-command-reference https://github.com/charmbracelet/vhs?tab=readme-ov-file#vhs-...
- pests 3y agoI saw that, yeah, but I don't want to do that manually. A custom command that could add some jitter automatically or just pretend to be a bit more human would be nice. Lets type "ls -lap" with some hesitation and a typo... Type "ls " Sleep 200 Type "-" Sleep 300 Type "l" Sleep 50 Type "aa" Sleep 100 Backspace Sleep 150 Type "p" Enter :( There is the TypingSpeed variable but its not exactly what I'm going for.
- AlexErrant 3y agoThe player is still in SolidJS. https://github.com/asciinema/asciinema-player/blob/develop/package.json#L26 https://github.com/asciinema/asciinema-player/blob/develop/p... https://news.ycombinator.com/item?id=29387761 https://news.ycombinator.com/item?id=29387761 The Rust frontend frameworks have been creeping up the perf charts, though.
- ku1ik 3y agoThe mentioned rewrite is about the CLI though. The player is fine where it is (Solid.js + Rust/WASM).
- benreesman 3y agoI don’t care what Marcin writes it in: asciinema is just the single best combination of “I use this constantly for serious work” and “this is so fun I forgot I’m even working”. Speaking of which, time for me to donate now that I think of it. Off to do that.
- francislavoie 3y agoWe used Asciinema on our revamped Caddy homepage :) https://caddyserver.com/ https://caddyserver.com/
- milliams 3y agoThat's really nice, especially with the perspective transform.
- sakesun 3y ago"Last but not least, I enjoy working with Rust much much more than with Python :)" Wow. I'm so curios about Rust now.
- Prosammer 3y agoyeah honestly I built 1 little mac app in Rust and now I'm using typescript and can't stop thinking about how I miss Rust's Option and Result
- winrid 3y agoTS solves that too right? Just return a type "MyInterface | null". You can even make it a generic Option<T>, or Result<V, Err> which maps to type Result<V, Err> = V | Err. I'm on my phone but I think that compiles :D
- Prosammer 3y agoYes, I'm stoked you brought this up, as I had previously googled and found some articles that recommend doing this in typescript. I haven't tried it out yet though, mainly because it seems like every article has a different approach to production-ready error handling in typescript and I don't know the best approach. Do you / does anyone have any suggestions for articles etc. on this?
- winrid 3y agono I would just do what makes sense to me, which is what I commented. you can do exceptions or type the return values. sounds like you want to do the latter. handling it isn't as nice as in rust though, I agree. You could create a simple object to emulate it though like "ReturnValue { unwrap: fn, ifOk: fn, ifErr: fn } " where unwrap throws if invalid, ifOk returns true if the response is valid, and ifErr returns true if an err.
- Prosammer 3y agoCheers!
- Cloudef 3y agoIt is not maintained anymore, but there's termtosvg that still works and does not need javascript or service to render your output https://github.com/nbedos/termtosvg https://github.com/nbedos/termtosvg
- epage 3y agoI occasionally use https://crates.io/crates/term-transcript https://crates.io/crates/term-transcript
- rmccue 3y agoI’ve already been using asciinema 3 as a Rust library to build tools - specifically, a tool that runs a command and streams the output logs directly to AWS CloudWatch. So far, apart from some minor bugs which mostly didn’t affect me, things have been working perfectly - so much so that it’s kind of surprising really. Kudos to Marcin (and my thanks for being so engaged on Mastodon when I had questions!)
- srid 3y agoInteresting. When you use it as Rust library, do you produce a cast? What does it record actually? Does using it as a library obviate vhs?
- rmccue 3y agoThe cast format is effectively line-oriented JSON, which adapts well to being streamed directly to CloudWatch, with each line being a single entry in the CW log stream. It's then fairly easy to pull back out and replay as needed. It's published up at https://github.com/rmccue/cinemastream https://github.com/rmccue/cinemastream if you're interested in trying it - it works, but still very early days, as it was just a holiday side-project. That said, likely to become a production tool for work, so will be cleaning it up a bit soon and squashing some bugs. Worth noting that asciinema is not directly usable as a crate currently, so I did need to fork it to add a lib.rs, but the code was so well-structured that there's not much to do there: https://github.com/rmccue/asciinema/blob/rust-lib/src/lib.rs https://github.com/rmccue/asciinema/blob/rust-lib/src/lib.rs - Marcin did say he's open to it once 3.0 stabilised though.
- vwkd 3y agoAsciinema is great! The only thing it’s lacking is full screen support for mobile. Currently, on mobile the full screen button doesn’t work. I can zoom in the page but this never really aligns well.
- ku1ik 3y agoThe problem here is, at least on iOS, webkit on iOS doesn't support fullscreen API unfortunatelly. Once Apple fixes this it should just work (tm). Not sure about Android though (if it doesn't work for you on Android then let me know).