Typst is pretty neat

RSS podcast badge Spotify podcast badge Apple podcast badge YouTube podcast badge

tl;dr: a programming language for documents

James shares a bit about Typst as an excited newcomer to the 'documents as code' ecosystem, while simultaneously throwing a lot of shade at LaTeX, a tool that James and Amos have never really actually used.

View the presentation

Video

Audio

Download as M4A

Show Notes

Episode Sponsor: Depot

Transcript

Amos Wenger: Cool. Trying a slightly different mic position. Hopefully, that's not an issue.

James Munns: I need something to go with my ask for the audience. I just need to have a big red band over here that's just like, "Don't look over here. Just don't." Right. No head turn further than like, "Face the camera."

Amos Wenger: There's a scene in Orange Mécanique. I forget the name of the English thing.

Amanda Majorowicz: A Clockwork Orange?

Amos Wenger: A Clockwork Orange. Where he's like like this and they make him look at things. I don't know what they're making him look at, I forget, but you should put whatever that is where you shouldn't look, whatever. Well, if you had the big, the big, the big...

James Munns: I'll put a jump-scare over here.

Amos Wenger: You should put those on and crank up the gain. Because then if you plosive, you will hear it immediately. It will punish you.

James Munns: That's fair. I have no immediate feedback because it's distracting and it breaks my train of thought.

Amos Wenger: Really? Well, with any delay, yes. But with direct monitoring through the USB interface, I'm well...

James Munns: It's probably just a habit. Like because I never have it, I'm not used to it. I'm sure if I did it for a week, it would make sense. Or if I recorded as many videos as you have, I would.

Amos Wenger: Well, I don't have feedback when I record videos because I'm just standing below a boom mic. But yeah,

James Munns: I think I just need a boom mic is probably what I need.

Amos Wenger: No! Not for this.

James Munns: I have a big fuzzy shotgun. Just mount it to...

JAmos Wenger: No.

Amos Wenger: Oh, yes. OK, yes. But only if you treat your entire room acoustically. Oh, OK.

James Munns: Are you telling me that the hard plastic and wood...

Amanda Majorowicz: Doesn't have a nice sound dampening material?

James Munns: No, but I just need to put crushed velvet all over everything.

Amos Wenger: It's not as bad as where I record, where it's mirrors and glass. So wood is already not that bad...

James Munns: Do you record in a dance studio?

Amos Wenger: I will show you my studio eventually. No, no, no, it's just a room, but it has those big open windows.

James Munns: You have like hard walls and stuff.

Amos Wenger: Yeah. And hard walls. And it's not even a cube because the roof is at an angle because it's right below the roof. The ceiling is at an angle.

James Munns: I have a friend who's like an audio and mastering engineer, and he built a like shed studio for himself. And they actually built the walls not at 90 degree angles on purpose because it's better for diffusing-- So like he treated the whole room, but also all the walls are like slightly-- like five degrees off on purpose.

Amos Wenger: That's a good shirt idea. "Five degrees off on purpose."

Amanda Majorowicz: Merch, merch, merch!

Typst is pretty neat

James Munns: All right. This is an episode where I am more excited than informed. Are you ready, Amos?

Amos Wenger: That is the whole entire idea of this podcast. I am so ready.

James Munns: I feel like some days we're informed and reluctantly excited. And then some days, some days we come firing in like "I learned a thing!" And this is one of those. This is one of those days because last week I picked up a tool called Typst, which I've been having an eye on for a long while, but finally came up with a couple of things that I needed it for. And it's that classic like I can't learn something new until I have like two specific projects that I need it for. Because otherwise I'll just read all the docs for forever and go, "Yeah, yeah, yeah. Makes sense." and retain none of it. And then the moment that I have real projects to put together with it's, "Oh, OK. Now it sticks." So this is Typst.

Amos Wenger: I thought it was pronounced "tipst" actually...

James Munns: I don't know. This is one of those that I've never talked to someone in person about it. So I'm saying like type like type.

Amos Wenger: It is T-Y-P-S-T.

James Munns: Yeah.

Amos Wenger: Just for the readers who are not reading the slides available at sdr-podcast.com/episodes

James Munns: Well, I mean, they're based out of Berlin, so it might be "Typst" (German accent). I don't know. We'll see. But I think Typst is pretty neat. So as a TLDR for someone who hasn't heard of it before, Typst is basically a programming language for documents. And this isn't a particularly revolutionary thing.

You might have heard of LaTeX before

James Munns: You might have heard of LaTeX before. LaTeX is one of those like what is it? It wasn't Kernighan. It was the other C guy. But it was it's one of those he made it in a cave out of a box of scraps. Like he was typesetting the um... it was Ritchie, I think, because it's K&R. It was when Ritchie was typesetting. I think the original one of the original textbooks was like --

