Hey @inthehands and anyone else who might be listening. If I already implemented undo/redo by saving snapshots of my state and with very small test data it's fine, does reimplementing it with a command pattern count as premature optimization? Is it still worth doing just to learn more? Or should I put this energy into writing tests? Or learn how to generate big test data and then see?
This is a hobby project in TypeScript...
@alter_kaker
If it’s a hobby project, the first and most important question would be “Would this be fun to implement?”
If you’re actually trying to optimize, well…you can probably get a good sense of whether you’re in danger territory just by doing some thumbnail estimates of how much state data you’re going to be dealing with at full scale. If you know you’re headed for trouble, architecting from the start for undoing via commands or deltas instead of full snapshots makes sense.
@inthehands frankly, maybe what would be most fun is to start over in Rust. TypeScript is neat but the build tools and dependency hell suck. And I got some pretty advanced ts concepts from this adventure so I feel like it was worth it. Esp now that I'm technically a TypeScript dev at work
@inthehands I'm pretty pleased, by the way. Do you remember—I think I told you how I took this chance to work on an Angular app without any previous experience. It totally paid off, now I'm officially a Typescript and Angular dev, plus everyone knows that I'm the guy at whom they can throw whatever's needed and I'll just pick it up. My next assignment might be serverless functions in Go. I got a book.
@alter_kaker
Awesome! Exploration always pays off.
Rust is fun, based on my limited knowledge. Real head trip if you’re used to the high-level world of Typescript! But also lots that will feel familiar.
@inthehands yeah, I've done a bunch of stuff with Rust already, but I keep running into things that are difficult to wrap my head around, like life times. And I am annoyed by the lack of reflection. And it's very slow to write, so much time fighting the compiler... It was my other choice for this project from the start, and I picked ts because I wanted to write code fast and experiment and iterate. This is after you suggested to just start writing...
I still haven't found the ideal language for these types of projects. Maybe it's actually Python, but I don't enjoy writing in it.
@inthehands it does have the best enums I've encountered, and I adore the result pattern and the way you can work with optionals and vectors. Honestly after experimenting with Rust I never wrote code the same again. Maybe I'll just make everything an Arc, that'll take care of a lot of the pain points
@alter_kaker
Seems like Rust is amazing if you have the problems it solves, and if you don’t have those problems, you really wonder what the heck it’s doing.
“Rust but make everything Arc” is kind of Swift. If you want Rust’s rock-solid type system and enums and performance but are willing to sacrifice a little performance not to fight the borrow checker, Swift is lovely! And Linux support at this point is pretty solid.
@inthehands looking into it. A couple of things I'll miss: Optional is an enum, no exception throwing. The latter of course is a matter of style, but I hate having to catch library exceptions
@alter_kaker
Both are true of Swift as well. Optionals are heavily sugared, in what I think are some really brilliant ways, but underneath it’s just an enum. There are no exceptions; errors are values. It doesn’t quite have the perfect interop between errors and Result that I might wish for, but it is an exception-free language.
@inthehands interesting, they don't seem to advertise it in the docs
@alter_kaker
If you’re reading the tutorial/guide, I’m sure they don’t advertise. It’s a good tutorial, but it’s there to help newcomers get comfortable and not to explain the language’s structure. The reference manual gets more into that.
If you want to dig into how Swift implements optionals, you might find this exercise that I give my p-lang students useful: https://github.com/mac-comp381/swift-optional-desugaring
@inthehands I landed on Rust because learning a new language felt overwhelming. And what do you know, for a change I'm working together with the borrow checker instead of fighting it! No unexpected mutation of something passed by reference.... It turns out that command pattern with undo is a problem that the borrow checker solves
You did get me curious about Swift, though. For when I'm feeling a little better.
@alter_kaker
I’m glad it’s working for you! I have heard people say that there’s a moment with Rust where the borrow checker kind of clicks, and suddenly seems a lot more reasonable. Enjoy the project, and send me Swift questions if you ever poke at it!