How we built a codegen solution for SDKs to create humanlike code
1–5 of 5 posts
Re: How we built a codegen solution for SDKs to create humanlike code
#2Re: How we built a codegen solution for SDKs to create humanlike code
#3We recently built our own codegen solution to automatically create, maintain, and document our backend SDKs so that we didn’t have to compromise on either quality or maintenance burden. Also see part one of the series where we discuss how compiler theory inspired our solution: https://stytch.com/blog/what-does-compiler-theory-have-to-do...
We actually used to do something similar, but were able to remove tons of code and move that to the user layer so they can control, because each language has its own patterns and snowflakes. Basically lift the DSLs, transforms, and templates out of the implementation. CUE also provides some really powerful building blocks for schemas, aggregations, and defaults, while also reducing how much we have to write as humans.
Re: How we built a codegen solution for SDKs to create humanlike code
#4We recently built our own codegen solution to automatically create, maintain, and document our backend SDKs so that we didn’t have to compromise on either quality or maintenance burden. Also see part one of the series where we discuss how compiler theory inspired our solution: https://stytch.com/blog/what-does-compiler-theory-have-to-do...
Interesting take on code gen. We went the way of declarative -> text/template (Go vs jinja in python), but use CUE as the input. Here, we can do many of the things that you implement in the translations and hybrid method. We actually used to do something similar, but were able to remove tons of code and move that to the user layer so they can control, because each language has its own patterns and snowflakes. Basical…
Re: How we built a codegen solution for SDKs to create humanlike code
#5Earlier quoted context omitted.
Interesting take on code gen. We went the way of declarative -> text/template (Go vs jinja in python), but use CUE as the input. Here, we can do many of the things that you implement in the translations and hybrid method. We actually used to do something similar, but were able to remove tons of code and move that to the user layer so they can control, because each language has its own patterns and snowflakes. Basical…
Thanks for sharing! We had a slightly different cost/benefit analysis for our use case with fairly straightforward APIs but know that might not be the same for everyone.
If you already have a different source of truth (like protobufs), then other methods will make more sense. We think CUE is a great language for the source of truth as it has integrations with all the common config formats as well as tech like protobufs and OpenAPI schemas. It's also much nicer to express large amounts of declarative code in.
Anyway, thanks for sharing as well! I found your perspective quite interesting too. I have some desire to see something like JSX for our CUE+templates, but that is still quite unclear and a long-term vision