Hacker Newsnew | past | comments | ask | show | jobs | submit | rayiner's commentslogin

How good are AIs at coding manual memory management? Is this a sea change in automatic memory management?

In my opinion, the "manual" memory management, introduced by the IBM PL/I programming language by the end of 1964, and inherited by C and other languages, i.e. where the programmer is responsible for invoking "free", was a serious mistake and it was an obsolete technique already at the date of its introduction.

When the explicit "free" was invented, automatic memory reclamation while avoiding the non-determinism of garbage collectors had already been known for 4 years, since 1960, when another IBM employee had invented reference counting (as a reaction to the garbage collector of LISP I).

When implemented naively, reference counting has some disadvantages, but those can be circumvented relatively easily in an optimized implementation. The book discussed in the parent article also has a chapter about reference counting.

I have written C programs for many decades, but I have never invoked "free" directly, because I have always used reference counts. I have never encountered a circumstance when I would have wanted to invoke "free" directly.

C has the disadvantage that the compiler will not do implicitly things like virtual function invocation, reference counts handling etc. but any such techniques that are provided by higher-level languages can still be used in a language like C, even if they require more boilerplate code.

I do not like the "shared_ptr" implementation of reference counting in C++, because that data type is not directly usable in places where a plain reference or pointer is expected. Implementations that do not have this problem exist.


I have never seen Codex or Claude get manual memory management wrong. I used to be pretty fastidious about using leak sanitizer or other such tools to catch my own memory management issues, and while not quite useless, that sort of testing has dropped way down my list of worries the more I lean on LLMs. I am constantly surprised by how many formerly tedious or error prone tasks stopped being either of those, and I expect to see practice shift away from middle-safe languages like C++ to not just much more safe languages like Rust but surprisingly also to much less safe ones like C and platform specific assembly.

The hard part was never getting it correct on a local scope, that's mostly solved by a linter, or even C++'s RAII will get it right.

The hard part is doing it correctly on a global scope with non-trivial lifetimes, possibly influenced by multiple threads.

And in my experience LLMs are still hit or miss on these kind of problems, they can find problems from time to time, but they can't really reason well about more complex global state reliably. They will come up with "hypotheses" that 'oh sure this is the root cause of the issue' only to say something completely wrong (which you may notice or not, only to fail later)


GC's strength is not only in the ease of writing but at also reading, since you don't need to interleave allocation and business logic everywhere (be it through types or imperative code).

GC simply is the only way to approach the clarity of pseudo-code in real code. That's one of my later realizations concerning the subject (https://world-playground-deceit.net/blog/2024/11/how-i-learn...)


You mean "interleave deallocation and business logic everywhere".

For allocation there is no difference between automatic memory management with garbage collectors or reference counts and manual memory management, where the programmer is responsible for invoking "free".

These alternative memory management methods differ only in how deallocation is handled.

Allocation must always be done by defining a new object, regardless of how memory is managed. Moreover, allocation also does not depend on whether an object is allocated in static storage, in a stack or in a heap. You always must define the object, so that memory should be allocated for it at compile-time if in static storage, or at run-time if in a stack or in a heap.


Well, it's true that most of the noise comes from deallocation but I did mention types for good reasons: having your code littered with std::shared_ptr (or worse for Rust where encoding lifetime goes much further than Rc/Arc) is a direct consequence of wanting GC without a global one.

