Andrew Nguyen
Andrew's Engineer Blog

Follow

Andrew's Engineer Blog

Follow
REIMAGINE: Designing files structure for a SSG (C#)

Photo by American Public Power Association on Unsplash

REIMAGINE: Designing files structure for a SSG (C#)

Andrew Nguyen's photo
Andrew Nguyen
·Apr 17, 2023·

1 min read

This is the sequence of Designing files structure for a SSG (Rust)

What's new

Class ParseResult

With the additional request for parsing Markdown, paper C# implementation removed the SourceFile class and implemented different class for each type (i.e. MarkdownFile and TextFile). Template is named more concisely as HtmlFile. Anything that genereate ParseResult (like MarkdowFile.Parse() or TextFile.Parse() can convert the result to .html using HtmlFile.Parse(). This removes the reduntdant of html parsing logic, and can easily supports and future file types.

Separation of file types

Separating the old SourceFile into MarkdownFile and TextFile also help organize the methods used by different file types.

C# vs Rust

Coding in C# certainly has less overhead to worry about (e.g. memory management), but Rust is undoubtedly more performant. As a fun experiment, I had an input directory like this

folder structure of the experiment

The logic for both implemenetation are identical, but C# took ~5 seconds to generate the output. Meanwhile, Rust was ~1 second. Mind blowing.

 
Share this