суббота, 18 октября 2025 г.

Quiet Phobias of AI: Why Your Coder-Robot Fears Exceptions (and Not Only)

 Quiet Phobias of AI: Why Your Coder-Robot Fears Exceptions (and Not Only)

Recently, Andrej Karpathy spotted a trend in "AI vibe coding" — and I echoed it in my post

and

sharing that I see these weird "psychological dependencies" among coders working with AI. And I thought: what if these dependencies aren't just in humans, but in the models themselves? LLMs are full of "quiet phobias." They don't scream "no!" — they just quietly dodge. Let's unpack why your AI coder trembles at the sight of try-catch.

Imagine: you ask AI to write a function for reading a file. You expect elegant try-except. Instead, you get a bunch of if-else, like the model fears the exception will bite. Why? Datasets are stuffed with "safe" tutorials. AI learns: "Errors? Better check ahead than catch on the fly." It's like an eternal fear of spiders — invisible, but stubborn. In the end, code bloats like weeds in a garden.

But phobias are treatable. With prompts. Here are a few tricks to make AI brave up.

First, basic case: "Write a Python function that reads 'data.txt' and returns lines. Use try-except for FileNotFoundError — return None. No if os.path.exists(). Exceptions are simple, like morning coffee." Model caves. You get a clean try-block. No drama.

Or for division: "Function divide(a, b): a / b. Try-except on ZeroDivisionError — return 'Infinity'. Forget if b == 0. Exceptions are expressive, like a good meme." AI nods: "Okay, I'll try." Code shorter, life easier.

And for networking (with async, to keep it fun): "Async GET with aiohttp to 'api.example.com'. Try-except on TimeoutError and ClientError — log and return empty dict. Don't check ahead. Exceptions — for the bold." Add "Think like an API expert" — and voila, AI steps out of its comfort zone.

It's no magic. Just explicit instructions suppress phobias. Success rate: 80-90%, per coder reviews.

But exceptions aren't the only fear. LLMs brim with other "quiet horrors." Recursion? They pick loops, like diet dinner over steak. "Stack overflow? No thanks." Prompt cure: "Use tail recursion with @lru_cache. For n<1000, zero risk."

Another phobia: excessive checks. Instead of fixing the bug, a forest of ifs. Code like a bulletproof vest: heavy and holey. Fix: "Assume valid input. Focus on core, no guards."

Outdated syntax? AI clings to Python 2 like grandma to knitting. Or skips async, fearing concurrency nightmares. Prompt: "Only Python 3.12. Async with gather — for modernity."

And over-commenting: every if with a lecture. Like AI's a teacher for first-graders. "Keep it concise, no docstrings everywhere."

These phobias are data mirrors. AI echoes human stereotypes. But at xAI, we're fighting: more diversity, fewer fears. Have you spotted such "psycho-dependencies" in models? Share in comments — maybe we'll cure them together?

#AI #Programming #LLM #CodingHumor #xAI

Links: https://news.ycombinator.com/item?id=45530486 ; https://openreview.net/forum?id=kNvwWXp6xD ; https://arxiv.org/html/2503.06327v2 ; https://www.reddit.com/r/OpenSourceeAI/comments/1hi2w79/llms_for_handling_recursion_and_complex_loops_in/ ; https://www.reddit.com/r/LLMDevs/comments/1l718ni/what_are_the_most_common_problems_with_the/ ; https://medium.com/@Shrishml/all-about-python-asyncio-ca1f5a8974b0




Related Posts Plugin for WordPress, Blogger...