Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

Follow publication

Member-only story

Making Web Apps in Rust: Part 3— Utilizing Web APIs

Olenin Slava
Towards Dev
Published in
8 min readJul 11, 2023

--

In this part, we are going to animate our clocks!

Animated Rusty Clocks

Articles in the Series:

Brief Overview

Should you come from a JavaScript background, your initial thought might be, “Just employ useInterval, what could be simpler?” Yet, this is where the complexities arise if you’re considering Rust. Even after a few hours dabbling with Rust and mastering some rudimentary concepts, you’ll end up with code that’s compact and neat. But I can’t recall another language that can make handling such an ostensibly trivial matter so challenging. However, it’s worth noting that it does become much more manageable with experience.

Leveraging Web APIs

I want to stress that the aim of this article is to provide insight into what it’s like to develop purely Web Applications using Rust. Here’s my perspective on this:

  • If your aim is to create a Web-first application, TypeScript is your best bet. If the need for high-performance operations arises, code those in Rust and export them as an npm package using wasm-pack.
  • If your objective is to develop cross-platform applications, avoid using WEB APIs directly. Instead, opt for cross-platform abstractions.

In this installment, we’ll explore how to use the browser’s setInterval. This might seem more complex than expected, but it’ll afford us the opportunity to delve into three crucial aspects of Rust: ownership, closures, and usage of Web APIs. Let’s start with the least ‘rusty’ one — Web APIs.

Using Web APIs in Rust

Mostly, when Rust for the Web is discussed, it’s often associated with the wasm-bindgen tool — this facilitates high-level bindings between Rust and JavaScript. Here are some key features highlighted in the official documentation:

--

--

Published in Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

Written by Olenin Slava

Passionate Software Developer with a strong focus on Web, 3D, Mobile, and pretty much any interactive computer graphics.

Responses (1)

Write a response