Amos Wenger: Knuth.

James Munns: What, was it Knuth? You're right. It was Donald Knuth who made TeX. Yeah. I'm forgetting my C language luminaries here. Or I'm getting them muddled up. But yeah, it's one of those needed a typesetting tool. So wrote one and basically the entire like university paper writer and a lot of professional bookmakers and stuff have been using something not terribly far out of the TeX family. So it's about LaTeX but it's I guess it's T-E-X like tex and then LaTeX is how I always see it. But I never really learned LaTeX even because I never did a PhD in university.

So I was never a researcher and I never had to actually typeset anything seriously. So I've managed to go almost my entire software career using either graphical editors like Word or like Google Docs or whatever or Markdown. Tremendous amount of my customers actually just prefer Markdown for even serious reports because they stick it in the docs folder of their repos and then no one has to worry about losing it. And if I'm making architecture diagrams and stuff, it's great because it goes in the repo or I end up copying and pasting it into their wiki or whatever I end up using it for.

Amos Wenger: And you can diff it and everything.

James Munns: Yeah. Yeah. And so this is always the benefit of using Markdown over Word or .docx or just PDFs really is that it's easy to diff. And there are some tools for diffing PDFs and there's change tracking, but they don't jive well with the normal software development practice. But yeah, these are languages that are used for typesetting. So you write your actual text, but you also write things like: hey, I want a table here with this many columns and this width of the column or I want my margins to be this, my number of columns to be whatever.

And it's a programming language and it has a compiler and you run the compiler on it. And instead of putting out a binary, it spits out a PDF or an SVG or whatever you'd like it to be. So these are interesting because they do sort of then come back around to the programming workflow where you can put them in a Git repo and you can have shared components and you can have all of these kind of things. And I've not ever used LaTeX, but have you, Amos?

Amos Wenger: I have, but I've never been a serious researcher either. I think the name for this podcast is a fraud. Neither of us have been researchers.

James Munns: We're independent researchers.

Amos Wenger: We are.

James Munns: We decided to do consulting instead of PhDs.

Amos Wenger: So you floated this topic recently and I said my own experience is through LyX, L-Y-X, which was a WYSIWYG editor for LaTeX. What I think very funny about the history of TeX, if I may interject for a second, is that Knuth made it because the first-- I'm going to read straight up from Wikipedia, which is 50% of what making a podcast is. The first edition of his book was typeset using hot metal typesetting on a monotype machine. I have no idea what it looks like. It's a method dating by the 19th century, produced a classic style that he liked. And when the second edition was published, they had to typeset everything again because the monotype technology had been replaced by photo typesetting. And he looked at it.

So from from 68 to 77, they switched to a new typesetting system. He looked at it and was like, "I liked it better before." So he just made his entire typesetting system. And then if you're wondering the difference between TeX and LaTeX, the 'La' part is mostly a set of macros. It's just like it's really just the maths behind it. And then you need to build kind of an ecosystem, a standard library or something of things you can use on there.

James Munns: Yeah, because there's a whole bunch of plug-ins and things like that. And this is why it gets used in a bunch of scientific writing. One, like universities will typically have like a standard template so that everyone writing a paper uses the same template and it gets imported like a macro or a library or something like that. And then same for graphs and tables and anything else that you put in there. So it has like a consistent looking voice is the wrong thing to use for text, but a consistent looking style.

And, you know, that way, even if you have just PhD researchers, they end up with something that looks consistent for the university and stuff like that. But like I said, I only did my my bachelor's, so I missed out on that. For my bachelor's, we didn't have a bachelor's thesis, but we had like a final project. And I think I just used Google Docs for that, if I remember correctly. Serious, serious intent on on that. But it was a much different audience than publishing in a research paper or something like that.

Amos Wenger: True. I do. I do find it interesting that unless I'm misreading this and if I'm wrong, we will get emails about it. But I don't think it was out of... it's not like the free software story. It's not like, you know, I want to use a printer. I couldn't because software was fucky. So I just started a whole movement. It's more like there's nothing that can do this right. So it's not even about making it open or whatever. It's just like I want to make my own because I know I can do this better.

James Munns: This is like back in the Bell Labs days, right? Like this is when... Knuth wasn't... I don't remember if Knuth was at Bell Labs, but I think it predates like the-- well, LaTeX probably doesn't. But I don't know. I'm going to speak on-- off the cuff here. But I think it's older than that. But yeah, I do think it was one of those yakshaves of like, "Oh, well, there's no software for that. So I guess I'll just write an entire typesetting programming language," as you do.

Amos Wenger: Yeah, I'm fact-checking you as we go. And I see mostly-- I see Stanford University. I see University of Oslo. I don't think he's part of the Bell Labs people.

James Munns: OK, like I said, I'm probably muddling up my C luminaries again.

