Weird Rust

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.

要查看或添加评论,请登录

Eric Kolotyluk的更多文章

  • Iterators Make Sense in Rust

    Iterators Make Sense in Rust

    Interface Iterator has been in the Java standard library since version 1.2, December 8, 1998.

  • Going Further With Rust

    Going Further With Rust

    After writing Getting Started With Rust, the adventure got more interesting, and the resulting code was simplified to…

  • Getting Started with Rust

    Getting Started with Rust

    After watching a lot of Rusty videos, and doing Hello World in Rust, I finally started a real project: Comparing Files.…

    4 条评论
  • A Rusty Web Assembly Architecture

    A Rusty Web Assembly Architecture

    When I learned Java and Web Applets I could not understand why Applets failed as a technology, and I resented the fact…

  • AI Idiocracy

    AI Idiocracy

    In the movie "Idiocracy" the hero wakes up in the future where everyone is stupid..

  • Dance Monkey Dance

    Dance Monkey Dance

    I had a job interview today that generally went quite well until the interviewer invoked the "Dance Monkey Dance"…

  • Arc Browser First Impressions

    Arc Browser First Impressions

    While watching I was impressed enough to try out this browser I had never heard of before. As a loyal Firefox user, it…

    1 条评论
  • Why RISC Five?

    Why RISC Five?

    The Genius of RISC-V Microprocessors is a highly technical presentation of RISC-V processors, so I am breaking it down…

  • Ten Years of MacBook Pro

    Ten Years of MacBook Pro

    I recently received my new M3 Max MacBook Pro to replace my 2013 Intel MacBook Pro. I will spare you the usual…

    2 条评论
  • Teamwork in the Modern Age

    Teamwork in the Modern Age

    I have been doing couple's dancing since 1997; to say the least, it’s teamwork. Sure, there are generally only two…

    2 条评论

社区洞察

其他会员也浏览了