I've used Satimage's Smile app to make vector diagrams (for technical illustrations, laser-cutting patterns, etc) via AppleScript augmented with drawing commands. It's like the opposite of PaintCode, which turns drawings into code. (I'm a mathematician, not an artist, so I want/need to describe images with formulas and equations.)
Sadly, macOS Mojave broke OSAX functionality, making Smile completely unusable.[*] Besides, the oh-so-rudimentary Smile UI can be pretty frustrating. It's time to seek an alternative.
The "code" doesn't have to be AppleScript. I've seen a couple of open-source (usually Qt) apps for editing TikZ, a programmatic graphics language. However, these are geared towards tweaking TikZ code for import into a LaTeX documents and whatnot; I'm looking for something more of a stand-alone document editor, capable of exporting to PDF or EPS directly. (But if there's a really good Mac-like TikZ editor, I'd consider it.)
[*] There's apparently an AppleScript workaround using an an auxiliary SatimageOSAX app, but I haven't gotten it to work with Smile. Besides, it's only a patch, doomed to break eventually.