News for hackers. Stuff that matters.
Re:JavaScript Macros in Bun by love2read on Saturday July 01, 2023 @12:04AM (#36546444)
Out of curiosity, what are you trying to make?
Re:JavaScript Macros in Bun by wolfgang42 on Saturday July 01, 2023 @12:32AM (#36546607)
I’ve run into this in a few different contexts, which usually boil down to “I have a schema, and I’d like to automatically write code that uses it.” (Think things like API definitions, database models, binary serialization formats, and the like.) Trying to do it at runtime with something like io-ts results in a lot of indirection that’s hard to follow, and writing the files by hand results in silly mistakes because it’s tedious to get all the details right. Generating the files and checking them in gives you the best of both worlds: the readability of hand-written code, with the accuracy of automation. But I’ve never been able to get the generator itself as nice as I’d like; string templating mostly works adequately, but as the parent says it lacks integration with the regular toolchains.