Friday, September 06, 2024

Typestate Pattern

I recently gave a slideshow presentation that I entitled "Typestate Pattern in Rust: With Fluent Constructor and State Machine Examples".  My thanks again to Cameron Dershem, the Organizer of the Indy Rust Meetup, for giving me the opportunity to speak to his group a second time.  I also thank the members of the Dallas Rust User Meetup (DRUM) for letting me practice initial drafts of my talk on them at our semimonthly online meetings.

In my talk, I started by providing the contexts for using the typestate pattern before digging into the implementation details as demonstrated by the examples in my open source code repository.  By working daily on the code examples for a month, I reached the point where I finally feel like I understand typestate and its variations.  You can download the presentation slides in PDF format from my Rust and WebAssembly research page.


Sunday, July 07, 2024

Variance in Rust

I recently presented a slideshow on the subject of "Variance in Rust: Covariant, Contravariant, and Invariant".  My thanks to Cameron Dershem, the Organizer of the Indy Rust Meetup, for inviting me to speak to the group.  This was an updated version of the talk that I gave to Dallas Rust User Meetup (DRUM) a few weeks before.

In my talk, I introduced the terminology and showed some basic code examples.  An ending slide includes links to where I learned about this topic so that interested Rustaceans can dig in deeper.  You can download the presentation slides in PDF format from my Rust and WebAssembly research page.


Friday, March 08, 2024

Programming Rust

It took me a few months but I finally finished reading the O'Reilly book Programming Rust Second Edition (2e) authored by Blandy, Orendorff, and Tindall.  I see now that there is also a "Revised 2nd Edition" which "Covers Rust 2021 Edition" meaning Rust 1.56 or later.  The edition I read "Covers Rust 1.50" so it is probably not much different.

I started recommending this book even before I finished reading it.  If you could only read one Rust book, this would be it.  Since you can read more than one Rust book, I would start with The Rust Book and then read "Programming Rust" sometime before you pick up Rust for Rustaceans.

The cover subtitle is "Fast, Safe Systems Development" and the book does appear to be written for those already familiar with systems programming.  I was grateful to the authors that some of the more advanced concepts expressed in their example code included diagrams to accompany the in-depth explanations.  This might be the intermediate-level Rust book that you were looking for.

This 700+ page book is big but O'Reilly has published bigger.  The Fourth Edition of O'Reilly's "Java in a Nutshell" was almost one thousand pages.  In a review that I wrote many years ago, I joked that "over the years this 'in a nutshell' book has expanded to fill the size of a coconut".

The physical bulk of "Programming Rust" is such that it can be less comfortable to handle while reading.  For the next edition, my advice to the authors is that they split the book into two volumes when they add content.  I can see that the authors have already arranged the chapters such that the more esoteric material comes later which could work well for a second volume.

My next read might be the recently published PacktPub book Asynchronous Programming in Rust by Carl Fredrik Samson.  The quality of PacktPub books can be hit-or-miss but this looks like a good one.  I am also eagerly anticipating a wave of new Rust books, hopefully including a Third Edition of "Programming Rust", when the 2024 Edition of the Rust programming language is released later this year.

 

Wednesday, January 10, 2024

Advent of Spin 2023

Recently I participated in the Advent of Spin 2023, an annual holiday-themed coding challenge hosted by Fermyon.  I wrote Rust code, compiled it to WebAssembly (Wasm), and then deployed the code as Function-as-a-Service (FaaS) serverless components running in the Fermyon Cloud.  The source code is available from my GitHub repository advent-of-spin.

Yesterday I presented a slideshow to the Dallas Rust User Meetup (DRUM) in which I described my solutions to the coding challenges.  This was in preparation for my being the guest speaker today on the YouTube show Fermyon Cloud Office Hours.  My thanks to the DRUM Members (DRUMMers) for their attention and feedback and my thanks to the employees of Fermyon for running this event.

 

Friday, December 01, 2023

Rust in the Cloud

For the frontend, I have had some good success recently using the Rust-based user interface framework Dioxus to create web applications.  Now I am exploring using Rust on the backend with serverless cloud technologies such as Fermyon Spin and Cargo-Lambda.  You can check out what I have so far in my new GitHub repositories spin-prototype and cargo-lambda-prototype.

Yesterday when I tuned in to watch the livestream of the Amazon Web Services (AWS) re:Invent 2023 conference keynote by the Chief Technology Officer (CTO) of Amazon.com Dr. Werner Vogels, I suspected I might hear something about Rust because the AWS Software Development Kit (SDK) for Rust had just transitioned from Developer Preview to General Availability a couple of days before.  To my delight, Dr. Vogels made the case for switching from Java to Rust in the cloud for reasons of cost and sustainability.  You can watch his presentation on this topic at the one hour mark in the YouTube video recording.


Friday, October 20, 2023

Dioxus Prototype

Previously I made web application prototypes using the Rust-based front-end frameworks Sycamore and Yew.  With the recent release of Dioxus version 0.4, I updated my Dioxus Prototype.  It demonstrates capabilities such as animation, form inputs, and static prerendering.

Saturday, September 23, 2023

Rust-Dioxus Project Setup

Previously I used Angular to make Single Page Application (SPA) websites in the TypeScript programming language.  I then used the Angular tool Scully to statically prerender the SPA webpages for Search Engine Optimization (SEO) and to be able to distribute the website code from a Content Delivery Network (CDN) instead of a web server.  When I switched over to the Rust programming language last year, I needed to learn new ways of doing things.

After a lengthy quest in which I explored a number of nascent Rust-based SPA libraries, I have finally figured out how to make this work which I have documented with step-by-step instructions in my new tutorial Rust-Dioxus Project Setup.  A few months ago I became the Organizer of the Dallas Rust User Meetup (DRUM) so I have created a website for that group that provides an online example of the techniques described in the tutorial.  I will be updating the tutorial over the next few months as my understanding of Dioxus improves in the process of converting my old websites.


Monday, August 28, 2023

Rust Podcast Duos

I updated my list of Rust Podcasts with two new entries:

I have listened to all eleven episodes so far of "Way of the Crab" and just started "Rust Workshop".  Both of these podcasts feature a co-host duo but each podcast has its own distinct personality.


Sunday, July 23, 2023

Rust Mars

I am currently working on converting to the Rust programming language yet another Java applet that I originally wrote a couple of decades ago.  Mars is a tank combat game which provides a demonstration of the use of my Rust-based implementation of the A* algorithm.  Although you cannot control one of the tanks yet, you can toggle on options to visualize how each tank is using the A* algorithm for pathfinding.

I was struggling with a memory leak in Mars until a member of the Dallas Rust Meetup mentioned that the wee_alloc dependency that I was using for memory allocation with WebAssembly (Wasm) was known to have this issue.  I removed wee_alloc and the problem immediately disappeared.  I have since updated my Rust-webpack Project Setup tutorial to no longer include wee_alloc in the setup instructions.