3 ms·
What I don't understand is if they were going to translate Zig to unsafe Rust, why not just build a translation tool for it? You could do a one-to-one mapping o
by smasher164 5mo ago
What I don't understand is if they were going to translate Zig to unsafe Rust, why not just build a translation tool for it? You could do a one-to-one mapping of language constructs, hardcoding patterns in your codebase, and as one friend put it "Tbh they could've just hooked up zig translate-c to c2rust". They would get deterministic translation, would probably have not been a heavy investment to build, and the output would have the same assurances as the input.
In this case, I would trust the output even less than the input. The input was memory-unsafe but hand-written. The output is memory-unsafe but also vibe-coded and has had no eyeballs on it. What is the point of abusing agentic AI for this use-case?
- whateveracct 5mo ago[flagged]
- brookst 5mo agoThanks for updating the age-old complaint about the printing press.
- whateveracct 5mo agoi wouldn't say that was as disproportionate
- ModernMech 5mo agoBecause they aren't trying to raise billions of dollars to build a translation tool.
- Animats 5mo ago> "Tbh they could've just hooked up zig translate-c to c2rust". Have you ever seen what comes out of c2rust? It's awful. It relies on a library of functions which emulate unsafe C pointer semantics with unsafe Rust. A few years ago, when I was struggling with bugs in OpenJPEG (a JPEG 2000 decoder), someone tried running it through c2rust. The converted unsafe rust segfaulted at the same place the C code did. It's compatible, but not safe. Main insight: don't do string manipulation in C or unsafe Rust. It's totally the wrong tool for the job.
- wrs 5mo agoWhat they’ve done here isn’t safe either, and doesn’t have the consistent translation of rust2c.
- swiftcoder 5mo ago> The converted unsafe rust segfaulted at the same place the C code did. It's compatible, but not safe That is indeed the point of c2rust. It gives you a baseline that is semantically identical to the original codebase, and with that passing the full test suite, bug-for-bug, you can then start gradually adopting rusty idioms to improve the memory safety of the codebase.
- Animats 5mo agoWhat comes out of c2rust is not intended for human consumption. It's more verbose than the original and harder to work on, but no safer. You lose the C idioms that people understand, while not gaining Rust idioms. It's like working on compiler-generated assembly code by hand. 2022 discussion on HN.[1] There's a DARPA funded effort called TRACTOR, Translate All C To Rust, which has funded some efforts to develop a usable translator.[2] It's about 10 months after award, with no reported progress. I've been checking the personal sites of the academics involved, and they barely mention the project, although $5 million has been allocated to it.[3] The approach comes from U.C. Berkeley - let the LLM generate slop, check it using formal methods.[4] Not expecting near-term results. [1] https://news.ycombinator.com/item?id=30169263 https://news.ycombinator.com/item?id=30169263 [2] https://csl.illinois.edu/news-and-media/translating-legacy-code-for-a-safer-future-darpa-backs-effort-to-convert-c-to-rust https://csl.illinois.edu/news-and-media/translating-legacy-c... [3] https://chandrasekaran-group.github.io/ https://chandrasekaran-group.github.io/ [4] https://metalift.pages.dev/ https://metalift.pages.dev/
- swiftcoder 5mo ago> let the LLM generate slop, check it using formal methods I'm much more bullish on the opposite approach. Perform the naive translation, let the LLM loose on cleaning it up...
- mr_00ff00 5mo ago“Tbh they could've just hooked up zig translate-c to c2rust” This doesn’t work like you think it does. These things are full of errors and make the code very verbose and hard to reason about. It works with small apps, not entire rewrites.
- deleted 5mo ago[deleted]
- rattray 5mo ago> why not just build a translation tool for it? They did ;) a highly dynamic one...
- giancarlostoro 5mo agoI mean, LLMs have been really good at translating code for a while now, which is why I'm more surprised that others are surprised this happened. They claim its a marketing trick despite the fact that they have to manage and maintain a fork of Zig if they don't switch languages.
- bendmorris 5mo agoThey don't have to do that at all. They could've used mainline Zig, without their vibe coded changes to it.
- giancarlostoro 5mo agoThey changed Zig because it was inadequate for their efforts, why would I keep using a tool that is inadequate if there's a better tool?
- coldtea 5mo agoBecause maybe they're wrong, and what they think is "inadequate for their efforts" is just due to their overengineering stupidity.
- giancarlostoro 5mo agoReally? What is this reddit? If you are going to resort to name calling at least provide some genuine facts? Show me what in their Zig fork was too much? You assume Zig is “finished” being built? Because thats a bold claim, seems every major Zig change is some very major shift in the language. Zig is where Rust was before it did the borrow checker system.
- 5mo ago
- deleted 5mo ago[deleted]
- lioeters 5mo agoThat would have been the proper way to port a codebase to another language, by parsing the syntax tree and applying deterministic and verified transformations.
- adsharma 5mo ago+1 - I was making exactly this argument in other threads. But I have a slightly different take on how software should be written. Translating zig -> rust is more complex than writing a JPEG parser in static python and then lowering it into zig and rust differently using idiomatic construct for each language. Towards that end, I've created a parser for a dialect of python which is suitable for this purpose. It should maintain compatibility with the vast majority of python code out there, while picking up some rust/zig features that make translation easier. JPEG parser included in the assets of the skill for a flavor. https://github.com/py2many/static-python-skill https://github.com/py2many/static-python-skill https://github.com/py2many/spy-ast https://github.com/py2many/spy-ast
- risyachka 5mo agoAt this point bun is a free adspace for Anthropic and Claude. This is the only thing that would explain the rewrite
- Pay08 5mo agoYeah, this is the same annoyance I have with AI psychosis. Deterministic tasks should be done by deterministic tools. The amount of people I've seen translate morse code using AI is far larger than it should be.