Amos Wenger: Yep, you gotta get mixed up.

You might have heard people complain about LaTex

James Munns: But also, if you've heard people talk about LaTeX, everyone I know who's used LaTeX also has complaints about LaTeX in that it is very like macro heavy. It's an artifact of its time, as far as I know, in that it's one of those things that it made sense at the time and it's just been grown and things added to it. And macros that were reasonable are less reasonable when you're a decade away from the person who wrote it or people who are in university. It's like, well, who wrote the macros that our university uses? Some third year undergrad student who is the only person who figured out how LaTeX worked and could write macros for it. And now if you ever have to debug it, it's horrible. Or, you know, I can't give that many directed complaints because I've never used it, so I'm not very informed.

But every single person who I've talked to who has used LaTeX always has a love hate relationship with it and that they love what it's supposed to do. And then as soon as a table overflows or you have to debug a macro or you import two macros that interfere with each other or whatever, everything goes to hell. And the actual workflow that a lot of people require to get it working requires like, OK, I have to install 37 Perl packages and two Python packages and whatever, because I guess however these macros are written, it's-- there's just a lot of processing step. And one, it's a tool that people have used, but a lot of different people have used and it's been this whole like bazaar of ecosystem. So it's yeah, I don't know.

Like I said, it's something that's always struck me as a love hate relationship that people love the idea of it and then just paper cuts all day every day, which is part of the reason why I never picked it up, because I heard every time I heard something good about it, I heard just as many complaints about it. And I went, I guess my Markdown is not so bad. Like I can do Markdown render to HTML or like Markdown render to PDF. And I can live with that.

Amos Wenger: Yeah, I definitely have heard the same complaints. And it is definitely a part of its time. There's so many more fun tidbits around it. For example, Knuth didn't just invent TeX. He invented the concept of literate programming where you essentially write a document and then you can compile a document to source code because it extracts the code that's in there. So explain what you do and the pros, the explanation for humans is kind of the main thing, the main focus. And then the code is a product of that is something you can compile.

He originally wrote TeX in a language called WEB, W-E-B, all capital. And that produced programs in DEC PDP-10 Pascal. Maybe a CDC. So yes, it was released 47 years ago. It is it is old and extremely old in computer years.

James Munns: Yeah, but this is Typst. And so LaTeX is LaTeX. Like I said, I never learned it, but this is Typst, which is a much more modern program. It's written in Rust, which: always great. I love using tools that are written in Rust because it means that I have a chance in hell at debugging it in case something goes wrong or just, you know, supporting people doing that. And it's actually local for me because it comes out of TU Berlin, which is one of the big universities here. And it started as a side project from a student in 2019, maybe one or two people. I know there are two main developers who are working on it now. And since then, they've been making it basically their full time thing of building the command line version of it. Well, I'll get into the different forms that it comes in, but making the language itself and all the tooling that relates to it.

And so it's something that I've had on my radar because in Rust, everyone talks about like, "Hey, I just built this new thing in Rust." So I've seen it on the like, you know, various announcements. And I think a year or two ago, I kind of looked at bringing it up because I was like, well, maybe I do want to do more formal reports for customers and stuff like that. So maybe I'll pick it up. But I didn't have anything at hand, which means I dropped it. And then I think like six months ago, I tried again because I found... what I actually found was the NASA design and style manual. So someone just printed a PDF of it. And it's like the whole guide of how you do typesetting and logos and fonts and everything like that for NASA. And it was a really interesting style guide. And it was I was like, "Oh, I want to make pretty technical documents like that!" Like there was a very like cool style and inspiring style.

So I started picking up Typst about six months ago because I was like, OK, if I want pretty like laid out documents like that with images set and, you know, all that, then I'm going to need something more powerful than Word or Google Docs or whatever. And so I sort of picked it up, did the tutorials, went really fine, but then I didn't use it. Went back on vacation and didn't touch it. But I recently got back into it because my company, OneVariable is going to Embedded World and we need either a big poster or like one of those roll up banners for it. And I was like: well, how do you design a two by one meter banner? Because I don't know how I would approach that in any of the tools that I know how to use like Google Docs. I guess I could make a really big PowerPoint slide for it or something? I don't know. But it seemed like a perfect opportunity because we didn't need that much text and style because it's something you want to be able to see from like across the hall. And I was just like, I wonder if Typst can just handle a two meter by one meter document. Absolutely no problem with it.

I opened it up, did like Hello World and it rendered a giant PDF that looked perfectly fine at 300 PPI. And I was like, "Oh. Cool." And then I think that was on a Friday. And I just sat the rest of the evening and was like, "OK, how do I make a pretty gradient background?" and just messed around with it.

Has a nice web editor with live updating

