Live data from Hacker News

Rewriting my blog in Rust for fun and profit

jonashietala.se

51–60 of 116 posts

Re: Rewriting my blog in Rust for fun and profit

#51

I really liked the reactive pattern, so one of the best static site generators I found was docpad. It used (backbone?) collections, so you could subscribe to changes on things like "new files under this path" and then rerender the part of the page that needed to change. I haven't seen this done in others. Then docpad was rewritten in ES6, and I lost all love for it. Things were so expressively concise in Coffeescript…

It's kind of ironic and uncool that DocPad's website is made using GitBook.

Re: Rewriting my blog in Rust for fun and profit

#52

It’s refreshing to see a front-page Rust piece that just nails it on promoting the language. It cites concrete examples of where the rubber really meets the road: e.g. Cargo as a one-stop-shop for platform insensitive, “just works” build and dep management. It acknowledges that it’s ok for fun and novelty to be features, which it is! It steers well clear of A >> B nonsense. No preachy TED talk about memory safety. It…

Your comment helped me want to click through and read the post. I'm very tired of all the recent Rust fanboy posts, but level-headed and earnest comparisons against real implementations make for much better understanding of a new concept or language. Here are some select quotes from the article: > Please note that this is not to say that Rust this [sic] much faster than Haskell, instead see it as a comparison of two…

I religiously refresh HN the last few months and I've seen exactly zero "fanboy" Rust articles. All of them outline what was gained by a switch to it and what problems were eliminated. The better ones also list tradeoffs i.e. they say what got a bit harder, too.

Maybe you just have an axe to grind?

Re: Rewriting my blog in Rust for fun and profit

#53

I also rewrote my blog's static site generator to a bespoke one (in Dart in my case), largely for performance reasons. Prior, I was using Jekyll and Pygments. Jekyll and Pygments are really slow. My new site generator is literally 100x faster, and I did, like, zero real optimization work. In fact, it can rebuild my entire blog and every post from scratch faster than Jekyll's watch mode (with caching set up properly)…

I wrote Zola because at that time I was using Hugo + Pygments and while Hugo was fast, Pygments was the opposite. I'm pretty sure Zola can build a 1k page website with syntax highlighting faster than Pygments can highlight 20 pages.

Re: Rewriting my blog in Rust for fun and profit

#54
I have some 381 posts (including landing pages, etc). It takes maybe 45 minutes to build (there is no cache process). I have a faster version that skips audio processing, but it still takes minutes.

The problem is that it does several pandoc parses for each page:

1. Plain text - Input for audio parsing (which takes a significant amount of time, I have a version of the build that skips this).

2. Simple HTML - Input for RSS feed.

3. Full HTML - Static web page.

One change I would make to pandoc is to have the option for several outputs (as was discussed years ago [1]). I think generating multiple outputs is highly common usage.

One feature I will get around to writing (eventually) is automatic image compression. I had some success using jpegoptim and optipng on another project. This takes a while, so I want to build a command line tool that caches the output of a command if both the input file(s) and command do not change, and invalidate based on time. That way I could blindly do something like:

    image="cat-pic.png"
    cache-run -i $image -c "optipng -dir out/ -o 4 -strip all -fix $image"
(You might want to experiment with different optimization values based on resolution, etc).

[1] https://groups.google.com/g/pandoc-discuss/c/lex900rSpOM

Re: Rewriting my blog in Rust for fun and profit

#55

It’s refreshing to see a front-page Rust piece that just nails it on promoting the language. It cites concrete examples of where the rubber really meets the road: e.g. Cargo as a one-stop-shop for platform insensitive, “just works” build and dep management. It acknowledges that it’s ok for fun and novelty to be features, which it is! It steers well clear of A >> B nonsense. No preachy TED talk about memory safety. It…

[deleted]

Re: Rewriting my blog in Rust for fun and profit

#56
post #4

I did the same thing a couple years ago [0]. It's not the most elegant and my blog is miniscule, but it was a fun project and also born out of frustration with the existing site generators. I structured it as the source sitting next to the site contents, so from a fresh computer (with Rust installed), it's as straightforward as `cargo build`. I think the best thing about this approach (writing your own generator) is…

