Saturday, August 13, 2022

Sycamore Prototype

Today I launched a new open source project, the CroftSoft Sycamore Prototype.  This is a conversion of one of my old Angular-based CSS Grid Layout demonstrations to the Rust-based front-end framework Sycamore.  My portfolio page has a link to a demonstration of the in-progress prototype.

Previously I was focusing on the far more popular Yew framework but according to this comparisons webpage on the Perseus website, Yew does not support static site generation (SSG) and server side rendering (SSR).  Perseus appears to be a framework layered on top of Sycamore which does support SSG and SSR.  Besides Sycamore / Perseus, another framework that I am considering is Dioxus.

Rust Project Setup

I started a new tutorial webpage providing a Rust Project Setup checklist. In addition to project directory creation and customization, it includes preliminary development steps such as tool installation. I am going to be adding to this over time as I use it.
 

Friday, August 12, 2022

Rust Podcasts

I have enjoyed listening to the Rust programming language podcast Rustacean Station. I like this podcast because it is not always the same host speaking. Now that I am all caught up with all eighty-eight episodes published to date, I searched for a different Rust podcast to listen to while I wait for the next episode to come out.

Fortunately one of the more recent episodes of Rustacean Station is an interview with the former host of the now defunct podcast New Rustacean with one hundred and three episodes available. I listened to the first episode tonight and it sounds like I am in for a high quality experience. I have also sampled the start of the first of nine episodes of the podcast Rust Game Dev.

Friday, August 05, 2022

Zero Arguments Methods

In my book Advanced Java Game Programming, I have a sidebar recommending named notation as a work-around for the Java programming language not supporting named arguments.  Here is the example from the book as converted to the Rust programming language:

let game_data = SerializableGameData::new(
  10,  // health
  99,  // wealth
  18); // wisdom

There is a proposal to bring named arguments to Rust but until this proposal is adopted I have started using a new work-around which I am calling "zero arguments methods".  Here is a static function to be converted:

pub fn periodic_savings_needed(
  f: f64,
  r: f64,
  t: f64,
) -> f64 {
  f * r / ((1.0 + r).powf(t) - 1.0)
}

Here is the equivalent using a zero arguments method:

#[derive(Clone, Copy, Debug)]
pub struct PeriodicSavingsNeeded {
  pub future_value: f64,
  pub interest_rate: f64,
  pub time_periods: f64,
}

impl PeriodicSavingsNeeded {
  pub fn calculate(&self) -> f64 {
    let f = self.future_value;
    let r = self.interest_rate;
    let t = self.time_periods;
    f * r / ((1.0 + r).powf(t) - 1.0)
  }
}

Here is how the zero arguments method can be called:

let calculated_value = PeriodicSavingsNeeded {
  future_value:  1_000_000.0,

  interest_rate: 0.12,
  time_periods:  10.0,
}.calculate();