frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Thoughts on Generating C

https://wingolog.org/archives/2026/02/09/six-thoughts-on-generating-c
88•ingve•2h ago

Comments

rirze•1h ago
Love how he put a paragraph for someone asking, "why not generate Rust?". Beautiful.
artemonster•19m ago
<something something about having a hammer and seeing nails everywhere> :)
whizzter•1h ago
Having done this for a dozen of experiments/toys I fully agree with most of the post, would be nice if the the addition of must_tail attribute could be reliable across the big 3 compilers, but it's not something that can be relied on (luckily Clang seems to be fairly reliable on Windows these days).

2 additional points,

1: The article mentions DWARF, even without it you can use #line directives to give line-numbers in your generated code (and this goes a very long way when debugging), the other part is local variables and their contents.

For variables one can get a good distance by using a C++ subset(a subset that doesn't affect compile time, so avoid any std:: namespaced includes) instead and f.ex. "root/gc/smart" ptr's,etc (depending on language semantics), since the variables will show up in a debugger when you have your #line directives (so "sane" name mangling of output variables is needed).

2: The real sore point of C as a backend is GC, the best GC's are intertwined with the regular stack-frame so normal stack-walking routines also gives everything needed for accuracte GC (required for any moving GC designs, even if more naive generation collectors are possible without it).

Now if you want accurate somewhat fast portable stack-scanning the most sane way currently is to maintain a shadow-stack, where you pass prev-frame ptrs in calls and the prev-frame ptr is a ptr to the end of a flat array that is pre-pended by a magic ptr and the previous prev-frame ptr (forming a linked list with the cost of a few writes, one extra argument with no cleanup cost).

Sadly, the performant linked shadow-stack will obfuscate all your pointers for debugging since they need to be clumped into one array instead of multiple named variables (and restricts you from on-stack complex objects).

Hopefully, one can use the new C++ reflection support for shadow-stacks without breaking compile times, but that's another story.

ufo•51m ago
Related to shadow stacks, I've had trouble convincing the C optimizer that no one else is aliasing my heap-allocated helper stacks. Supposedly there ought to be a way to tell it using restrict annotations, but those are quite fiddly: only work for function parameters, and can be dusmissed for many reasons. Does anyone know of a compiler that successfully used restrict pointers in their generated code? I'd love to be pointed towards something that works.
Joker_vD•1h ago
> And finally, source-level debugging is gnarly. You would like to be able to embed DWARF information corresponding to the code you residualize; I don’t know how to do that when generating C.

I think emitting something like

    #line 12 "source.wasm"
for each line of your source before the generated code for that line does something that GDB recognizes well enough.
FpUser•14m ago
This is weird. As soon as I thought about the subject the relevant article showed up on HN.

I was thinking about how to embed custom high level language into my backend application written in C++. Each individual script would compile to native shared lib loadable on demand so that the performance stays high. For this I was contemplating exactly this approach. Compile this high level custom language with very limited feature set to plain C and then have compiler that comes with Linux finish the job.

UEFI Bindings for JavaScript

https://codeberg.org/smnx/promethee
104•ananas-dev•2h ago•54 comments

Sleeper Shells: Attackers Are Planting Dormant Backdoors in Ivanti EPMM

https://defusedcyber.com/ivanti-epmm-sleeper-shells-403jsp
37•waihtis•1h ago•8 comments

Thoughts on Generating C

https://wingolog.org/archives/2026/02/09/six-thoughts-on-generating-c
92•ingve•2h ago•7 comments

Show HN: Algorithmically Finding the Longest Line of Sight on Earth

https://alltheviews.world
234•tombh•6h ago•88 comments

GitHub Is Down

https://github.com/
45•albelfio•4m ago•9 comments

Long-Sought Proof Tames Some of Math's Unruliest Equations

https://www.quantamagazine.org/long-sought-proof-tames-some-of-maths-unruliest-equations-20260206/
28•ibobev•1h ago•2 comments

Hong Kong pro-democracy tycoon Jimmy Lai gets 20 years' jail

https://www.bbc.com/news/articles/c8d5pl34vv0o
79•tartoran•54m ago•36 comments

Medieval Monks Wrote over Ancient Star Catalog – Particle Accel Reveals Original

https://www.smithsonianmag.com/smart-news/medieval-monks-wrote-over-a-copy-of-an-ancient-star-cat...
12•bookofjoe•5d ago•0 comments

AT&T, Verizon blocking release of Salt Typhoon security assessment reports

https://www.reuters.com/business/media-telecom/senator-says-att-verizon-blocking-release-salt-typ...
87•redman25•1h ago•13 comments

Art of Roads in Games

https://sandboxspirit.com/blog/art-of-roads-in-games/
497•linolevan•19h ago•157 comments

It's not you; GitHub is down again

https://www.githubstatus.com/incidents/54hndjxft5bx
18•MattIPv4•7m ago•4 comments

Vouch

https://github.com/mitchellh/vouch
980•chwtutha•1d ago•426 comments

Humans peak in midlife: A combined cognitive and personality trait perspective

https://www.sciencedirect.com/science/article/pii/S0160289625000649
47•Brajeshwar•2h ago•12 comments

Like Game-of-Life, but on Growing Graphs, with WASM and WebGL

https://znah.net/graphs/
45•znah•1d ago•8 comments

Discord Launches Teen-by-Default Settings Globally

https://discord.com/press-releases/discord-launches-teen-by-default-settings-globally
51•dm•1h ago•28 comments

Show HN: Browse Internet Infrastructure

https://www.wirewiki.com
88•pul•3h ago•15 comments

Matrix messaging gaining ground in government IT

https://www.theregister.com/2026/02/09/matrix_element_secure_chat/
146•rbanffy•4h ago•109 comments

Nobody knows how the whole system works

https://surfingcomplexity.blog/2026/02/08/nobody-knows-how-the-whole-system-works/
143•azhenley•10h ago•109 comments

Show HN: Printable Classics – Free printable classic books for hobby bookbinders

https://printableclassics.com
25•bookman10•4h ago•6 comments

Offpunk 3.0

https://ploum.net/2026-02-09-offpunk3.html
126•todsacerdoti•5h ago•25 comments

Roman industrial hub discovered on banks of River Wear

https://www.durham.ac.uk/news-events/latest-news/2026/01/roman-industrial-hub-discovered-on-banks...
43•andsoitis•4d ago•7 comments

AI Doesn't Reduce Work–It Intensifies It

https://hbr.org/2026/02/ai-doesnt-reduce-work-it-intensifies-it
125•swolpers•1h ago•77 comments

AirPods Pro 4 Could Feature Cameras to 'See Around You'

https://www.macrumors.com/2026/02/09/airpods-pro-4-could-feature-cameras-to-see-around-you/
7•geox•23m ago•5 comments

Safe Drinking Water Is a Basic Human Right That Texas Prisons Fail to Respect

https://truthout.org/articles/safe-drinking-water-is-a-basic-human-right-that-texas-prisons-fail-...
6•wahnfrieden•24m ago•1 comments

Show HN: Minimal NIST/OWASP-compliant auth implementation for Cloudflare Workers

https://github.com/vhscom/private-landing
28•vhsdev•4h ago•8 comments

LispE: Lisp Interpreter with Pattern Programming and Lazy Evaluation

https://github.com/naver/lispe
86•PaulHoule•4d ago•16 comments

Tessellation Kit (2016)

https://sciencevsmagic.net/tes/#0.5.0.1.aaaaaaaaa
38•surprisetalk•5d ago•3 comments

Ask HN: Do provisional patents matter for early-stage startups?

3•gdad•34m ago•1 comments

Show HN: A custom font that displays Cistercian numerals using ligatures

https://bobbiec.github.io/cistercian-font.html
141•bobbiechen•17h ago•33 comments

Every book recommended on the Odd Lots Discord

https://odd-lots-books.netlify.app/
149•muggermuch•16h ago•61 comments