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

by Andrew N.T.

Hero image

Photo by Louis Reed

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

Table of Contents

  1. What's new

    1. Class ParseResult
    2. Separation of file types
  2. C# vs Rust

  3. Additional links

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.

Originally posted at