Here’s the original C++ program: Owen Lynn / meow · GitLab
And here’s the (mostly done) port in Swift: Owen Lynn / meowsw · GitLab
Java/Javascript/C# are what I call 2nd gen C-likes and Rust/Zig/Swift are what I call 3rd gen C-likes. I’ve now played with all three of these 3rd gen languages, and of the three, Swift comes out ahead IMHO. I may adopt it for future projects.
The only real complaint I have about the language itself is the lack of a defer statement. It’s not a dealbreaker for me but it does improve quality of life, IMHO. Sometimes you need to close handles before you exit the function and defer makes that happen without introducing errors.
The Foundation API is usable but I do question some of the design choices made. It feels a lot like it was made back in 1997 or so, forcing you to create URLs before opening files for reading, for instance. That and to get an actual pointer to a buffer you just read in - you need to do it in a closure. A closure.
Calling C libraries is a little rough - the modulemap file requires a full path to the C header, which probably doesn’t work on other systems (I’m on linux). But it was possible to get up and running, calling C code after an hour or two. I do appreciate the attitude that there’s other code out there in the world and that people do want to link and call it. Too many languages want you to stay in the walled garden. Thank you.
Overall, I think it took me about a day to get something printing identical output to the C++ program and maybe another day to sand off all the rough edges. And I liked when I guessed at what an expression would be, the guess was right more often than not. I didn’t feel like I was fighting the compiler the whole time.