Live data from Hacker News

LLMs are mortally terrified of exceptions

twitter.com

11–20 of 157 posts

Re: LLMs are mortally terrified of exceptions

#11
post #2

Even when they're not AI slop, these kinds of "paranoid sanity checks" are the software equivalent of security-theater.

Yeah, I really hate code like this because it generally ends up full of codepaths that have never been exercised, so there's all sorts of potential for weird behavior and unexpected edge cases. Plus it's harder to review.

Re: LLMs are mortally terrified of exceptions

#12

If you are dividing two numbers with no prior knowledge of these numbers or any reasonable assumptions you can make and this code is used where you can not rely on the caller to catch an exception and the code is critical for the product, then this is necessary. If you are actually doing safety critical software, e.g. aerospace, medicine or automotive, then this is a good precaution, although you will not be writing…

I might agree with that, and maybe the example posted by Karpathy is not the greatest, but what I'm constantly being faced with is try catches where it will fail silently or return a fallback/mock response, which essentially means that system will behave unexpectedly in a more subtle way down the line while leaving you clueless to as what the issue was.

I have to constantly remind Claude that we want to fail fast.

Re: LLMs are mortally terrified of exceptions

#13
Given that the output describes the function as being done "with extraordinary caution, because you never know what can go wrong", i would guess that the undisclosed prompt was something similar to "generate a division function in python that handles all possible edges cases. be extremely careful". Which seems to say less about LLM training and more about them doing exactly what they are told.

Re: LLMs are mortally terrified of exceptions

#14
Expert beginners program like this. I call it what it driven development. Turns out a lot of code was written by expert beginners because by many metrics they are prolifically productive.

In go all SOTA agents are obsessed with being ludicrously defensive against concurrency bugs. Probably because in addition to what if driven development, there are a lot of blog posts warning about concurrency bugs.

Re: LLMs are mortally terrified of exceptions

#17
It's also logically incoherent - division by zero can't occur, because if b=0 then abs(b) Furthermore, the code is happy to return NaN from the pre-checks, but replaces a NaN result from the division by None. That doesn't make any sense from an API design standpoint.

Re: LLMs are mortally terrified of exceptions

#18
I mean, the first three cases are just attempting to turn dynamic into static typed... right? maybe just don't aim for uber-safety in a dynamically typed language? :shrugs:

(I used to look out for kaparthy's papers ten years ago... i tend to let out an audible sigh when i see his name today)

Re: LLMs are mortally terrified of exceptions

#19

This is just AI trying to tell us how bad we designed our programming languages to be when exceptions can be thrown pretty much anywhere

So you think java's checked exceptions are a better model? No opinion myself, but that way seems widely considered bad too.

Re: LLMs are mortally terrified of exceptions

#20

Given that the output describes the function as being done "with extraordinary caution, because you never know what can go wrong", i would guess that the undisclosed prompt was something similar to "generate a division function in python that handles all possible edges cases. be extremely careful". Which seems to say less about LLM training and more about them doing exactly what they are told.

[deleted]
Post reply on HN