James Munns: Because it has this really nice. What you see is what you get. Web editor. It's sort of like if you've ever seen any of those-- like HackMD is one of those websites where you've got Markdown in one pane and you've got like pretty rendered version on the right side. Typst has the same thing. So you've got all your code on the left. It's even got like syntax highlighting and it'll do autocomplete sort of like a LSP sort of thing.

So like it'll autocomplete things and you can hover over things and see it. And it caught me in exactly the right way where I just spent like the next six hours like, "OK, how do I make a title? Cool. How do I make a gradient? How do I make a shape on top of a gradient? How do I do stacking shapes?" and just it was fun to just play around with. So, I mean, it took having a very specific task to do. It was neat because I just had the editor open in one window and the docs open another and they have really good searchable docs. So I'm like: gradients. Type 'gradient' and it's like "function gradient: looks like this. Call it with these methods." And I was like, "Oh, cool!" And you just paste that in and you iterate on it.

So I have some very like some of the intermediate documents I made. I was like, OK, I am approaching the level of competency. So my documents now look like PowerPoint in the late 90s because it had like, you know: big text, rectangle behind it, gradient as a background. But over the course of like six hours, I went from like black text on white background to PowerPoint to something that I was like, OK, if we printed this, I wouldn't be ashamed to have it at my booth in like six hours, which was really, really neat.

Amos Wenger: So I wonder because you're talking about gradients and I'm trying to think of the whole pipeline because rendering to a bitmap so that you can see it in your browser is easy. I'm wondering what's what's the thing they standardize on? What's the lowest common denominator? And I think it has to be PostScript, right? Because that's what you send to printers.

James Munns: I have no idea.

Amos Wenger: And by printers, I mean both the physical device and the people whose job it is to print things because well, I don't know either. But I have an interesting tidbit that TeX was released initially in 1978. So 47 years ago, but PostScript was released in 1982, which was only 43 years ago. So that means that for four years, TeX was the thing. But PostScript wasn't. And how PostScript is not even the thing people actually use. They use PDF, which has PostScript inside, if I understand correctly. So it's it's fun to see.

James Munns: PostScript is great. PostScript is a Forth. Well, it's not exactly a Forth, but it's basically a Forth, which is great. And that was back in the day when printers were big, expensive machines and user terminals were dumb machines. So you would have basically a big, beefy computer that was running the printer. So instead of sending it rasterized images because your network wasn't fast enough and your computer wasn't fast enough to rasterize the image. So rasterizing is like turning it from vectors into like a bitmap like we think of. So you would just send PostScript, which is a program over the network to the computer that would then render in the giant RAM buffers that your printer had because the printer was the expensive piece of equipment.

Amos Wenger: Wait, do people do code golfing with PostScript? Like try to make a document in as few bytes as possible because you can write PostScript by hand.

James Munns: Got to be doing code golfing with with PostScript. I'm sure that's a thing. Yeah. So I don't know. I did look into a little bit how it works because it isn't just a Rust crate. It renders into sort of it's like any other compiler. It has like a million intermediate formats. And so it renders into some document model. It does the rendering and then you give it to the next step, which is either render to PDF or render to PNG or render to bitmap. And like I ended up using one-- spoiler for later-- that renders to like tiny-skia.

So it creates essentially just like a bitmap image where it gives me an array of pixels. So I'm sure it has some plug in for like, OK, we get to the intermediate representation, the IR with the document model and like things that have been applied and things that haven't. And then if you're going to PDF, you might apply those to create the PDF in one way or do a PNG or a bitmap. You might do it a different way. I haven't looked really under the hood, just enough to plug it into some other stuff. But yeah, the web editor is super nice. Like I said, if you're looking at the slides now, I have an actual picture. So Amanda probably has had this picture on the slides. If you're watching the video for the last five minutes, we've been talking instead of just the slide that says it has a nice GUI editor.

But you can see exactly the slides we're looking at right now, basically. And you can see the text over on the left and a preview of the previous slide on the right. And it looks really nice. It's about what you would expect from a visual editor.

Also as a CLI tool and a crate

James Munns: But because it's still usable in all the places that LaTeX was, it also comes as a command line interface tool. So you just can type 'typst compile input source file output PDF' or 'output PNG,' and it'll just spit that out. And because it's in Rust, it runs stupidly fast and it's fairly instant. So I've done things like just run watch exec on this. So every time I hit save on the file, it immediately regenerates the PDF, which you can do with LaTeX as well.

But it just is nice and snappy, like I said, because it's in Rust and I didn't mention it: the entire thing's open source. I don't think their web GUI tool is open source. I'm not sure. But like the core engine in the language itself are open source and now fairly recently published as a crate, which means you can just add it to your project. And I'll show you what I did with this, but it it works pretty simply as well. Like you give it the text. It has this concept of a world that you need to give it. And that's how you handle like loading plugins and fonts and things like that. So you can make a really minimal one that has like the one font you need and then you just do compile.

