logoalt Hacker News

markstosyesterday at 7:08 PM7 repliesview on HN

I have successfully vibe-coded features in C. I still don't like C. The agent forgets to free memory latter just like a human would and has to go back and fix it later.

On the other hand, I've enjoyed vibe coding Rust more, because I'm interested in Rust and felt like my understanding approved along they way as I saw what code was produced.

A lot of coding "talent" isn't skill with the language, it's learning all the particularities of the dependencies: The details of the Smithay package in Rust, the complex set of GTK modules or the Wayland protocol implementation.

On a good day, AI can help navigate all that "book knowledge" faster.


Replies

whiatpyesterday at 9:44 PM

Something I've noticed that I never really see called out is how easy it is to review rust code diffs. I spent a lot of my career maintaining company internal forks of large open source C programs, but recently have been working in rust. The things I spent a lot of time chasing down while reviewing C code diffs, particularly of newer team members, is if they paid attention to all the memory assumptions that were non-local to the change they made. Eg. I'd ask them "the way you called this function implies it _always_ frees the memory behind that char*. Is that the case?" If they didn't know the answer immediately I'd be worried and spend a lot more time investigating the change before approving.

With rust, what I see is generally what I get. I'm not worried about heisenbug gotchas lurking in innocent looking changes. If someone is going to be vibe coding, and truly doesn't care about the language the product ends up in, they might as well do it in a language that has rigid guardrails.

chisyesterday at 8:54 PM

It's really funny how much better the AI is at writing python and javascript than it is C/C++. For one thing it proves the point that those languages really are just way harder to write. And another thing, it's funny that the AI makes the exact same mistakes a human would in C++. I don't know if it's that the AI was trained on human mistakes, or just that these languages have such strong wells of footguns that even an alien intelligence gets trapped in them.

So in essense I have to disagree with the author's suggestion to vibe code in C instead of Python. I think the python usability features that were made for humans actually help the AI the exact same ways.

There are all kinds of other ways that vibe coding should change one's design though. It's way easier now to roll your own version of some UI or utility library instead of importing one to save time. It's way easier now to drop down into C++ for a critical section and have the AI handle the annoying data marshalling. Things like that are the real unlock in my opinion.

show 3 replies
UncleOxidantyesterday at 10:32 PM

> I have successfully vibe-coded features in C. I still don't like C.

Same here. I've been vibe-coding in C for the sake of others in my group who only know C (no C++ or Rust). And I have to say that the agent did do pretty well with memory management. There were some early problems, but it was able to debug them pretty quickly (and certainly if I had had to dig into the intricacies of GDB to do that on my own, it would've taken a lot longer). I'm glad that it takes care of things like memory management and dealing with strings in C (things that I do not find pleasant).

ActorNightlyyesterday at 7:10 PM

> The agent forgets to free memory latter just like a human would and has to go back and fix it later.

I highly recommend people learn how to write their own agents. Its really not that hard. You can do it with any llm model, even ones that run locally.

I.e you can automate things like checking for memory freeing.

show 5 replies
sureglymopyesterday at 9:55 PM

Lately I have learned assembly more deeply and I sometimes let an AI code up the same thing I did just to compare.

Not that my own code is good but every single time assembly output from an optimizing compiler beats the AI as it "forgets" about all the little tricks involved. However it may still be about how I prompt it. If I tell it to solve the actual challenge in assembly it does do that, it's just not good or efficient code.

On the other hand because I take the time to proof read it I learn from it's mistakes just as I would from my own.

nylonstrungyesterday at 9:33 PM

I think arenas might be better memory management technique when vibe coding C, for this reason

greenavocadoyesterday at 7:11 PM

I just wrote a piece on this specific C issue the other day https://news.ycombinator.com/item?id=46186930

show 1 reply