r/ProgrammingLanguages • • 2d ago

Programming in English

https://pvs-studio.com/en/blog/posts/1428/

Some thoughts on why natural language still can't replace code

7 Upvotes

15 comments sorted by

19

u/Seek4r 2d ago

Natural language contains tons of ambiguity.

If we take a very small subset of a natural language, sure. But that's kinda what Python, Ruby and co are (loosely speaking).

8

u/Ichigonixsun 2d ago

I would add that ambiguity doesn't refer only to the different (sometimes contradicting) interpretations that the same statement can have, but also to the fact that almost any natural language description of something will always be incomplete, and you can't deterministically reject a natural language "program" for being incomplete, so even "a very small subset of a natural language" wouldn't be enough without also simplifying the grammar, at which point it wouldn't be "natural language" anymore but a formal language like "Python, Ruby, or Go".

For example, if I ask an LLM to create a pong game, it might create something that is unambiguously a pong-like game, but details like the color palette, thickness and length of the paddles, etc... could be different each time.

2

u/koflerdavid 1d ago

It's actually worse. Asking an LLM to create a Pong game works because it is very well-known what Pong is. Also, the LLM has been trained on a dataset that very likely contains dozens of Pong game implementations. It would be more interesting to ask an LLM to create an implementation for a completely off-the-beaten-path game idea.

8

u/Automatic-Tackle5018 2d ago

I'm no expert, but I don't think there's a human language in any sort of practical usage that has syntax and grammar strict enough to write an algorithm for a computer to run deterministically and unambiguously.

Most human languages don't even have any notion of a centrally-maintained codification of the language 'rules'. Most languages have words that may have multiple meanings based on context, and it would be very difficult to program a computer to understand these contexts, as they are based on a purely human experience.

You could, however, write a programming language grammar that uses a strictly-codified subset of natural language words, and some people have done so.

1

u/tubameister 2d ago

2

u/Automatic-Tackle5018 2d ago

Hahaha. I was thinking more of 'joke' languages like Rockstar, but yes, I suppose this fits too.

8

u/Inconstant_Moo 🧿 Pipefish 2d ago

It occurs to me that legalese was an attempt to make English unambiguous and still so general purpose as to be able to describe events as diverse as embezzlement and arson and the division of property in a divorce, and yet a substantial slice of what lawyers earn is because this didn't work and there's still plenty of ambiguity to bicker about.

We don't actually need that much generality of purpose because the apps we write are way more about data structures than they are about the domain. It is only in the variable names that the app you're writing for the fruit company is about pineapples. It's mostly about handling data, and would work just the same if they were shipping peaches or persimmons or porcupines.

And when we have a constrained domain in which we want to be precise, we invent a constrained precise language --- musical notation, knitting patterns, circuit diagrams, architects' blueprints, chess notation, etc.

And the actual fundamental domain of data processing is very constrained indeed. Sometimes I go and look at the file in my lang that contains its two dozen or so built-in functions and remind myself that the whole of the rest of the language is adding flow of control to that, and then the whole of the rest of the project is adding DX to that, and that fundamentally all it knows how to do is a few things like compare two numbers and see which is bigger, or concatenate two strings.

6

u/AdreKiseque 2d ago

"Still" as though we expect that to change?

6

u/rexpup 2d ago

They keep trying every 10 years or so. In COBOL was supposed to let business people write their own code. Visual Basic was supposed to let business people write their own applications. LLMs are supposed to let business people write their own applications.

I don't think it's gonna stick this time, either.

5

u/Sensitive_Mountain97 2d ago • Bravo

I think English itself is a horrible language. It is not even consistent and doesn't have a good structure. I also think there is no language with a good consistency or structure. We might need to create a better language to keep it consistent with a good structure. Hmm.... Maybe we need to create a consistent programming language?

3

u/Spotted_Metal 2d ago

We might need to create a better language to keep it consistent with a good structure

Lojban already exists /s

2

u/Norphesius 2d ago

I get the joke, but with English being the defacto  syntax base for programming languages since there were programming languages, I've wondered if other written languages/grammars could offer unique ways of creating simple syntax structures. I know that the 'else' part of if-else originated from German's grammar, but I'm not aware of any others.

1