Amos Wenger: So I'm looking into their their pricing to see what the model is because it's always a question to ask. You find a tool, it's cool. The source is available, but especially now in 2025, you know, in the in the wake of all the business source available license. The BSL, I forget exactly the name, but there's a lot of software. The source is there, but it's not necessarily open source in the sense that you can't change it, you can't recompile, you can't distribute the changes. And also just you should be interested in the in the future of the software you use. And by you, I don't mean you, James, specifically, I mean everyone listening to this. Anyone using a tool. Exactly.

So I think they're going for an open core model where the whole technology, because you have to reassure people, people are going to write a lot of documents with this. So they have to know that even the company goes out of business, they still can do something with all that Typst source code. So that I think that's why it's open source and also because then they get free contributions. But then I think what they're trying to monetize is the whole collaborative editing experience on the web thing and cloud storage. And so cloud storage itself is not enough. It's hard to make a living just selling that. It's Google Docs level of collaboration where many people can have the same document open at the same time. You see people editing. They're using CRDT under the the hood to do that. So I think that's what they're going for. And I have no idea if they're profitable or not, but we'll ask them and get back to you. No, we won't. Yeah.

James Munns: I know they've also gotten some funding from like some European grants and stuff. And I think from their university, they're going through this process are always difficult. So I'm sure they're they're aiming to be profitable. I haven't talked to them. But yeah, it does make sense to me that like you have sort of this core engine that the really like tech focused people can just download the open source version and install it and run it.

But if you want it to be more applicable to more industries, having a really nice collaborative editor because you want this to be useful for teams that don't know source control. You want to be able to say, "I have 10 accounts for the people in my newsroom and we can collaborate on this and we can kick out a newspaper every day or every week," or something like that. So I definitely see that as being the like you want people to go and run with it in open source, but then monetize the ones where it's like, hey, if you're a business using this, if I've used this for more than a week, we'll probably start looking to that because they also accept sponsors. So I know they have a GitHub Sponsors. So if that's something that becomes a serious part of my workflow more than this slide deck and a couple of the other things that I'm going to show off, then chances are we'll probably--

Amos Wenger: So this slide deck is made with Typst.

James Munns: Yep.

Amos Wenger: But the other ones were not.

James Munns: No.

Amos Wenger: Just this one.

James Munns: The history of my slides: I was using Google Docs for a while. And then after some of your presentations where you showed Keynote handling some stuff better, I started using Keynote and I went, "Well, this is kind of nice." And then...

Amos Wenger: And then I switched back to Google Docs.

James Munns: You switched back to Google Docs, and now--

Amos Wenger: I'm a real influencer, I'm like, "Everyone's doing this new thing." And then I don't use it.

James Munns: And then now I'm switching over to Typst. So we'll see. I don't know if it's going to stick, but I aim to make it fairly similar. You probably can tell some difference between the two of them, but

Amos Wenger: I like the way it looks.

James Munns: I was just eyeballing the font sizes and stuff, but the vibes are the same.

Amos Wenger: I might follow you on this one. We'll see.

What does it look like?

James Munns: Nice. So what does the extra source code look like, especially for people who haven't like myself, haven't done programming in LaTeX or whatever. So I won't be able to contrast this, but... This is all of the source code necessary to render up to the first slide of this presentation. So a couple of things are going on. Function calls typically happen with a pound sign or a hashtag and then the name of a function, but you can also set essentially like the default values to all of these by doing hash set and then the name of the function. So I type hash set page and then I fill in a ton of parameters like the width of the page, the background fill, which is black, the margin that I want on the page. And then I can set the header here.

And so I can actually put a chunk of code in here that is going to be rendered as the header on all of my pages. The other main like syntax thing that you'll see here is when you see square brackets, that's saying here's a chunk of text, basically. It's like almost like a closure almost for text. So it's saying like the header parameter here would take some text or some content here. And if I want to have a multi-line thing where maybe I call other functions and set some stuff, I put those inside of square brackets, which will kind of encapsulate the thing that I'm running. So I can set alignment, I make a rectangle. And then in the rectangle, you can see one more piece of syntax. Most functions take content as their last argument. And you can either put it inside the parentheses of the function call, or you can put it as a square bracket immediately after the function call. And it becomes essentially the last parameter of that

Amos Wenger: That reminds me of Ruby blocks. Have you have you done Ruby? Do you have any Ruby experience?

James Munns: No, I haven't.

Amos Wenger: They have this weird thing that I've always hated, actually. I like when languages explicitly take closure. So I like Rust, I like some others. I don't know what Python does. But for Ruby, you do... I forget the exact syntax, but you can pass a block to a function. And it's not an argument. It's something else. And it has a weird syntax. And sure, it looks it feels nice to write, but it's-- I don't know. And this feels like the same thing. You can either-- but you can have it both ways here, because you can either pass it as an argument or use that kind of square bracket block syntax, right?