I just linked your blog post in a separate comment because I was reading it over the weekend. I was looking for articles about writing static site generators and didn't realize most people don't roll their own templating engines. I was disappointed to see not much on templating in your post but it definitely gave me the confidence to keep going. Managed to get aspects I'd been struggling to work for months working yesterday.

Re: Rewriting my blog in Rust for fun and profit

#57
post #45

Earlier quoted context omitted.

The author is clearly an experienced and mature hacker who knows many languages well. It’s pretty difficult to maintain the shrill “X is better than everything” tone you’re referring to with a diverse portfolio of marketable skills. I don’t know how Rust, which is quite a cool language, attracted this sizable bloc of aggressively intermediate jihadis, but it’s really worrying because Rust is in fact innovative and im…

You’re really going to call people jihadis for talking about the technical strengths of a programming language? And then you’re going to act like you’re the self appointed arbiter of discourse on HN, saying that this kind of article is ok but that kind isn’t? Maybe a person who calls those they disagree with jihadis isn’t qualified to police what others say. Let’s talk about the way you talk. Here’s you from 5 days a…

While his vocabulary might be a inflammatory, it's hard to argue that any language has an evangelistic community anywhere near the level of rust's. No other community is pushes their favorite language for every single use case. No other language has a rewrite it in rust meme. No other language attacks people for unsafe code.

Re: Rewriting my blog in Rust for fun and profit

#58
post #7

I've been trying to make a cool static site generator numerous times. Well, yes, it actually is a quite fun thing to tinker with, but I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill. So I ultimately went with Zola[1] and encourage you to try it too! Aaaand it is written in Rust, too.…

> I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill.

It's tricky. You can't accept all the features otherwise you just have a mess. At the same time you need to also add/supports features that a lot of people want but _you_ personally don't need if you want the tool to be used by more than 1 person. For example with SSG I don't use themes, I just write my own templates for every site. Despite that I still added it to Zola because most people want themes. Some people will not be happy when you say no to some features they want but hey, it's open-source they can always fork it.

Re: Rewriting my blog in Rust for fun and profit

#59
post #7

I've been trying to make a cool static site generator numerous times. Well, yes, it actually is a quite fun thing to tinker with, but I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill. So I ultimately went with Zola[1] and encourage you to try it too! Aaaand it is written in Rust, too.…

I plan on writing a static site generator soon myself. And I briefly wondered the same thing and realized that I could very easily answer that question: ruthlessly build whatever I personally need and not what others need. I don't usually follow that line of thinking, but the static site generator space is so full of so many great tools that I don't think there's really anything for me to contribute to it. Instead, I…

I went this route. At first I tried writing a bunch of Python scripts reading a YAML manifest. However, after ~2 weeks I already got warnings and errors about things which got deprecated/removed/changed by a new Python version and the YAML library I was using. So I dumped it and rewrote the thing in XML and XSLT. It's been working for a couple years with no breakages. Essentially 0 maintenance after the initial work. This design was about generating a tree of directories with Markdown files turned into HTML, PDF files turned into pages linking to them, and some directory renames, GUIDs and dates (for Atom feeds, which I generate for each directory) specified in a manifest file.

I've since taken up photography, so now I need to automatically read metadata from jpegs, add some tags and organise it on the site in albums. It's a bit outside the reach of XSLT, so first I've tried using Python with Jinja2 and PIL. Same problem as previously. So I've rewritten it in Go with the help of encoding/json (for the manifest), html/template (for the template), image/jpeg, golang.org/x/image/draw (for generating thumbnails of different sizes for different screen sizes) packages and exiftool (reading and removing EXIF tags). Pandoc has been present throughout all the rewrites, because I like its flavour of Markdown and options to shift heading levels by a specified value, so that they fit in with the surrounding template. I'm putting some finishing touches and am going to upload it in the coming days.

I know, you stopped reading at "XSLT". :D

Re: Rewriting my blog in Rust for fun and profit

#60
post #7

I've been trying to make a cool static site generator numerous times. Well, yes, it actually is a quite fun thing to tinker with, but I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill. So I ultimately went with Zola[1] and encourage you to try it too! Aaaand it is written in Rust, too.…

I ended up making mine with Pandoc + Make. At first i used Nextjs and Remark/Unifiedjs but then I had a realization that all that is not even needed.
Post reply on HN