u/PerformerDazzling601 2d ago

My language would say otherwise

1

u/NoSpite4410 1d ago edited 1d ago

A machine that could be programmed in English, would have a brain. It takes a trained and educated brain to understand enough of plain English to create a useful program of any size.
Once that theoretical threshold is passed, then you don't need a programmer, the machine can program itself.

The point of programming is applying your human brain to a problem, and creating a set of commands and evaluators and sensors and actuators to solve it.
The math part is pretty much all automate-able, the English part is practically an infinite set of options, that a machine could only have a sliver of taxonomy.

The "new wonder" are huge parallelized machines that have corpuses of billions of words, billions of training routines to pick from, to attempt to simulate programming in English. And they occasionally in very skilled hands produce some impressive results, but usually just spit out whatever comes up like a word slot machine. Slot machines calculate an "answer" in a few milliseconds after the button is pushed, and then "concoct a story" of graphics including spinning wheel animations, music, sound effects, for some time to occupy the human looking at the screen. But the outcome of the graphics when the story ends was determined in a few milliseconds by very non-English code. The Large Language Model machines are doing the same thing. And like slot machine computers at casinos, they are designed primarily to keep customers looking at the screen and paying.

Literate computing has long been a goal in science fiction and in academia, it has always fallen short, relying for it efficacy on the expertise and knowledge of the underlying hardware and software architecture of the operator to produce anything close to useful. This will not change, no matter how "literate" an AI model becomes. There will always be a gap between the understanding of an organic human brain and a simulated software brain. The gloom and doom of "they will replace us" is only a prediction of bad industrial practices, that has come true in every stage of the automation process evolution of business. The "no human involvement" end-stage scenario will never really come to pass, however, because there will always be a need for human expertise and guidance.

The next "iteration" of literate code attempts which is here is AI prompting, and it is pretty much a hit and miss affair. Everyone who is not blinded by dollar signs in their eyes can tell that it would be utter disaster to try to give such machine any say in things, trust their spewing implicitly, not double check practically every "answer story" that comes out of the text slot machine. Because it is not "thinking", it is not "literate programming", it is a bunch of statistics and table lookups of existing data already input.

Will it be "good enough" for some uses? Yes it already it good enough to fool people looking to score big on the market casinos of finance. But that it what they do, sometimes its the only thing they do, use other people's money to make bets on market trends. So of course they are going to roll the digital dice on making stacks of cash from what they see as an eager public and business sector to eliminate human work with "a machine programmed in English". It will rise, reach its limits, fall, and revert back to its actual level of usefulness, like any computer idea, and it will just then be a background utility, like networking, which once was a huge source of hype, turned out to be a game changer, and now is just taken as given, like a national road system, something most assume was just always there.

Logic programming languages were a great purple hope at one time for the future of literate programming, but hit their limit far sooner than their creators anticipated. It seemed quite possible to build out logic to encompass English prose as programming, but it was found to be quite beyond most people, and quite cumbersome and frankly cranky to try to expand logic languages beyond a very finite set of procedures. Of course it became obvious eventually that a language based on formal logic principles required a programmer that understood them as well as the original language creator, or better, because it is sometimes easier to create a tool than to wield it expertly.

Starting with Java, and Tool Command Language, then Perl, Python, and Ruby, programming languages have become more string oriented, the syntax has become more like the sentence structure of a kind of stunted English.
result = [object verb (params ...) ] seems like what has been settled on, along with a set of standard things like

if <predicate>,

for <loop>,

while <predicate> (loop_,

apply <<functions> (params ..),

do <commands>

All very directly-translatable to non-English binary or intermediate languages,primarily stacked commands internally.

There is no "why" involved for the machine. It can't do "why" -- it can only do "what" and "where'. This is a fundamental thing that cannot be overcome, so when English is tried to be translated, all the inherent "why" implicit in the language is lost to the machine.

So a subset of English has to stipulated that contains no leaps of intuition as to why a directive is given, why the person typed in a sentence that way in that particular set and cadence and order of words.

1

u/Hixie 6h ago

LLMs are English to programming language transpilers. So in some sense, it now can. But as others have said, it's ambiguous, and so the transpiler makes a lot of guesses as to what you meant. Sometimes that works well, other times...