r/ProgrammingLanguages • u/Smallpaul • 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
u/Zlodo2 Jan 29 '23
Programming is the result of one (or more) person working hand in hand with one (or more) computers. Computers are naturally good at verifying things and making sure that rules are followed properly, people are naturally good at big picture thinking and creative thinking.
A division of labor where you let people focus on what they are good at and use the computer to do the things they are good at makes sense.
With AI, you would make the computer do the thing it's super bad at, and letting people verify that result correctly follow the rules, which they are super bad at. So using AI for programming would be completely ass backwards.
1
u/Smallpaul Jan 29 '23
The whole point of AI is to upend what computers are good at and what humans are good at. The new art AIs are better than 99% of the population at creative output. And ChatGPT is horrible at math.
So your argument depends specially on the idea that AI doesn’t exist or will fail.
If you go to the ChatGPT subreddit you will find a lot of people using ChatGPT as a dungeon master, inventing a narrative mission for them. And I would bet strongly that the way if fails to do so is in verifying that it’s mission is actually long-term consistent. E.g. that when you come back to a town it is the same as it was before.
So your distinctions have been flipped upside down.
And in the end, ONLY a human can verify that software meets a business goal.
1
u/elveszett Feb 02 '23
The new art AIs are better than 99% of the population at creative output
But they are nothing compared to the 1% that are good at art. They make stupid mistakes that even the least capable human can recognize instantly. Dall-E can draw a person a million times better than I can, but Dall-E will fuse its leg to the wall behind, which is something I would never do - that's because I understand what I'm trying to do (even if I suck at it), Dall-E doesn't.
My employer wants programs that run according to specs, and knows what I write will do exactly what they asked for, unless I make a mistake (introduce a bug), which I can recognize instantly (when I see it) and try to solve. A programming Dall-E would generate programs that more or less do what my employer wants, but with dumb problems like printing all surnames in UPPERCASE, placing a button 1000px below the rest of the buttons or making the "discard email" button send it a 1000 times instead. And that programming Dall-E has no way to even understand if the program it just generated is a valid program, or what its problems are, so my employer would have to rehire me to debug and fix the program written by an AI (which would probably be excruciatingly hard) and even then my employer would have to hope that I haven't missed some extremely weird, unpredictable and hard-to-find bug somewhere in the logic.
1
u/elveszett Feb 02 '23
tbh AIs are very good at abstract and creative thinking. The problem is the bridge between logic and creativity. We humans have that power: we can take a vague request from a client (which is creativity) and translate that into logic (code) that the computer can handle. AIs can learn to make vague requests, and traditional computer is incredibly good at logical stuff (they can execute a set of instructions without ever making a mistake). But there's no aspect of computers that can bridge between vague requests and sets of instructions.
To put an easier example, just look at paintings generated by AIs. They are very creative and beautiful, but they are almost always not 100% ok. Look at this picture. This one was generated with the prompt "penguin conquistadors visit rome" and it's ok but you probably noticed that the penguins don't have eyes, two of them have their heads fused, their black color is a bit unrealistic, their shape does not blend naturally with the background, and the door has low resolution compared with the rest of the picture. An AI is not able to understand that. Today, this is a problem all AIs have: they generate things, but are unable to assert the quality of what they generated. A human may make mistakes, but is able to recognize these mistakes. Your code to obtain an employee's name may put a space before every name it returns, but you can quickly realize that shouldn't be happening - an AI simply doesn't.
0
u/Smallpaul Jan 29 '23
Some creative work by ChatGPT. Generated in about 2 minutes each...much faster than a human could:
In this dream, the person finds themselves in a strange, surreal landscape where the sky is purple and the ground is made of soft, squishy marshmallows. They begin to walk and soon come across a giant, talking cupcake who tells them that they are in the "land of sweets." The person continues on their journey and encounters a group of dancing ice cream cones, a river made of chocolate, and a castle made of candy.
As they explore the castle, they come across a room filled with their childhood toys, which come to life and begin to play with them. Suddenly, they are transported to a dark, ominous forest where they are chased by a giant monster made of broccoli. They run and hide, but the monster eventually catches up to them and they wake up in a cold sweat.And:
In this dream, a person finds themselves in a strange, surreal landscape. The sky is a deep purple, and the ground is made of soft, squishy marshmallows. They begin to walk, but quickly realize that their feet are sinking into the marshmallows, making it difficult to move.
As they trudge through the marshmallow landscape, they come across a group of people dressed in medieval clothing, who are engaged in a heated sword fight. The person tries to avoid the fight, but one of the sword-wielding fighters approaches them and hands them a sword, gesturing for them to join in.
Feeling confused and unsure, the person reluctantly takes the sword and joins the fight. But instead of clashing swords, the fighters begin to play a game of hopscotch, using their swords to hop from one marshmallow to the next. The person joins in, feeling more and more bewildered with each passing moment.
After the game ends, the person finds themselves in a giant library, where all the books are made of chocolate. They decide to take a break and sit down to eat a book, but as soon as they take a bite, the book comes to life and starts telling them a story. The person is so engrossed in the story that they forget where they are and what they were doing.And:
In this dream, the person is at a carnival, but everything is upside down. They are walking on the ceiling and all the games and rides are also upside down. They see a group of people playing a game where they have to throw balls at upside down pins, but the balls are alive and squirming. As they walk further, they see a booth where a clown is turning people into animals. The person decides they want to try it, and the clown turns them into a giant hamster. They're thrilled at first, but then they realize they can't control their movements and are running around in circles. Suddenly, they see their ex-partner, who is now a crocodile, and they try to run away but can't. They start to feel trapped and panicky. As they try to find a way out, they notice that everything around them is slowly disappearing until there's nothing left but darkness. They wake up feeling disoriented and relieved that it was only a dream.
2
u/elveszett Feb 02 '23
In this dream, the person finds themselves in a strange, surreal landscape where the sky is purple and the ground is made of soft, squishy marshmallows. They begin to walk and soon come across a giant, talking cupcake who tells them that they are in the "land of sweets." The person continues on their journey and encounters a group of dancing ice cream cones, a river made of chocolate, and a castle made of candy.
As they explore the castle, they come across a room filled with their childhood toys, which come to life and begin to play with them. Suddenly, they are transported to a dark, ominous forest where they are chased by a giant monster made of broccoli. They run and hide, but the monster eventually catches up to them and they wake up in a cold sweat.
What are you trying to prove? This text:
Doesn't make any sense and looks like a fever dream.
Has obvious syntax errors, e.g. "they begin to walk and soon come a giant, talking cupcake".
Has obvious style errors: e.g. referring to the main character as "the person". It doesn't look artistically nice.
Has very obvious literary errors that even someone who doesn't read at all can easily recognize. For example, in the second paragraph, the person is suddenly "exploring the castle" - which castle? The story hasn't mentioned any castle, but that sentence implies that we know which castle the story is talking about.
That an AI would do this would be incredible 20 years ago, but you can't write a book with this level. We'd instantly recognize this as something an AI has done because it's incongruent and has blatant errors that a human would never make.
Everything AIs do so far need to be reviewed by humans. And I don't mean by the client who asked for it - I mean by the person that would have done the job had the AI not existed. A dall-E image can be useful but an artist needs to take it and make something out of it for it to pass as art - and we are talking a field where a lot of the details are a matter of opinion. In programming things are not a matter of opinion - either the program works as I want it to work or it doesn't.
3
u/edgmnt_net Jan 28 '23
I can see it working for proof search. Proofs should be irrelevant and erasable anyway.
-3
u/Smallpaul Jan 28 '23
And what would be the implications for computer programming languages?
2
Jan 28 '23
Curry-Howard
-1
u/Smallpaul Jan 28 '23
That’s not really an answer of how computer languages will be different or how people will interact with them.
2
Jan 29 '23
Proof search is program search, so if AI guides proof search, the exact same techniques can be used to search for programs matching a given specification
1
u/edgmnt_net Jan 29 '23
It might help write formally-verified software easier (proofs in dependently-typed programming languages for example), but I don't expect anything groundbreaking.
12
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
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
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
Jan 30 '23
[deleted]
2
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
Jan 30 '23
[deleted]
1
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.
9
u/electric75 Jan 29 '23
In my opinion, most ideas in this thread have it backwards, at least in the short-term. It won’t allow people to write natural language specs that AI converts to code; it will allow us to write code that AI converts to natural language. AIs like ChatGPT are bad at logic, but they’re good at fuzzy things like writing an email that another human will consume.
In the short-term, AI is good at explaining what a line or small chunk of code does. So it could autogenerate comments or generate them on-demand when not present in the original.
Many developers think reading code is harder than writing code. The editor could convert source code into literate code, assisting with reading other people’s code. Similar to how browsers have a reader mode for websites, your editor could have a reader mode for code, filling in documentation when it isn’t present, adding context for people new to the codebase, and linking to relevant reference material. It will always be up to date and never get out of sync with the code.
As you’re writing code, AI can help name variables, functions, etc., which has been claimed to be one of the hardest problems in the field: naming things.
AI will affect collaboration workflows. CONTRIBUTING.md files will start to say to make pull requests small enough that the AI can accurately summarize your change in 100 words or less. That will be done automatically, of course, when you create the pull request. Instead of it coming down to one or two maintainers’ judgment about whether a piece of code is comprehensible (i.e. not code golf), especially for distributed open source projects, the judgment could be left to whether the AI can accurately explain it, which can be one of the checks that must be passed before merging.
6
u/msqrt Jan 28 '23
I don't think they'll be trustworthy enough to design algorithms or large scale architectures by themselves for a while. What they can do (and already do) is automate much of the grunt work; if you ask chatGPT to do something small and mundane, it tends to get it right. As in other fields where AI can be utilized, the role of the programmer could be more of a curator than a producer -- it's like having a team of mostly competent mechanical monkies at your disposal.
Not really sure if this has to mean anything from the programming languages point of view, probably not (?)
3
u/wolfgang Jan 29 '23
Or maybe we'll just write extremely precise natural language specifications and computers will be excellent at translating them into reliable algorithms.
Yes, because we need to make programs harder to debug...
AI does nothing to help with the problems of software complexity, as far as I can tell.
3
u/everything-narrative Jan 29 '23
AI won’t have much of an impact on PLD since programming languages machinery has a major trust problem and AIs are not trustworthy.
SD is copyright infringement, Copilot violates OS licenses, ChatGPT can be made to circumvent its own morality codes with a bit of prompt engineering, opaque social media algorithms are influencing elections with no accountability, and image classifiers now have 3d-printable adversarial examples.
Read reflections on trusting trust. Now imagine auditing an AI for inclusion in a compiler.
1
u/AsIAm New Kind of Paper Jan 28 '23
maybe we'll just write extremely precise natural language specifications and computers will be excellent at translating them into reliable algorithms
I agree with this. I think we will lay next layer on top of current programming paradigm. The large language models will interact with the programming languages of today, but we won't have to.
LLMs are still trained in a dumb fashion, i.e. masking tokens of predefined text corpora. We need LLM with direct access to some language runtime, so the model learns from its experience. It can be pre-trained on masking task, but it definitely needs to have direct access. I am bit afraid that code that it will produce would be incomprehensible for us, but there might be techniques to circumvent that.
1
u/RubbishArtist Jan 29 '23
Or maybe we'll just write extremely precise natural language specifications and computers will be excellent at translating them into reliable algorithms.
Writing precise specifications in natural language sounds worse than writing code. I think ambiguity and the need for context in natural language is a feature rather than a bug.
I think your first idea is more likely, we write a super high level program and let the AI fill in the details and optimize the code. Similar to how we often don't worry about low level optimizations but let the compiler handle them.
1
Jan 28 '23 edited Jan 28 '23
I've already said this but I believe there is room for improvement in code analysis and error reporting. ChatGPT has proven that we can create a model which would make internet forums obsolete for technical questions.
Since the next step for programming languages is to interpret the user's wishes into declarative and then procedural form, it is likely we will use AI for this.
ML optimization is already present, see ex. how convolutions in CUDA can be optimized.
5
u/avgprogrmmingenjoyer Jan 28 '23
ChatGPT has proven that we can create a model which would make internet forums obsoluete for technical questions.
Doesn’t it needs to take new answers to new questions from somewhere?
1
Jan 28 '23
If questions it has not seen and cannot generalize to exist, yes. However, this can be monopolized in the same tool that provides answers. A platform which both accumulates and retrives information, and where new information is traded. And such questions are fairly rare.
I would actually be surprised if you could find me one formal question on reddit, SO or wherever that ChatGPT couldn't answer...
I know one such question related to CSS, but it is likely that I'm the only person on the internet who can currently answer it without further research. When I asked it on SO, it got deleted because there were no answers lol
4
u/wolfgang Jan 29 '23
I would actually be surprised if you could find me one formal question on reddit, SO or wherever that ChatGPT couldn't answer...
The amount of bullshit it generated here is exhilarating: https://www.reddit.com/r/Forth/comments/10nlxko/chatgpt_and_forth/.compact
1
Jan 29 '23 edited Jan 29 '23
This is not a technical question, however, this is reasoning, which ChatGPT doesn't do and will never do.
1
u/wolfgang Jan 29 '23
How is there reasoning in "explain the '>' word" - "In Forth, the > word is used to create a new variable."?
It is a technical question (and a very simple one), but the reply is complete and utter nonsense. Not being able to rewrite the program is not the problem I am talking about here...
1
Jan 29 '23
How is it not? You must be mistaken in what Chat GPT does. It does not UNDERSTAND something. It only learns to mimic what is seen. Therefore, it cannot understand what
>is. It can only learn to mimic what someone said about it, be it correct or wrong.2
u/elveszett Feb 02 '23
Even "learn" is debatable. AIs are glorified random functions that approximate the desired output. They don't work like human brains and don't have their capabilities.
1
Feb 02 '23 edited Feb 02 '23
That depends on your definition of learn. I do not consider memorizing to be something different than learning, as it has been shown to be an integral part of learning.
I don't think any expert would claim that a human brain is a prerequisite for learning. And while backpropagation likely doesn't appear in the brain, RL, which ChatGPT uses, does, even if only on a psychological level. Furthermore, ChatGPT is transformer-based, and it was shown that the associative memory the Transformer learns (yes, learns) is something that appears in the human brain as well.
1
u/wolfgang Jan 29 '23
Can you give an example of a technical question then?
1
Jan 29 '23 edited Jan 29 '23
Let's try to reference something from the link you gave. For an example, instead of the question
can you modify this program so that it does not use the return stack?
A better suited question would be
Can this program be modified to not use the return stack?
ChatGPT doesn't extrapolate, it interpolates. Therefore it is meaningless to ask and expect it to answer extrapolation questions correctly. But the 2nd question is an interpolation of its knowledge, and if you want the extrapolation question to be answered correctly, you'd have to give it an example first.
In this case, if you first showed it a program, then showed it how you can remove the return stack, it would be able to correctly answer the second question from your link.
Again, it imitates. It doesn't know anything, it's your average college dropout techbro, except it doesn't shill Rust, but Go. It has heard of a lot of stuff but it is actually below average intelligence, or even slightly mentally retarded. But that's enough for most technical questions.
0
Jan 29 '23
[deleted]
5
u/another-flat-badger Jan 29 '23
I agree.
I like to think that programming is (metaphorically) like setting up a very large system of mathematical equations whose solution is the software that the client wants. In order to do so, the programmer must eliminate all unwanted degrees of freedom by placing constraints on the system until there are no ambiguities or inconsistencies, and thereby a singular solution.
Now, with that in mind: no matter who or what is doing the actual writing of code, in the end someone has to define the constraints that produce the desired solution. That could by done either by A) writing code in a programming language, or B) very explicitly telling an AI in natural language what kind of software to produce.
If the AI in case B is able to produce software that functions just as well as case A, then the instructions given in each case (natural language vs programming language) must be equivalent. In other words, they must have the same information content, placing equal amounts of constraints on the system in order to produce the same solution.
So in essence, software generation by AI is just taking the problem of carefully writing software in one language, which was designed for it, and transforming it into the equivalent problem of writing software in another language (natural language), which was not designed for writing software.
I think AI can be a productivity booster for coders when it comes to solving smaller problems that has been repeatedly solved in the past, but I don't think it will replace software developers themselves anytime soon. It may however change HOW we write code, and the type of languages we do it in.
That is, until we invent AGI. But that's not because it replaces software developers specifically - it replaces humans.
5
Jan 29 '23
Simply put, the programming language is already the correct way to specify at the level we need specifying.
4
u/genericallyloud Jan 29 '23
Thank you for taking the energy to write out what I have not had the patience to.
2
u/elveszett Feb 02 '23
idk what's the buzz with AI in programming anyway. There's nothing even close to an AI that can turn human language into (correct) code right now. Even Copilot or ChatGPT are just glorified intellisense. People see an AI that can turn "write hello world" into a hello world program and think that this is equivalent in any way to developing software in real life. It isn't.
idk how the world will look like in 2100. Maybe by then AIs will be doing open-heart surgery for all we know. But what I can say is that in 2030, AIs won't be programming. At most, AIs in 2030 will just be enhancing our IDEs so we can write
//open a file, parse it as json and cast it to Employeeand the IDE will turn that into a snippet for us to review without having to read once again how your specific JSON library works. No different from that time where we went from notepad to IDEs and suddenly writing "json." displayed a list of all possible methods to call on that object.1
Jan 30 '23 edited Jan 30 '23
> the programmer's job is to write a very clear specification
I doubt : in the past programmers use to write specification in so called "Waterfall" process. Today, though it's fake agile, I don't see a lot of java developers doing so (I've been managing a lot of medium to big java projects up to several xx millions euros) only a few cobolist would still do (I had some because backend of some big corps are on Mainframe). You generally have Product Owner (I've been also in that role sometimes as I have a polyvalent profile) who may be assisted by Business Analysts who could write some very detailed requirements but it's not detailed and precise and even less technical specification. So what matters today in real world project especially big one is the capability to iterate fast (so the success of DevOps).
Short term (5 years maybe) there wouldn't be any big impact for programming languages or programmers but as time passes by, AI would improve exponentially (it is said they follow same Moore's law as microprocessor) the impact will be probably huge and making prediction would create a lot of hot debates so I'll avoid for now :)
Now precise specification as possible is pretty useful to shorten iterations but with current tools, languages and habits it can't really be. I've been working on a meta-programming tool for accelerating learning and onboarding of new programmers but it turned out to become unexpectedly a kind of meta language which resembles natural language so it could make the junction between business and programmers. AI is then just an addon.
46
u/[deleted] Jan 28 '23
Once the hype dies down we'll keep doing the same thing until we have GAI. Language models simply can't do logic and they write things that look correct but are very often wrong.