The source of my second revelation: GC should be opt-out (e.g. SBCL's arena system) instead of opt-in via refcounted types.


While C and C++ have ugly syntaxes for "malloc", "std::shared_ptr" and the like, it is quite easy to mask that ugliness by using macros and writing thus only cleanly-looking programs, without any noise words and symbols around dynamic allocations.

In general, by using macros it is possible to transform so much a C or C++ program, that it becomes unrecognizable as C/C++ and it can mimic reasonably well any other programming language that you might fancy.

The problem is when you work in a team, because even if everyone will agree that such programming languages have great deficiencies, it would be impossible to reach a consensus about how the ideal programming language should look like, so eventually the team remains stuck with writing programs in the ugly standard manner.


Eating meat. Changes in moral perception generally are downstream of changes in technology. E.g. the modern conception of women being equal participants in the economy arose alongside the growth of the knowledge economy, where your average worker was sit in front of a computer instead of bolting doors to a car frame on an assembly line. I strongly suspect that once lab grown meat becomes ubiquitous, our killing and eating animals will come to become regarded as barbaric.

It’s ironic that the civilizations that directly contributed to us sitting here believing in egalitarian democracy, get far more hate for it than the ones that never evolved into egalitarian democracy at all. We are standing on the shoulders of giants and some people can’t see it.

I was talking about its economic system, not politics.

> The public’s life is getting worse while these companies consolidate power using data they stole from the public

How can you “steal” public information?


really? You know this just like everyone else: Just because the information is available publicly, does not mean that you can do whatever you want with the information. Copyright exists for a reason, and if the copyright lobby is going to continue to push for the poor poor media companies to keep their copyrights, then we should do the same towards the AI companies. So yes, they Stole the information from everyone else, and they keep doing so, as you can see their scanners still hitting every website on the web to get an updated dataset. It does not matter what they do AFTER they steal all the information, as they already stole it.

This is why I don’t understand the concerns about “our AI overlords” monopolizing all the gains from AI. It doesn’t seem like there’s much of a moat around the models themselves. So the race is mainly about compute. But compute is subject to power law effects. I remember Intel building the first Teraflop computer (ASCI red) in 1996. It was the size of a house. By 2014 you had more compute and 50% more memory in an off the shelf dual processor server system.

The openness of AI is currently being held up only by Chinese companies (previously Meta, but they stopped). They're not saints, but there is not even a question in the open weight/HF community that the immense mass of Chinese talent, knowledge and resources are the only thing stopping a monopoly/duopoly from forming. In a very Cathedral vs Bazaar-esque way, China severely lacks compute, but are extremely ingenious in coming up with new optimizations, architectures, etc, which they all detail in their papers.

Fox wasn’t! That’s what made the Times worth reading! It was center-left people being objective to the best of their ability. So you could use it as a neutral-ish default, the check out Fox for any stories or angles the Times had overlooked.

How can they make any money on this?

No, too much emotion.

Isn’t this just a bet that I’ll have an AI data center in my iPhone within 10 years? Why is that a bad bet?

The article gets six paragraphs in before starting to discuss the actual legal issue. No bueno! Better summary: https://www.scotusblog.com/cases/landor-v-louisiana-departme...

Here’s the missing context. Congress has chosen to confer on prisoners certain freedom to practice their religion freely. For federal prisons, Congress can do this directly. But Congress cannot directly regulate the machinery of state government, so it can’t tell state prisons what to do, as the Supreme Court held in a 1997 case: https://en.wikipedia.org/wiki/City_of_Boerne_v._Flores. Note a key point here is that these rights are statutory in nature, and go beyond the protection for religious liberty required by the constitution.

To work around that, Congress has imposed certain requirements as a condition of accepting federal prison funds. Among other things, it requires states to answer prisoner lawsuits for violations of these requirements. This is a common approach: Congress can’t directly regulate the states, but it can bribe them to agree to do things. But if the state doesn’t follow the conditions, then the only thing Congress can do is withdraw the money.

What this case holds is that the state’s consent to these lawsuits does not mean suits can be filed directly against prison guards who work for the state. This makes sense. A company might have a contract with another company that requires employees to follow various data security practices. The company might have rules requiring employees to follow data security practices. But if an employee doesn’t follow those practices, the other company can’t sue the employee directly. The employee isn’t a party to the contract. Similarly, the state may agree to certain requirements in return for federal funds. Prison guards may have to follow state policies to implement those requirements. But the prison guard is not a party to the contract between the state and federal government and cannot be sued for its breach.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: