At the end of last year, I wanted to clean up some mailing addresses in an Excel spreadsheet for use with our family New Year’s cards. I resent having to spend time learning any computer language other than Lisp and SQL unless that language is more powerful than Lisp and/or SQL. Thus, I’ve never become a proficient Excel programmer. Could an LLM come to my rescue?
Prompt to ChatGPT 5.2:
write a Microsoft Excel 365 formula that will take a US address and remove a trailing “US” or “US” preceded by a newline and also turn any 9-digit ZIP code into a 5-digit zip code by removing “-NNNN” where N is a digit.
Answer:
=REGEXREPLACE(
REGEXREPLACE(A1,"(\d{5})-\d{4}","$1"),
"(\r?\n)?US$",""
)
Grok’s answer:
=LET(
cleaned, TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,CHAR(10)&"US",""),CHAR(10)," ")," US","")),
lastLine, TRIM(RIGHT(cleaned, LEN(cleaned)-FIND("@",SUBSTITUTE(cleaned," ","@",LEN(cleaned)-LEN(SUBSTITUTE(cleaned," ","")))))),
zipLike, TRIM(TEXTAFTER(lastLine," ",-1,"",1)),
fixedZip, IF(REGEXTEST(zipLike,"^\d{5}(-\d{4})?$"),
LEFT(zipLike,5),
zipLike),
SUBSTITUTE(cleaned, zipLike, fixedZip)
)
What’s the difference between these, other than Grok’s epic verbosity? The Grok version results in an unexplained error from Excel while the ChatGPT code works.
Advantage: ChatGPT
The main difference is that Grok is using spreadsheet/Excel-specific functions, while ChatGPT is using the more general mechanism of Stephen Kleene’s regular expressions, which are available in Unix and all modern programming languages.
The Grok version is so complex that I can’t justify the time to try to understand it, which is not all that unusual in my experience with LLM-generated code.
The ChatGPT version is impressive, but note that:
a) The code relies on the ZIP+4 having an infix dash
b) The ZIP+4 removal would affect any number, including a street or house number, with that pattern, i.e., “29687-1315 E Retirement Ave”)
c) ZIP+4 was invented for a reason and you probably shouldn’t remove it
> […] language other than Lisp and SQL unless that language is more powerful than Lisp and/or SQL
Ahem, I know that you’re an MIT PhD, and all that, so please correct me if I am wrong. AFAIK all Turing-complete languages are equally “powerful”. It’s only the compilers which can be less or more powerful. Like the official Rust compiler is arguably more powerful than most C compilers.
You are wrong.
Leaving aside K&R C and x86 Assembly Language as a whole, printf format strings and the x86 MOV instruction are themselves Turing complete.
Power is work/time. Languages with built-in data structures, first-class functions, OOP facilities, etc. (or with minimalist syntax which facilitates easy implementation of all that) allow more work to be done per unit of programmer time.
“powerful” has a practical aspect. x86 binary code is Turing-complete. Could the average programmer build a useful desktop app in x86 binary code? If not, it is not “powerful” in practice.
You are wrong.
I am assuming Dr. Greenspun was referring to theoritical power of Lisp when he said that he didn’t find a language more powerful. I am not defining power as the same way that you are.
> Leaving aside K&R C and x86 Assembly Language as a whole, […]
Irrelevant to what I said.
> Power is work/time. Languages with built-in data structures, first-class functions, OOP facilities, etc. […]
Not the definition of power I wrote about.
Congratulations, you know what a Turing machine is; you’ll be CEO of an Western company any day now!
My definition is not only consistent with physics, but also with the generally accepted meaning in programming, for example:
https://philip.greenspun.com/blog/2005/03/07/how-long-is-the-average-internet-discussion-forum-posting/
Look how much fun it is to program SQL. Three lines of code and you get an interesting answer (and those three lines would have been much cleaner and simpler if we hadn’t been forced to use the CLOB datatype, which has its own strange accessor functions). Compare to Java and C where typing until your fingers fall off usually doesn’t result in much of anything. SQL, Lisp, and Haskell are the only programming languages that I’ve seen where one spends more time thinking than typing.
https://youtu.be/LQCU36pkH7c
Another reference, via James Mitchell:
https://paulgraham.com/avg.html
“All languages are equally powerful in the sense of being Turing equivalent, but that’s not the sense of the word programmers care about. (No one wants to program a Turing machine.) The kind of power programmers care about may not be formally definable, but one way to explain it would be to say that it refers to features you could only get in the less powerful language by writing an interpreter for the more powerful language in it. If language A has an operator for removing spaces from strings and language B doesn’t, that probably doesn’t make A more powerful, because you can probably write a subroutine to do it in B. But if A supports, say, recursion, and B doesn’t, that’s not likely to be something you can fix by writing library functions.”
Phil, there is no language that is more powerful than Lisp, so you won’t be learning very many languages. I think you might already know this:
https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule
Different languages have different purposes. If you’re doing Windows/Azure system admin, PowerShell is great. It would not be suitable for writing a full application.
Paul Graham’s essay is worth reading:
https://paulgraham.com/avg.html
James Mitchell
https://www.jamesmitchell.info/
That’s 5x the amount of prompt writing a lion can stand. Some of us are born to describe algorithms in natural language & some are born for algebraic language.