Also being able to remove all the dispatch and stack-allocate everything. Haskell would probably do a good job of that too but in python or js, even with codegen, it would be hard to avoid heap allocation. The simple examples here might fall to escape analysis, but in production code the intermediate Blob values typically cross a lot of function boundaries.
Other languages with macros can do this sort of thing but one then needs to “derive blob” or something like that.
In Haskell one could probably do it with Generic (ie the compiler generates a data representation of the type; you write a function to go from this representation to your deserialisation function; and then the compiler does a crazy amount of inlining)
An alternative way to do this in an object oriented language is with a different metaclass that does the appropriate dereferencing. But this risks being slow if not compiled well