Weird Rust
The only Rust program I have written is "Hello World!"
I have been watching many YouTube videos, but this resonated greatly.
The more I learn about Rust, the weirder it seems to me. As someone who started programming in BASIC in 1970 and is most comfortable with Java, Scala, and Kotlin these days, Rust seems like the bastard child of C and Scala.
Systems Programming Language
As a systems programming language like C, it lets you get to a very low level and reminds you constantly of this. In fact, there are no "class" in Rust, but like C, "struct" is how one defines a 'type.'
On the other hand, unlike some languages that have "interface," Rust is more like Scala having "trait" with both interface and implementation. It also has an "enum" that is like Java and modern Scala. In both Java and Scala, enum is like a class, but more specialized.
Diagnostics
In the early days of C, there really were no diagnostics at compile time. If your compile failed, you would run "lint" for static analysis. Well, what else could you expect on a PDP-8 or PDP-11?
Rust compiler diagnostics are likely the best I have ever seen, the best in the industry. The Rust compiler works very hard to ensure we do not do something wrong or even stupid. When doing systems programming, this is a very welcome capability.
Exceptions
Like C, Rust does not have exceptions such as in C++, Java, .Net, etc. While Scala does have exceptions, functional programming in Scala tends to rely on structured results such as Option, Either, and Try.
On the other hand, reactive functional programming in Scala can become completely undermined with exceptions. In Java Project Loom, they made an extraordinary effort to make concurrent asynchronous programming work with exceptions.
Rust assumes that exceptions were a bad idea to start with in C++, and there is increasing evidence that this is true. I am increasingly convinced that exceptions and exception handling makes programmers lazy and only focus on the happy path.
It is hard to write robust, reliable, and resilient code, and Rust is like those nagging parents who train you as a child to be responsible, reflective, and remediating. There are some great videos to help us better get into this frame of mind.
Ugly Duckling
Rust code can sometimes be very ugly to look at, read, and comprehend. But, as the code matures, to the end user, what they will see is a beautiful swan.
On the other hand, Rust advocates claim that as time goes on, Rust code does not seem so ugly, and they spend less time and effort trying to deliver robust, reliable, and resilient products.
Garbage Collection
Most modern frameworks, such as Java and .Net, rely on garbage collectors to reduce the cognitive load on the programmer and reduce programming mistakes such as memory leaks. However, it can be very frustrating if you have been using a program and the garbage collector kicks in when you are in the middle of something. Also, garbage collection does not eliminate memory leaks and related problems; it only reduces them.
Rust has memory management, but conforming to its dictates can be very frustrating. While it does reduce programming mistakes, it does not introduce latency and other nondeterministic performance problems.
Web Browsers
While writing web apps in Javascript does not seem like systems programming, Rust is becoming popular in user interfaces because it improves the user experience by eliminating the annoying pauses in garbage collection.
Additionally, we will likely see Rust displacing Node.js as a full-stack development environment, where Rust is one of the first platforms to compile to web assembly for even better full-stack performance.
Understandably Weird
Indeed, those who dance with Rust do hear the music.