I prefer to use Zod or JSON Schema as the source of truth. Then I use QuickType [1] in the build process to generate code in different languages. This lets me share data structures. I mostly do this in Tauri apps to keep the same data shape in TypeScript and Rust. I also use it to define protocols, like for REST APIs.
Here are the advantages of this approach compared to using guts lib:
- I get validation with clear error messages.
- It supports many languages out of the box.
- I don’t need to maintain a custom library.
- JSON Schema is well supported in LLMs (for example, with structured output or vibe coding).
I’m more focused on the situation from Musk’s point of view, not yours. Maybe your view is less controversial. But I don’t think Musk sees China and Russia as failed states. He’s said many positive things about both countries.
I share Durov’s disappointment about where the internet is heading.
But I think it’s hypocritical to talk about freedom of speech issues in Western Europe while ignoring similar or worse restrictions in China, Russia, or Dubai, where he lives.
It’s similar to Musk’s approach — when Twitter is shut down in Brazil, it’s a freedom of speech violation, but having a Tesla factory in China suddenly makes that problem disappear there.
Here are the advantages of this approach compared to using guts lib: - I get validation with clear error messages. - It supports many languages out of the box. - I don’t need to maintain a custom library. - JSON Schema is well supported in LLMs (for example, with structured output or vibe coding).
[1] https://quicktype.io/