James Munns: Yeah, so if I-- you can also like save content off in a variable name. So if I was doing that, I might just pass it as the last argument to rectangle. Since I'm writing it in line, I'll probably put it after, and this is just saying so like rectangle when you give it content, it puts that content inside the rectangle. So this content that I'm putting there, I'm putting in a stack, which is basically like three things right next to each other. And it's the direction is left to right.

So you could have TTB, which is top to bottom or LTR or RTL or BTT, I guess, but I'm just saying, okay, I need the text, which is 24 point font that says "Self- Directed Research," a small rectangle, which just gives me some spacing between the text and the image, and then the image, and I'm telling it to scale that to the height, which is the height of the header 100%. So I just say, Okay, these are the three things that go in there. It's aligned right. And then these three things in this order.

Amos Wenger: So can I ask a question?

James Munns: Sure.

Amos Wenger: Everything makes sense to me in this code. But if you're listening to this podcast, you should be looking at this podcast, go on YouTube or the website to get the slides because it's really hard to just describe with sounds. But I'm looking at the slide that this produces. And I don't understand height 80% on the rectangle because you're making a header the width is 100%. I understand that... 80% of what because it's not--

James Munns: Yeah, it's 80% of the parent context. So of the height of the header, the rectangle that's inside of it is 80%. And then the stack of three items then exist within the bounds of that rectangle.

Amos Wenger: So there's a built in header thingy for pages?

James Munns: Yes. Yeah, I think there's a footer as well.

Amos Wenger: But okay, so there's a preset size for headers that are part of every page that you just stuff the rectangle in there.

James Munns: Yep, exactly.

Amos Wenger: I see.

James Munns: And I think they're-- I was actually looking at how to tweak that. I don't know, because I'm only like four days into this. So I don't know how you change the size of the header. But I know that it obeys the margins of the page. So that's why I have my margin set so wide is because I wanted the header to be over to the right

Amos Wenger: It's interesting, because it feels like you're building the page from first principles like you're making rectangles and then alignments and everything and... but also there's a hard coded header and footer. Like those concepts are so deeply embedded into how we think about documents that they're just there by default. It feels like something they would have added to the standard library instead of baked in. I don't know,

James Munns: Maybe! It's just how you... Yeah, I don't know. Fair disclaimer. If you're more experienced than me, you're probably like, "Oh, why are you doing it like that? You really are like- you're gluing rocks together at this point." So this is with like three days of actually working on this. But to the point where I'm-- I know just enough to be dangerous. So I was able to put together a whole slide deck in one sitting for this.

And then so we come out of the page setup, I set some other stuff like okay, I'm setting the align to center and horizon. So it's going to be aligned left to right center and also top to bottom center, and my text is going to be white with the font Departure Mono on this size. And then I just start typing text like "Typst" line break "is pretty neat." And we get that first slide where you get that over that. And then to make more slides, it's just hash page break parentheses because each slide is a page. So from here on, it's pretty much just text.

Amos Wenger: So horizon is just horizontal alignment?

James Munns: Yeah, it's horizontal center. It's like the up down version of center, if that makes sense.

Amos Wenger: Yeah, I built a GUI with egui recently doing immediate mode layout. And I had to think about that for one week straight. So I have no... I have no spoons left. I will trust you on that one.

James Munns: Okay. Yeah. So I mean, the rest of the slide, it's got some other cool things like it takes themes for... so I mean, like, what we're looking at now is a syntax highlighted block, which is just text in my actual slides. And you can import themes and it uses the dot TM theme format, which Sublime takes as well.

So I exported the the Monokai theme that I use in my Sublime text editor, imported into that. And then all of a sudden now my slides code formatting looks exactly like my text editor does and Amos won't yell at me anymore because I'm not taking screenshots of my text editor, which is great!

Amos Wenger: Yes and no. Yes. Yes, this--

Amanda Majorowicz: Amos was still yell at us. Don't worry.

James Munns: Yeah.

Amos Wenger: First of all, I don't yell. I use my inside voice. This is so much better. And I'm so happy for you, James. But it's still I don't like text made grammars, because they're just basically regular expressions. And this would have been the status quo still today if the Tree-sitter project hadn't been made. And I wish I could credit the people. Give me one hot second to look up the people behind Tree-sitter who's responsible for-- because like they wrote actual parsers, they wrote actual grammars. And now you can have actual good--

James Munns: They're also great because they're generated and they do one generated C file per language, which means some languages like Rust or Haskell and stuff end up generating like 90,000 line C files. And it makes the GitHub view of those files just fall over.

Amos Wenger: So the presentation, the initial presentation of Tree-sitter at GitHub Universe 2017 was by Max Brunsfeld. And I know we've interacted online before. Max, you're a real one. Thank you so much. James, try again. Do better.

