6 ms·
Swift at Apple: Migrating the TrueType hinting interpreter
- ks2048 4mo agoSo, hinting only takes place at low resolutions, I believe. How often is it used, eg viewing “typical” PDFs on “typical” screens?
- dcrazy 4mo agoThere are fonts that rely on hinting for correct shaping at all sizes: https://xoxo.zone/@numist/116716601962175503 https://xoxo.zone/@numist/116716601962175503
- pjmlp 4mo agoDuring the State of Platform keynote, on the subject of Swift adoption across macOS, several examples were given, not only TrueType engine. RIS is happening across all OS levels, if the keynote is to be believed.
- DASD 4mo agoCurious the direction of Webkit as there was a nebulous mention of select portions being rewritten from C++ to Swift. And yet, the new ECMAScript module (ESM) loader for Safari 27 is implemented in C++ (https://webkit.org/blog/17967/news-from-wwdc26-webkit-in-safari-27-beta/ https://webkit.org/blog/17967/news-from-wwdc26-webkit-in-saf...).
- pjmlp 4mo agoNo idea, maybe the private parts of the code, Safari isn't open source, or is coming later. In any case I would have liked to have more info during the deep dive sessions. As it is, Meet with Apple on security (a 5h long event) had much more information.
- hirvi74 4mo agoWhat does RIS stand for?
- gyomu 4mo agoRewrite in Swift
- willXare 4mo ago[flagged]
- cwillu 4mo agos/better/blurrier/
- thewebguyd 4mo agoCareful, you’ll bring out all the “but it’s true to print media” people.
- steve1977 4mo agoLife without retina displays is possible, but pointless.
- MBCook 4mo agoThey’ve been doing it for years. I don’t remember how we first knew, but I know they’ve been using Swift in kernels for at least some of the other chips like the Secure Enclave or whatever. I’m not sure exactly which. I assume it’s some of the code and not all. But it’s not new in the abstract. That said I don’t think I’ve heard of it in the kernel of MacOS on the main processor. That may be new. Either way this is certainly the most concrete announcement I remember them ever giving on this stuff.
- commandersaki 4mo agoI know internally they use an IPsec implementation written by Rust (I think in the iCloud infra). Heard this from an ex-Apple engineer Ben (forgot his last name) that did a wonderful presentation of Rust from first principles. He said that it was hard to get people in on Rust when most would argue for Swift. Edit: This is the guy: https://rustcurious.com/course/ https://rustcurious.com/course/
- pjmlp 4mo agoSome stuff was discussed at Meet with Apple security event a few months ago, and the talks on FoundationDB rewrite, or why Swift Embedded subset came to be. However I miss them actually having had one of those 15 - 30m WWDC sessions, where they could have gone a bit deeper into the keynote examples
- JimDabell 4mo agoAlexandre Colucci has published a series of articles analysing the use of Swift in iOS and macOS by Apple here: https://blog.timac.org/categories/reverse-engineering/ https://blog.timac.org/categories/reverse-engineering/ And frequently discussed on Hacker News: https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=apple%27s%20use%20of%20swift&sort=byPopularity&type=story https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...
- pjmlp 4mo agoThanks!
- troupo 4mo agoI think these are the types of things Apple should've focused on instead of half-heartedly barging ahead with SwiftUI and breaking the language in the process
- saagarjha 4mo agoI mean they’re doing both
- saagarjha 4mo agoInteresting that this is published under the MIT, rather than Apple’s more favorite Apache 2, license
- JumpCrisscross 4mo agoWhy is it interesting?
- drob518 4mo agoPresumably because MIT is even more permissive and it’s a change in Apple’s behavior.
- zdw 4mo agoGiven the age of TrueType, wouldn't nearly all patents be expired already? Apache2's license I've heard described as mutually-assured-patent-destruction - if you use the code and make a patent claim, your rights to use the code go away. So Apache2 offers little benefit here, and MIT may get it into more hands?
- favorited 4mo agoSome corporations prefer Apache 2.0 for projects where they'll be accepting contributions, because it includes patent protection and retaliation clauses. In case like this, where source code is just being published for reference and contributions aren't accepted, those risks don't exist.
- mrpippy 4mo agoThe author discussed this a bit on Mastodon as well: https://xoxo.zone/@numist/116716469017975106 https://xoxo.zone/@numist/116716469017975106
- weinzierl 4mo agoBack in 2023 there was talks about Microsoft rewriting the font stuff in Rust for similar reasons Apple is now doing the Swift move. I'm not sure what became of it and if it ever shipped. If anyone knows I'd be curious.
- DASD 4mo agoRussinovitch (Azure's CTO/CISO) gave a speech at RustConf 2025 and mentions it(DirectWriteCore) took 2 engineers 6 months resulting in 154K LOC and 5-15 percent performance increase for font shaping. https://www.youtube.com/watch?v=uDtMuS7BExE&list=PL2b0df3jKKiRFEuVNk76ufXagOgEJ9sBZ&index=4 https://www.youtube.com/watch?v=uDtMuS7BExE&list=PL2b0df3jKK...
- LoganDark 4mo agoI'm surprised the code has visible LLM smells. Though, I shouldn't be surprised. I hope the important bits are still human-controlled (and the same for Apple's many operating systems that absolutely deserve to remain stable and understood).
- airspeedswift 4mo agoI assure you, every inch of the interpreter code has been stared at by humans, a lot. TBH even the assembly generated by it has.
- dgellow 4mo agoFrom what I got Apple is using claude code A LOT internally
- wahnfrieden 4mo agoYes they are using Claude Code - not the Xcode agents. It worries me. I hope Codex adoption picks up there.
- andrekandre 4mo agothats a shame if true, they really should be dog-fooding that horrible agent ui in xcode to bring it up to a usable state
- airstrike 4mo agoAs much as I enjoyed Swift, one can only wonder what the world would look like if they had gone with Rust as their default language instead.
- jadengeller 4mo agoModern Swift borrows a lot from Rust! And it also has its own benefits, both ergonomic and also supporting eg generic in dynamic libraries
- airstrike 4mo agoThese days I mainly write Rust but I did write a semi complex iOS app and enjoyed Swift. I just didn't love how slow the type checker was and how it got lost. I recall having to break things into smaller bits to help the compiler, and there were some oddities about the language. The gap between the two languages is quite small, it just makes me wish Apple was also all-in on Rust
- DenisChetwynd 4mo agomaybe so on the surface, but it remains quite massive underneath; these languages are fundamentally different and target entirely different use cases
- airstrike 4mo agoI'm not sure Rust has one specific use case as its main goal, despite being immediately suitable for systems programming. I use it for making user-facing desktop applications, to name one example.
- MBCook 4mo agoIn the last year they’ve added improvements to the type checker to speed it up, those would have been released now. They have further and much more significant changes that I think might have recently landed in the development version. That should make an even bigger difference. But it’s not in a released version yet. And yes, none of us like that one part of Swift. Especially the DRASTIC difference compared to objective-C which really only checked syntax and little else. It’s still probably my favorite language right now though I don’t get to write in it much.
- raphlinus 4mo agoWelcome to the club of doing high performance text in a memory safe language!
- masiulis 4mo agoThere are dozens of us! Dozens! Vello has been a big inspiration and source of knowledge for my own webgpu text renderer, thank you for that!
- WalterGR 4mo ago> high performance text Just strings or rendering strings? If the latter, who are the other members of the club?
- raphlinus 4mo agoYeah, probably should have made a more substantive comment. I'm mostly thinking of the trio of Skrifa, Harfrust, and Parley, but there is other open source Rust work that qualifies as well. There's also, very relevantly, the DWriteCore work from Microsoft. My understanding is that there's been some talk of open sourcing that, but it's still proprietary. There are other things that count as high performance text in memory safe languages, for example implementations in Go, but in general those are not a good candidate to replace C and C++ in environments like operating systems and browsers.
- WalterGR 4mo agoThanks. Skrifa - Skia in Rust. https://github.com/googlefonts/fontations/tree/main/skrifa https://github.com/googlefonts/fontations/tree/main/skrifa , https://developer.chrome.com/blog/memory-safety-fonts https://developer.chrome.com/blog/memory-safety-fonts Harfrust - HarfBuzz in Rust. https://github.com/harfbuzz/harfrust https://github.com/harfbuzz/harfrust , https://github.com/googlefonts/oxidize https://github.com/googlefonts/oxidize Parley - text layout in Rust. https://github.com/linebender/parley https://github.com/linebender/parley DWriteCore - the Windows App SDK implementation of DirectWrite. https://learn.microsoft.com/en-us/windows/win32/directwrite/dwritecore-overview https://learn.microsoft.com/en-us/windows/win32/directwrite/...
- wg0 4mo agoNo mention of AI? Hand written code?
- numist 4mo agoThere's mention at the end. The models (and Swift itself!) have evolved a lot since this project started, so the early code is largely hand-rolled and the later changes were mostly authored by centaurs (to steal a term from chess). But I personally reviewed every line that shipped and was absolutely insufferable about testing.
- AndriyKunitsyn 4mo agoWhat's funny is from 2023 (I think), macOS just draws the UI unhinted. You have a 1080p display and you don't want to see the letters in the UI blurred to death? Tough luck, 1080p is incompatible with macOS, everybody needs "retina", and nobody cares that Windows and all Linux DEs look on 1080p just fine. It looks like this hinter will be used only in rendering PDFs, because that's where they test the performance.
- nomel 4mo agoMy last 1080p monitor was around 20 years ago. I have trouble comprehending people still use them regularly.
- AndriyKunitsyn 4mo agoPeople also use usable mice instead of touchpads, and they put the "ctrl" key where Apple thinks a useless "fn" should be. All kinds of things happen outside Apple world. To me, it's more about what I'm used to. I have a perfectly fine several years-old monitor, so why should I throw it away?
- nomel 4mo agoI'm a PC user with a work MacBook. I was talking about my PC.
- afavour 4mo agoA very quick search yielded Dell selling 1080p laptops today: https://www.dell.com/en-us/shop/dell-laptops/dell-15-laptop/spd/dell-dc15250-laptop https://www.dell.com/en-us/shop/dell-laptops/dell-15-laptop/... It is very, very common. Just not in the Mac world.
- kbolino 4mo agoIt's also the corporate standard for generic cubicle workstation monitors, though it's unusual to find a Mac in such a place anyway.
- jacquesgt 4mo agoIf you want to help improve the security of OS software through the magic of memory safe languages, the team that did this work is hiring: https://jobs.apple.com/en-us/search?search=Spear&sort=relevance&location=united-states-USA https://jobs.apple.com/en-us/search?search=Spear&sort=releva... Knowledge of Swift not required. If you know your way around OS software, can reason about the security of the code you write, and are excited about writing exhaustively tested software, we’d love to talk to you. We’re hiring for roles in kernel/systems and userspace. Like the Platforms SOTU mentioned, we’re using Swift at all layers of the software stack now. https://www.youtube.com/live/yl2jsIoMfDU https://www.youtube.com/live/yl2jsIoMfDU I had the pleasure of leading the effort to ship Swift in the Secure Enclave back in 2022. Now I have multiple teams working on accelerating the transition to memory safe languages. We’re showing that with good planning and a relentless focus on testing, we can improve security, performance, and functionality. And we get to have a ton of fun working with some amazing colleagues. It’s the most enjoyable and impactful work I’ve ever done in my career.
- byproxy 4mo agoAny resources you'd recommend for learning about reasoning about the security of code?
- rinon 4mo agoFor low-level system security, I'm a fan of https://llsoftsec.github.io/llsoftsecbook/LLSoftSecBook.pdf https://llsoftsec.github.io/llsoftsecbook/LLSoftSecBook.pdf as an overview for any systems developer, not just compiler devs. It might not be the most approachable, but it's got great info on everything memory corruption.
- rfc3092 4mo agoHow do I apply? Historically jobs.apple.com is a black hole unless you know people.
- musicale 4mo agoApple (like most large tech companies) is indeed a resumé black hole, and knowing people helps, so definitely network if possible. However, applying to the right position, with a good resumé that highlights experience/skills/projects/open source contributions/education/etc. that are directly related to the position, also matters. I am aware of several people who simply applied online and got interviews. I may be wrong about this, but I don't think Apple bans you from applying to multiple positions within the same year the way some companies do. There also seems to be a decent pipeline for new graduates (though I think highlighting relevant academic, research, and open source projects can still help.) Internships can also be a path if you are currently in school. I don't know if Apple recruits on linkedin, but that might also be an option. Of course connecting right here on HN seems like a great idea as well.
- comex 4mo agoBeware: As of a few months ago, when I tried to use the lifetime features shown off in this post, I ran into constant compiler crashes with very simple programs, until I gave up and wrote off the features as unusable. This happened on both stable and nightly compilers. I guess they work well enough for this TrueType interpreter, but I suspect they’re using a narrow subset of what the features are supposed to support. Or maybe things have been fixed very recently. That said, I’m looking forward to using Swift lifetimes once they actually work!
- stephencanon 4mo agoThe work discussed in this post shipped in the OS last year (fall 2025), so nothing here is dependent on very recent changes.
- monster_truck 4mo agoAverage swift experience
- KolmogorovComp 4mo ago> Operations like filter and map allocate memory, but that allocation is only necessary if the value escapes. The Swift standard library provides .lazy.map and .lazy.filter, but they don’t work in every case. For logic that only iterates over the filter or map, it’s much more efficient to loop with continue (or use for … in … where) and transform elements into local variables as necessary. It does feel like a compiler/optimiser failure to have to rewrite those cases.
- Altern4tiveAcc 4mo agoI've always wondered if JS engines could rewrite those array functions at compile time, like this: https://github.com/SomeRanDev/Haxe-MagicArrayTools https://github.com/SomeRanDev/Haxe-MagicArrayTools Though, it probably wouldn't work if user code modified the Array prototype.
- leecommamichael 4mo agoIt isn't. You'd need full lifetime analysis as part of the compiler to even decide whether you _could_ skip the allocation, and even then it's 100% up to the circumstance and actual lifetime of the data to say whether it can be, e.g. stack-allocated to avoid placing it somewhere less localized.
- yyyk 4mo ago"we used a fuzzer to minimize a corpus of 10 million PDF files down to 4,200 without any loss of code coverage" Did they need a fuzzer for that? They could've render them all and see what's exercised?
- dpark 4mo ago> By the end of the project, we wrote nearly four times as many lines of test code as we wrote for the Swift interpreter itself. This is the most interesting bit to me. Engineers consistently underestimate the amount of effort that testing demands for projects that need truly high quality, it’s nice to see this shared.