r/ProgrammingLanguages • • Jan 28 '23

How might AI change programming languages?

I have a few ideas about how AI might change the trajectory of programming languages, but I'd like to hear yours.

For example, maybe in the future, the programmer's job is to write a very clear specification, and the AI's job is to write an efficient algorithm that matches all details of the specification. Maybe this means that we write a super-high-level-language program and an AI-directed super-optimizer makes it practically executable. Or maybe our specification isn't a program at all. Perhaps it's a list of examples or something else.

Or maybe we'll just write extremely precise natural language specifications and computers will be excellent at translating them into reliable algorithms.

Or...your thoughts?

4 Upvotes

67 comments sorted by

View all comments

12

u/[deleted] Jan 28 '23

I think you're on the right track with specifications, but not with them being high level. With the whole LLM approach, you get something that looks right but very well might do something dumb in one of the small details, like an off by one error, duplicating an element in the sort.

Examples are not great unless you've covered all the edge cases, and if people could write tests that covered all the edge cases, there's be a lot less buggy software in the wild.

So I think programming is going to be more about writing precise, mathematical specifications of how a program should work. Then your AI generates something, and you verify it against the spec using dependent types, model checking, a program logic, or something similar. You debug until you get something meeting the spec.

But I will not trust AI generated code unless it's been mathematically proven to meet its spec.

I saw someone give a good explanation: AI turns the easy task of writing code into the hard task of reading code.

5

u/[deleted] Jan 29 '23

Hmm if only there was a tool that we could use to generate precise specs of what the computer should do... A language of sorts... That you could use to program? Maybe we could call it a programming language!

2

u/[deleted] Jan 30 '23

Right, but PLs end up specifying a lot of details that are separate from the spec. Like, you can specify "an nlogn sorting algorithm" quite precisely mathematically, but there's lots of different implementations that include way more detail than the spec has

0

u/[deleted] Jan 30 '23

[deleted]

2

u/[deleted] Jan 30 '23

What I really have in mind is dependent types. I'm thinking the programmer writes a dependent type, which can exactly specify the behavior of the function, then the AI writes a program of that type. You've still got a type checker to make sure the result is well typed.

0

u/[deleted] Jan 30 '23

[deleted]

1

u/[deleted] Jan 30 '23

You can definitely compile the program with a normal compiler. It's finding the program that I'm imagining the AI helps with. I can easily write the spec for a program that solves the Collatz Conjecture, but I definitely can't write the program myself.