Hacker News new | ask | show | jobs
Implementation-free TypeScript functions with Imaginary Programming (imaginary.dev)
2 points by aickin 1192 days ago
1 comments

We've recently released a new library that implements a concept called "Imaginary Programming" for TypeScript. The idea is that you can incorporate Large Language Models (LLMs) like GPT into more traditional webapps by simply defining a function prototype with a good comment but without an implementation. Our library then finds those functions in your code and replaces them with a runtime call to GPT asking GPT what such a function would return for particular arguments if the function existed.

It's sort of a mind-bending paradigm, but I think it's really delightful to use from a programmer's perspective. Just write out the function name, the arguments that the function takes in, the JSON-compatible type it returns, and a descriptive comment saying what the function should do, and voila. You have yourself a function you can call, and it actually works.

To be clear, this is not the same thing as Github Copilot. Copilot is great at writing code for you, but Imaginary Programming doesn't write code. Rather, Imaginary Programming uses GPT as the runtime for your function. This means you can solve problems that you never would be able to code normally, answering questions like: "How angry is this customer email?", "What are all the proper names in this email?", or "Come up with a good name for this song playlist.". Copilot lets you code the same things faster; Imaginary Programming lets you do things that were previously impossible to code in TypeScript/JavaScript.

I'm interested in seeing what developers make of this, so I'd love for folks to try it out, either by installing the library or using our online playground: https://playground.imaginary.dev/ . Any and all feedback is very much appreciated!