James Munns: I got to look up. I don't know how Typst actually does code highlighting because it like it takes the TM theme option. That's what I don't actually know what the engine that uses to do that.

Amos Wenger: Right - maybe it's just taking the theme and not the actual grammars.

James Munns: Yeah, I don't know. But it is also written in Rust. So I'm sure if we wanted to glue in Tree-sitter onto it, then they could. Yeah, yeah.

Amos Wenger: It would be surprising if they didn't actually.

I've already started doing silly things with it

James Munns: Yeah. But like I said, I've learned just enough to become dangerous in it. And because... this is how my brain works, once I get a new tool, it's great. Because all these problems where I went, I don't know how to solve it. My brain immediately starts applying it to that, even if it's not the best fit tool. But I've never had a tool for building like UI designs before. Which means even on embedded systems and stuff, I've always just been, you know, bare minimum text and rectangles and stuff. My minimalism isn't some design principle. It's like this is literally literally the best I can do. And somehow it looks clean and nice most of the time. And that project for me was I'm building a little E-paper display clock for my house.

Amos Wenger: That's so cute!

James Munns: And this is built on all the PostStation stuff.

Amos Wenger: That's why the E-paper thingy you posted about was for.

James Munns: Yeah. So I have PostStation, which is usually set up so that you have like a Linux computer running the show and you've got like devices out on the edge. So what I do is once a minute on my laptop, it generates this image. It knows that it's a 400 by 300 pixel black and white picture. And I use Typst typesetting. And I actually fill in the time and whatever the values are.

Because in that screenshot before where I showed you building it as a crate, I can just use a Rust string and format in the numbers and words you see here and then take that formatted string, run it through Typst as a rendering engine, spit it out into a bitmap, compress it so I can put it over my wireless network and then send the compressed black and white image to my device, which reassembles it, shoves it onto the E-paper display and then puts the E-paper display back to sleep. So now I have this whole new world of user interfaces open to me because I've never learned HTML or CSS really. So now I have one tool in that field and I want to apply it to literally everything.

Amos Wenger: That's very fun. How do you deal with the, well, you don't have user supplied inputs. So you're not, this is not a security problem, but I'm just curious, do you just do formats or do you have something more fancy to do the templating and actually replace placeholders with the current time, et cetera?

James Munns: So right now I just use format. I know Typst itself, I'm not sure about it as a library, but as a language, it has some concept of being able to import documents. So you can import JSON content or Toml or YAML content and tell it to query a field in a JSON document or a Toml document. So I think the idea is that you're able to like glue that to API requests or, you know, other metadata. So there's probably a more clever way to do it. For me, the most expedient thing was format because it's just, I'm taking from chrono hour and minute and then using that, you know, two digit padded, put it here kind of thing. But it does as a language have some ability, like I think at the compilation stage, you can tell it to load this JSON file and pull this, you know, sort of like a JQ.

Amos Wenger: It does this concept of variables or environment or something like that.

James Munns: So there's definitely room for that. It probably depending on how I was driving it. If I'm pulling it as a crate, as a Rust library, I'd probably just have the Rust library do the smartness on that. If I was using it as a command line tool, it might be more amenable to scripting to say like pull it, I'll make sure that I've prepared data.json. And then I tell it to pull this information out of data.json or something in my bash script before I call the compile step.

Amos Wenger: This is very cool. By the way, I just checked on the official website and it is 'Typst.' You are correct. There is the IPA in the crates page, which everyone should do, honestly, just put the internet- international phonetic alphabet of your name so people know how to pronounce it.

James Munns: Nice. Yeah, this is where I'm at. I've been enjoying it heavily. We'll see in a couple more episodes if I'm still using this for this, but I am absolutely chuffed with it so far. And I wanted to share my excitement with you because I know we've talked a lot about layouting and how to get pretty content.

Amos Wenger: We have. And I have been doing some, like I said, I built an application with egui. And in my typical fashion, it's an article about something completely different, but I dedicate several pages to rendering a timestamp. So exactly like you have here. That's why my mind's thinking about that. You have 12 colon 34 and I'm looking at it and the colon is too wide. There's too much space on either end because you're just using a monospace font, which is the second best thing you can do. And you like this font.

But for me, I wanted to have consistent spacing and not have the numbers jump around when the time changes. But one is narrower than seven, which is narrower than eight, et cetera. So there's a yeah, there's an entire section in one of my articles just about rendering timestamps correctly with serif non-monospace fonts.

James Munns: And it made me think of that. I was just saying, I haven't gotten to messing with the kerning of anything yet, but I know it's possible.

