If you don't know C, in older versions that can be a catastrophic failure. (The issue is so serious in modern C `free(NULL)` is a no-op.) If it's difficult to get a `FOO == NULL` without extensive mocking (this is often the case) most programmers won't do it, so it won't be caught by unit tests. The LLMs almost never get unit test coverage up high enough to catch issues like this without heavy prompting.
But that's the least of it. The models (all of them) are absolutely hopeless at DRY'ing out the code, and when they do turn it into spaghetti because they seem almost oblivious to isolation boundaries, even when they are spelt out to them.
None of this is a problem if you are vibe coding, but you can only do that when you're targeting a pretty low quality level. That's entirely appropriate in some cases of course, but when it isn't you need heavy reviews from skilled programmers. No senior engineer is going to stomach the repeated stretches of almost the "same but not quite" code they churn out.
You don't have to take my word for it. Try asking Google "do llm's produce verbose code".
C is fundamentally a bad target for LLMs. Humans get C wrong all the time, so we can not hope the nascent LLM, which has been trained on 95% code that does automatic memory management, to excel here.
I always found myself writing verbose copypasta code first, then compress it down based on the emerging commonalities. I think doing it the other way around is likely to lead to a worse design. Can you not tell the LLM to do the same? Honest question.
> I always found myself writing verbose copypasta code first, then compress it down based on the emerging commonalities. I think doing it the other way around is likely to lead to a worse design.
I do pretty much the same thing, which is to say I "write code using a brain dump", "look for commonalities that tickle the neurons", then "refactor". Lather, rinse, and repeat until I'm happy.
> Can you not tell the LLM to do the same?
You can tell them until you're blue in the face. They ignore you.
I'm sure this is a temporary phase. Once they solve the problem, coding will suffer the same fate as blacksmiths making nails. [0] To solve it they need to satisfy two conflicting goals - DRY the code out, while keeping interconnections between modules to a minimum. That isn't easy. In fact it's so hard people who do it well and can do it across scales are called senior software engineers. Once models master that trick, they won't be needed any more.
By "they" I mean "me".
[0] Blacksmiths could produce 1,000 or so a day, but it must have been a mind-numbing day even if it paid the bills. Then automation came along, and produced them at over a nail per second.
a) The agent doesn't need to read the implementation of anything - you can stuff the entire projects headers into the context and the LLM can have a better birds-eye view of what is there and what is not, and what goes where, etc.
and
b) Enforcing Parse, don't Validate using opaque types - the LLM writing a function that uses a user-defined composite datatype has no knowledge of the implementation, because it read only headers.
`free(NULL)` is harmless in C89 onwards. As I said, programmers freeing NULL caused so many issues they changed the API. It doesn't help that `malloc(0)` returns NULL on some platforms.
If you are writing code for an embedded platform with some random C compiler, all bets on what `free(NULL)` does are off. That means a cautious C programmer who doesn't know who will be using their code never allows NULL to be passed to `free()`.
In general, most good C programmers are good because they suffer a sort of PTSD from the injuries the language has inflicted on them in the past. If they aren't avoiding passing NULL to `free()`, they haven't suffered long enough to be good.
> That means a cautious C programmer who doesn't know who will be using their code never allows NULL to be passed to `free()`.
If your compiler chokes on `free(NULL)` you have bigger problems that no LLM (or human) can solve for you: you are using a compiler that was last maintained in the 80s!
If your C compiler doesn't adhere to the very first C standard published, the problem is not the quality of the code that is written.
> If they aren't avoiding passing NULL to `free()`, they haven't suffered long enough to be good.
I dunno; I've "suffered" since the mid-90s, and I will free NULL, because it is legal in the standard, and because I have not come across a compiler that does the wrong thing on `free(NULL)`.
So what would be the best practice in a situation like that? I would (naively?) imagine that a null pointer would mostly result from a malloc() or some other parts of the program failing, in which case would you not expect to see errors elsewhere?
> imagine that a null pointer would mostly result from a malloc() or some other parts of the program failing, in which case would you not expect to see errors elsewhere?
Oh yes, you probably will see errors elsewhere. If you are lucky it will happen immediately. But often enough millions of executed instructions later, in some unrelated routine that had its memory smashed. It's not "fun" figuring out what happened. It could be nothing - bit flips are a thing, and once you get the error rate low enough the frequency of bit flips and bugs starts to converge. You could waste days of your time chasing an alpha particle.
I saw the author of curl post some of this code here a while back. I immediately recognised the symptoms. Things like:
if (NULL == foo) { ... }
Every 2nd line was code like that. If you are wondering, he wrote `(NULL == foo)` in case he dropped an `=`, so it became `(NULL = foo)`. The second version is a syntax error, whereas `(foo = NULL)` is a runtime disaster. Most of it was unjustified, but he could not help himself. After years of dealing with C, he wrote code defensively - even if it wasn't needed. C is so fast and the compilers so good the coding style imposes little overhead.
Rust is popular because it gives you a similar result to C, but you don't need to have been beaten by 10 years of pain in order to produce safe Rust code. Sadly, it has other issues. Despite them, it's still the best C we have right now.
It's about time to finally grok that all world's military is only there to wage wars at the whim of the 0.001% under the guise of being defence-only, and that constitutions worth less than toilet paper these days.
Kill the royal couples, no problem. There is an argument to be made that those that start wars should be sentenced to death for doing so. Particularly frivolous ones of aggression.
If the civilian populous has access to arms and armories they can make it a worthless proposition to invade them. Its not like the world is entirely composed of large countries with strong militaries already. An insurgency can last decades under fire from a superior force, an organized military won't. So if you can't match the organized military might of potential enemies, its probably mostly a waste to try.
Defense doesn't mean not to start a war. Think about how Vietnam justified their invasion of Cambodia in 1978, or how China started the war with Vietnam the following year, or how Turkey entered Syria, how Pakistan fought the Taliban recently, and of course what Russia did in Ukraine, 2014 and 2022.
Wars are messy and have always been. Military actions are to be decided by the governments. Those who have resources are more willingly to use it, west or east.
Rather: the "victorious" countries of the Second World war were afraid of a re-militarization of Germany. On the other hand, they wanted to re-militarize the Western part of Germany just a little bit so that West Germany could become part of the NATO.
Quite the contrary; up until the end of the Cold War both German states were highly militarized. They were quite happy to be able to roll back a lot of it after the reunification though.
That is basically redefining the word defense, though.
I can’t be like “it was self defense” if I beat somebody up because they are getting too big at the gym and they could beat me up later if I don’t beat them up first.
That doesn’t mean such a thing is never ever justified, in international relations, it just ain’t “defense”.
Well that depends. Are they saying this because they have a problem with me specifically? Or is it because they have a problem with my asshole friend who I for some reason support financially?
If it’s the latter (like it is in reality, AFAICT), I would first do some serious reflection about my friend.
In the analogy, if you are financially supporting guy A who is harassing guy B and his family constantly over years, and as a kicker guy A acts like he’s done nothing wrong, it is human nature for guy B to be pissed not only at guy A but also at YOU who financially supports guy A even while you know what he is doing.
If you stop financially supporting guy A and sincerely apologize to guy B, and guy B continues to be pissed at you, THEN you can act like he is unreasonable and take steps to protect yourself, even if those steps hurt guy B.
You can’t pretend guy A is blameless and act confused why guy B is pissed at you, which is what is happening in real life.
Of course you are free to support abusive behavior but especially with friends and family it would probably be useful for your own sake not to do so, and it is factually correct to view (and treat) you as enabler if you continue to do so despite knowing about the abuse.
I don’t care how things started. If someone wants to chop my head off and has shown evidence of chopping the heads off of people of my tribe, I will try to beat them first
But you do you.
So while many of the reasons are questionable (understatement of the year), let’s focus on the last one. After America lost the war in Vietnam, what happened to those neighboring nations? Did they suffer from Vietnamese communists? The only Vietnamese intervention was in Cambodia, and hardly anyone thinks that wasn’t the right thing to do.
The OP probably thought of defense in the narrow sense as "the action of defending against or resisting an attack", and not in the broader sense defined as "we’re going to travel halfway around the world to kill a million people because that’s who we are". A common mistake.
Not because “that’s who we are.” That’s a ret*rded retort. You go halfway around the world because you want to protect your friends and your nation’s interest.
Wouldn’t you do that to protect your family and your home, now and into generations? I think I know the answer.
That depends greatly on which interests you allow to be defined as "American". The vast majority of American people would have preferred not to be involved in most of our foreign adventures. The rich and powerful thought differently. Is our citizenship determined by the size of our bank accounts?
This is factually incorrect. Here are the estimates for the rates of support for each conflict at the beginning of the conflict:
- Iraq (Gulf War): 75-80%
- Iraq (2003): 65-76%
- Syria: 35-50%
- Vietnam: 65-75%
- Iran: 42%
Alexander Hamilton wrote that governance should involve people with “wisdom to discern” and “virtue to pursue the common good”. The US is not a direct democracy; it is a constitutional republic. The definition of what constitutes American interests is literally whatever the United States federal government says it is.
I'm probably going to get flagged for this, but here goes anyway.
Russia absolutely has reason to not want Ukraine to join NATO. I'm not condoning the invasion, but I say it absolutely makes sense for Russia to carry it out. Not a reason to commit war crimes, or to cause any more suffering than necessary, but from a national security perspective it makes sense to want to disrupt the process of Ukraine joining NATO.
Only if you accept the hidden assumption that Russia is an antagonist toward the rest of Europe. Otherwise the common "national security" justifications make no sense, because Russia benefits immensely from other NATO members investing resources into the development of institutions in newer member states.
A former Russian foreign minister has labeled NATO "free-of-charge security" for Russia, because NATO membership requirements turn a country into a stable and predictable place. The best neighbors Russia has are in NATO, and much of that stability is directly attributable to their membership.
Yeah, by such definitions any country is justified to wage a war and always find a way to claim it’s for self-defense (which is indeed how most causus belli have worked throughout the history – they always claim to have the moral high ground when launching the war). This is also how essentially in every country it’s called the Department of Defense (unless you’re Trump) but that means nothing as they start wars all the same. Not a trace of any rules, accountability or restraints still remains under such a framing.
Germany participated in the NATO military campaign/occupation of Afghanistan, including ground forces, naval activities and special operations units. Its seems a total of 150,000 German soldiers (and police officers?) were deployed overall (not at the same time of course); of them, 62 were killed and 249 wounded:
I'm wondering if you have actually used claude code because results are not so catastrophic as you describe them.