Embarking on a Rust Web Development Journey in 2023

It has happened - I now have a blog. Please take a look around and get comfortable. While it may not be much, it is something that is all mine.

Intro

In all honesty, I must admit that I am not a writer, but rather a developer through and through. So appoligies ahead of time. Nonetheless, I started software development with VB6.0, now specialized in FullStack Web Development, primarily focused on Java. Development and creating things, in general, has been a long passion of mine. Java, as a language, does its job well. Many say it is verbose, but it is a solid OOP language that is well-supported in the corporate space. However, there is a nagging feeling that there may be something better out there - something... Rusty.

Rust has been on my radar for many years. Back as I was first learning development, A misguided priority in the language I wanted to use was for the language to be one of the fastest languages to run. I disliked the notion of interpreted languages, I thought C++ was the bees knees. To an extent I still hold that view, preferring .NET and Java over Node and Python due to their decent though not quite native performance. Rust in theory does it all!

So, that brings us to today. When Rust was introduced, it was initially set to be a contender for systems and IoT development. Today, however, it's much more. With a rich and growing ecosystem, Rust has the potential to be used in all areas of development. From its introduction to the Linux Kernel, to rich frameworks like Yew.rs, the language has come a long way. There are still challenges, though, with the difficulty of learning the language, the tools, and ensuring your code is idiomatic. It is overwhelming, enough to hold many back, but it does not have to be...

Building a Blog in 2023

So, why build a blog, and why from scratch? For me, it comes down to a few reasons:

A blog is an intriguing type of web app, with numerous examples ranging from static sites built with pure HTML/CSS to WordPress solutions, as well as custom sites developed using various frameworks. The features of a blog serve as an excellent demonstration of a toolset's capabilities. A blog has the simple core functionality of sharing the writer's thoughts while offering extensibility with opportunities to experiment with design and additional features.

But enough digression, what am I doing here?

The Plan

The starting point for this blog requires improvement, but it serves as a foundation and an opportunity to witness a site undergoing active development. To further develop this site, here's my plan:

HTML/Scripting Framework

I'm using Rust on WebAssembly with the Yew Framework for this project. The content you're reading now was built in Rust using Yew.rs. lthough it's not the only framework available - Smithy and Dioxus are also good options - I've been using Yew for the past year. With its recent addition of features like server-side rendering, it has become even more appealing.

Styling

During my initial introduction to React, I learned how to use Styled Components. Since then, I've experimented with other solutions such as Tailwind CSS. However, I appreciate the flexibility offered by Styled Components, and fortunately, there's a similar library for Yew called stylist, which I use for this blog.

Content

Sometimes it's crucial to keep things simple, even though what seems simple initially might turn out to be more complex after implementation. For the time being, the content remains straightforward. This site uses Markdown to define the content and the library
pulldown-cmark to parse the content into HTML using the default mapper. The advantage of this approach is its quick implementation - just feed the parser the content in Markdown, and it outputs HTML. However, the drawback arises when you need custom features. Upon closer inspection, if you need to modify the default parser, you'll have to implement everything yourself.

Alternatively, you could define content in another format like JSON. This approach provides more flexibility in terms of design and implementation but comes at the cost of simplicity.

Infrastructure

The infrastructure aspect of this project is probably the most uncertain at this stage. Currently, the application's infrastructure is defined in Terraform, with a simple static app deployment on Digital Ocean. Digital Ocean wasn't the only choice; there are countless static site options available, from Github to AWS or even running Nginx on a Raspberry Pi. However, static sites have their limitations. You can extend them with REST APIs, but if you want to implement server-side rendering (SSR), you'll need a more flexible solution.

Given that this is a blog and likely to have limited traffic, serverless seems like a good option to consider. Serverless would allow the site to scale for load if necessary while keeping costs to a minimum. However, serverless providers that support Rust are relatively rare. Currently, the main options for serverless Rust are AWS and Cloudflare, though there may be more. There are pros and cons to adopting a cloud-native solution from one of the large cloud providers.

Alternatively, a containerized approach could be an option. On one hand, Digital Ocean offers excellent support for Kubernetes (K8s), and using it would mean that this site isn't constrained to just one cloud provider. On the other hand, is K8s really necessary for a blog?

This topic is likely to evolve into its own series of posts. I hope to find a framework similar to the now-abandoned IronFunctions, but it's uncertain at this point. Perhaps WasmEdgeRuntime?

API Framework

I haven't given much thought to the API framework yet. I have experience with both Warp and Axum in the past, so I'll likely stick with one of those two if I decide that a REST API is necessary.

Moving Forward

As we embark on this ongoing blog series, we'll continue to explore and learn about Rust's potential and capabilities in the realm of web development. I hope the blog itself will serve as a living testament to Rust's growth and versatility while providing insights into the potential as a full stack language Rust has.

Throughout the series, we will tackle various aspects of building the blog from scratch, including infrastructure, styling, content, and API frameworks. As decisions are made and implemented, we'll share the reasoning behind them, discussing the pros and cons of each choice. The series will also document the challenges faced, lessons learned, and best practices discovered along the way.

With each new blog post, readers will have the opportunity to follow along and experience the journey of a developer diving deeper into Rust. I invite you to join us in exploring the language, learning from our experiences, and perhaps even considering Rust for your own projects. Stay tuned for future updates as I continue to build and expand this blog using Rust.

Copyright 2023-2024 Ugvx.
Disclaimer: The opinions expressed on this blog are solely my own and do not reflect the views of any current, past, or future employer.