Amos Wenger: I don't know if you maybe you pretend to like this font just because it's monospace and that makes everything so much simpler. You know, little column A, little column B, you know. But yeah, Typst is interesting for this because like, you mentioned tiny-skia. Skia is the- correct me if I'm wrong- I think it's the rendering library. Think of it as HTML5 canvas, but that's actually what backs that in Chromium. I believe there's two competing ones. There's like Cairo, the GTK thingy and Skia, I think is the one from Chromium.

And tiny-skia is a subset that drops a bunch of features that are hard to implement. Like it's an 80 20% thingy. They dropped like the 20% of features that were responsible for 80% of the code. And so it's all safe Rust and only slightly slower, something like that. And that gives you like, you can do text rendering, you can render gradients and various shapes. The round ones are the hard ones to render, but then you still have to do the typesetting. You still have to do the layout. And I'm assuming that's where Typst actually comes in. And it makes a ton of sense. I've been wondering how I can generate open graph previews for links from my websites with like title and the description and everything. I think Typst would be actually great for that.

James Munns: I think it'd be perfect for that. Yeah.

Amos Wenger: Because you can generate an SVG as well. Because some browsers support that. So you can you can serve both.

James Munns: Yeah, built in, they have export to PDF, SVG and PNG. And then, like I said, there are other crates that handle like the rendering step. So the one that I had is like, I forget what it's called, but it's-- it renders to a tiny-skia buffer, which means you just get an array of RGBA pixels. And you can do whatever you'd like with them. But-- you'd probably be good to go with just the command line application, which will dump out XML, PNG or whatever.

Amos Wenger: Oh, no, I would link against it. It's a Rust crate. I'm pulling it in. I'm-- I have 900 crates in my graph. Originally. Why do you think I split things by dynamic libraries? It's gotten out of control a long time ago. I think my previous strategy would have been to just make an SVG and then use an SVG rendering engine to do that. But the thing with the SVG is that it's really not made for typesetting and layouting and all that. It's much closer to something like PostScript than it is to something like, like Typst, I guess, because it's just put some text here, but--

James Munns: It's not all the way to rasterizing, but it's one step down of preprocessing or something.

Amos Wenger: There's so little you can do with formatting. Like if you place each individual character, then it's fine, right? Because it is able to pull a glyph from a font and put it somewhere. And then you can give it a font weight or something. But you can't really... in HTML, you can do a lot. You can do a lot of topography. I've never said that word out loud. Wow. But in SVG is very, very limited. And so, for example, the diagrams on my website right now are exported from draw.io, which is a diagramming software. And they used to be first converted to paths and then converted to SVG.

So I did like PDF paths and then SVG so that it would render exactly the same every where. So even letters were paths. But now I just take this, you export from draw.io, which only displays correctly on browsers because it uses foreign object to put HTML inside the SVG so that you get stuff like line wrapping and text elements because SVG doesn't do that. So that's how bad SVG is at this. I think it does, but you can't have bold tags and stuff. Anyway, Typst is so much better for this. I'm going to use this. Thank you, James. I'm excited about it.

Amanda Majorowicz: I feel like there were two references where I was thinking about Aladdin.

Amos Wenger: Which ones? We're keeping that in.

Amanda Majorowicz: Yeah. When you're like, "It's a whole new world." And I was like (singing) "A whole new world!"

James Munns: "Don't you dare close your eyes."

Amanda Majorowicz: Exactly.

Amos Wenger: What's funny is that you can sing and it's going to be on the record, but you can cut it out in the edit and you can just have us be like flustered because we hear the whole new world. We're trying to be serious.

Amanda Majorowicz: Yeah, exactly. And then the other one was a little bit of column A and a little bit of column B.

James Munns: Oh, yeah.

Amanda Majorowicz: From when the genie-- yeah. The genie song. Anyways, thank you.

Amos Wenger: I have to say that flustered doesn't necessarily mean anything sexual. No, it's just "confused, befuddled in a state of panic." That's just my greatest fear as a non-native speaker. Flustered. I've only ever used flustered in a context where you find someone a little attractive or whatever But no, it just means confused. So I was correct.

Episode Sponsor

This episode is sponsored by Depot: the build acceleration platform that's on a mission to make all builds near instant. If you're tired of watching your builds in GitHub Actions crawl like the modern-day equivalent of paint drying, give Depot's GitHub Actions runners a try. They’re up to 10x faster, with unlimited concurrency, faster caching, support for Linux, macOS, and Windows, and they plug right into other Depot optimizations like accelerated container image builds and remote caching for Bazel, Turborepo, Gradle, and more.

Depot was built by developers who were tired of wasting time waiting on builds instead of shipping. It's made for teams that want to move faster and stay focused on what actually matters.

That’s why companies like PostHog use Depot to cut build times from over 3 hours to just 3 minutes, saving tens of thousands of build hours every week.

Start your free 7-day trial at depot.dev and let them know we sent you.