HNHacker News
TopNewBestAskShowJobs

mikeday

52 karma · joined December 26, 2012

Working on Prince to get HTML + CSS into PDF
submissionscomments
mikeday··on Show HN: PrinceJS – 19,200 req/s Bun framework in 2.8 kB (built by a 13yo)
Ohhh Nigerian Prince, I thought it was a wrapper for our Prince HTML to PDF formatter, but there is also a JavaScript implementation of Prince of Persia lol.
mikeday··on The hardest program I've ever written (2015)
yeah, we often refer to the first 90% of the work and the second 90% of the work lol.
mikeday··on The hardest program I've ever written (2015)
Absolutely! The CSS support, layout engine, PDF output, and JavaScript interpreter are all written in Mercury, while the font support that was originally a mix of Mercury and C has now been rewritten as a standalone Rust project, Allsorts.
mikeday··on The hardest program I've ever written (2015)
We've spent twenty years working on HTML to PDF conversion and I expect we could easily spend another twenty years, so feel free to give Prince a try if you would rather avoid the headache :)
mikeday··on Allsorts: font parser and shaping engine implemented in Rust
HarfBuzz is more complete (supports more scripts) and higher performance (we assume, haven't benchmarked yet), but the large C++ codebase can be a little intimidating to dive into. We plan to extend Allsorts to reach feature parity with HarfBuzz, so it will be an interesting comparison of tackling a complex problem in Rust!
mikeday··on Show HN: GuiLite – Tiny UI framework, runs on MCU without OS
What about compiling existing OpenType fonts to state machines in combination with the shaping rules? That's something we're thinking about for our Rust implementation :)
mikeday··on The Mercury programming language
It's a wrapper around the native process just to simplify passing command-line arguments. (There is also a persistent process mode for speeding up batch processing of many small documents).

The browsers don't specialise in PDF generation, and we do :)

mikeday··on The Mercury programming language
We use Mercury at YesLogic to write Prince, our HTML to PDF formatter! [1]

We chose it because logic/functional languages are great for tree processing, Mercury was designed for large projects, and because in 2002 there really weren't many other options around.

Its syntax and semantics are derived from Prolog, it borrows a lot from Haskell (types, type classes), in spirit it's reminiscent of OCaml (niche, little weird) and with support for unique modes there is some interesting overlap with Rust, although this aspect of the language still needs more compiler support.

All in all, definitely worth checking out.

[1] https://www.princexml.com/