Hacker News new | ask | show | jobs
by zozbot234 19 days ago
Memory management annotations are actually quite rare in Rust. It mostly uses plain RAII as seen in C++. You do need to annotate whenever an object may have multiple "owners" extending its lifecycle (which requires refcounting) but that's often directly visible in the problem domain.
1 comments

& and &mut is all over the code in Rust. &T by far the most common arg type.

In the OP article, they mention 'don't need to worry about thread cause the concept does not exist' - well, & does not exist in Python.

Those things are related to low-level computational issues (memory management) not problems space issues (moving money, transcoding the file, checking the spreadsheet), so a lot of &/&mut etc. and all that extra thinking slows down AI for the same reason it slows down you and I.

In particular, building in rust requires us to think a bit different about how we create the program in the first place and I don't think AI is very good at architecture yet.

Probably ... eventually none of this will really matter though, it will just be like 'compiler pedantry' for the small number of people who work on those things.

There is a huge semantic difference between sharing an object by providing a reference to it, passing the ownership of the object and passing a copy. It’s not a technical low level detail because the results can differ. Many developers use those distinctions in Rust to encode business rules, not to optimize memory use.

Similarly there is an important semantic difference between something you can change and something you shouldn’t change. Again - this can be used to express business logic constraints, similarly to how you can use static types to enforce other properties like e.g. „age must be a number”.

While you may say you can get away with just sharing references everywhere like Java or JS do, and not care about immutability, that’s like saying the only type you need is string and hashmap and you can code everything. And you just document in comments when strings contain numbers. I saw code like that in PHP once. Fun.

"There is a huge semantic difference between sharing an object by providing a reference to it, passing the ownership of the object and passing a copy."

Yes - of course there is!

You're totally right!

But that semantic difference does not exist in most languages.

For good reason.

That 'semantic difference' only matters in a specific context - wherein you need to have the difference, usually for performance reasons.

There's no need to expose that semantic difference in the surface language, in most cases.

And that 'semantic difference' requires an enormous amount of thinking to process across the system. It's a huge amount of possibly unnecessary work.

Making the AI have to deal with that layer of design concern is a big cost you only want to deal with if it's worth paying the price.