There Is Life Before Main in Rust
64 points
1 day ago
| 5 comments
| grack.com
| HN
smy20011
5 hours ago
[-]
> This post is 100% human-written. Claude was used for feedback and to assist with the linker symbol diagram. Cursor was used for feedback and to ensure examples were compilable.

Love this, I hope every blog have the same disclaimer about how AI is used.

reply
rootnod3
5 hours ago
[-]
If Claude gave feedback then it’s not really 100% human written is it?
reply
frakt0x90
4 hours ago
[-]
I'm pretty much hardline anti-AI and even I would say this is too far. If I read documentation or ask my wife to review something, those people did not write the final product. Perhaps it would be mentioned in a citation, like this person has.
reply
vitally3643
4 hours ago
[-]
It was written on a computer with a keyboard, so clearly it's 0% human written
reply
orthecreedence
3 hours ago
[-]
Show me the cave drawing version of this post or I will absolutely not be reading it.
reply
ronsor
5 hours ago
[-]
If you merely get feedback from a human, are they now a co-author?
reply
wahern
1 hour ago
[-]
If the feedback or involvement is substantive it used to be common to mention this, even if just in a prologue, epilogue, or footnote. You still see this is some academic writing and some journalism, where authors mention with whom they consulted. Books and other literature have tended to dissociate people from sources of knowledge, and the Internet furthered the dissociation. But honest writing should disclose all the sources of substantive claims, preferably traced back to primary sources. Legal writing and scientific papers are perhaps the last bastions where this is still done, or at least expected to be done, fairly rigorously, but the manner in which AI is used seems qualitatively more problematic for maintaining any kind of rigor in citation.
reply
mmastrac
53 minutes ago
[-]
FWIW this post has both a "thanks" section for the human reviewers, and numerous footnotes linking to more authoritative sources.
reply
hresvelgr
55 minutes ago
[-]
Most human editors are not given credit, why would it be any different for an LLM?
reply
khuey
3 hours ago
[-]
If you run spell check on a document is it no longer 100% human written?
reply
Sharlin
4 hours ago
[-]
Editors (as in, the human kind) are not co-writers either.
reply
sophacles
2 hours ago
[-]
Yeah! It was typed into a computer and never even put on paper. How can you say it was written at all?

Further, can anything be "100% human writt even if it uses pen and paper? No of course not! Unless it is created by pricking a finger and put on human vellum, it's only partially human written.

Seriously though - if you want to do stupid purity test games, at least be properly pure about it. This half-assed nonsense is just trite.

reply
mmastrac
5 hours ago
[-]
Author here, happy to answer any questions. I've been working on building some higher-level abstractions on link sections (specifically, link-time optimized collections like maps (1) and sorted slices (2)) and wanted to share the hard-fought knowledge from the last couple of months.

There's a decent amount of knowledge around pre-main work in Rust, but I think this is one of the first attempts to walk through mutable link sections, which open up a pretty wide world of optimization, IMO. Even without mutability, I figured there isn't nearly enough documentation on these approaches out there.

(1) https://docs.rs/scattered-collect/0.20.0/scattered_collect/m...

(2) https://docs.rs/scattered-collect/0.20.0/scattered_collect/s...

reply
jeffbee
4 hours ago
[-]
The general lesson of these things is main is not that special and it pays to understand how your program actually starts. This has little/nothing to do with Rust or other language tools. On Linux, given a static ELF program, the kernel returns to the IP given by e_entry, which can proceed to do anything. If the program is dynamic (has a .interp) then it loads the interpreter and returns to its e_entry instead. The interpreter, in turn, can do absolutely whatever.
reply
ameliaquining
19 minutes ago
[-]
The relevance to Rust is precisely that it doesn't have life before main at the language level; therefore, if you need it, you need to use these kinds of linker hacks (which fortunately are amenable to encapsulation through macros). By contrast, if the article were about C++, the focus would be on "what happens under the hood when you use static initialization, in case you were curious" rather than "how to use these low-level mechanisms to do something not otherwise possible".

Which you should think very carefully before concluding is the case, as it's responsible for rather a lot of bugs in C++. I think in Rust it is mostly used for registry-pattern type stuff since the const system can't currently(?) handle that.

reply
wild_pointer
3 hours ago
[-]
I thought it was about prehistoric Rust before the main branch was created :)
reply
Surac
3 hours ago
[-]
everything abount Rust MUST have some AI in it nowerdays. even this article
reply