SPICE. You're describing SPICE. :)
One project that comes to mind for high-level programming style circuits-as-code:
https://github.com/atopile/atopile
Show HN: https://news.ycombinator.com/item?id=39263854 More recent HN thread: https://news.ycombinator.com/item?id=44548449
AIUI the best frontend is kicad, though I never really tried that, I just wrote the text files by hand.