HNHacker News
TopNewBestAskShowJobs

aka-rider

78 karma · joined February 29, 2020

submissionscomments
aka-rider··on Port of the TypeScript compiler, checker and lsp to Rust, by LLM
Makes sense.
aka-rider··on Port of the TypeScript compiler, checker and lsp to Rust, by LLM
GC doesn’t affect performance (at least visibly), memory allocations on critical paths do. Moreover, Rust ARC may cause memory fragmentation and perform worse than a GC.

Writing Rust, Zig, or Go, you would still control memory manually, where it matters.

aka-rider··on Trusting-Trust Attack against an Entire Linux Distribution
Yes and no. We used to have rampant script kiddies back in the '90s and early 2000s. After 2005-ish, well maybe 2010, most systems became adequate enough to not trust users' input, bug bounties, security as a separate role, etc, etc.

It would take at least some knowledge to hack, not just a random script from a forum.

Now, with LLMs, it's the '90s all over again.

aka-rider··on Actively exploited sandbox RCE in all Chromium versions
Google is routinely buying and destroying competitors. They lower prices to kill competition en-masse. They promote their own products in search and elsewhere over paid ads.

Search Engine have chicken and egg problem, you can only have a good search if enough people use it to tune the ranking and see enough search spam cases.

“Just compete with a monopoly on their own field with one hand tied behind”

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I don’t know about Windows but between MacOS and Linux mine experience is smooth. I can even cross compile from Linux to MacOS.
aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
True, the main problem is how to split the work. They decided to go file by file.

To be fair, I haven't try exactly "rewrite in Rust" prompt, but I cannot imagine for this to work.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I don't know. The most Go software I encountered is IO-bounded, and usualy it's network latency. Rust cannot meaningfully improve this.

Although, in the agentic environment, a benefit of not having GC at all definitely helps.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
> I have rewritten several things from eg. Python to Rust, Rust to Go very recently.

What is the scale? Because I'm pretty sure it's impossible to one shot 65k LoC with "good luck, make no mistakes" prompt.

I also did this within a subscription. I counted the number of tokens afterwards and calculated the cost as if I'm paying per token. $400 is of course arbitrary, but it's a ballpark number, bun was $165000.

> In my experience it mostly comes down to the harness (or lack of) that you use.

Yep, it is.

Tokens per task is a good proxy measure of skills, 'superpowers' or any other.

Either a skill gets you the thing more efficiently (less tokens), or you don't need to redo the result afterwards (less tokens). I benchmark all my skills that way.

Models need less and less steering at this point, especially frontier ones.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I'm glad to help
aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
>files might diverge

The way rune works with files minimizes chances of silent corruption. I keep original byte blobs immutable, separately there is a journal (kinda WAL) of positional deltas (inserts and deletes).

So I only need to validate that blob + deltas = snapshot.

Disk IO is encapsulated through VFS, and writes are atomics (write to a temp file, then rename).

Separate virtual rendering buffer is built on top of that. Rune, like Obsidian, renders markdown preview inline, so the same chunk could be rendered as "Header" as well as `## Header` when under the cursor.

All of that makes it quite easy to work with text. The core function is to translate offset in a byte array to line and column and back, which is pure math and relatively easy to test.

Another trick that helped a lot is to use sqlite extensively: blobs, deltas, vfs, redo and undo history graph are all sqlite tables.

I noticed that LLMs make stupid decisions when it comes to data structures, but they understand CRUD and SQL, so I turned all Rune's internals into dumb CRUD.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
This isn't complete example. I don't remember the details unfortunately.

But somehow compiler has decided that i <= limit is always true.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
Thanks for the feedback. My main goal was to present the idea with an intermediate representation, I didn't payed much attention to the specifics of this translation, it would vary wildly depending on code bases.

65k LoC of Go without comments resulted in roughly 60k LoC of Rust witout comments (code column of the cloc tool).

The error handling is not so different between Rust and Go, in both cases I cannot panic to avoid the data loss. So it boils down to if (failure) return something for graceful degradation. And generally errors in my case (a text editor) are rare, only disk IO, which is encapsulated in one VFS module, everything else, like non-closed brackets in code is expected behavior.

The biggest differences were in third party libraries, UI, markdown parsing — completely different API and paradigms.

> Performance characteristics of resulting rust

I haven't measured. I don't think there's any significant difference between Go and Rust if app doesn't do allocations on a critical path. The reason I started this project was mainly to experiment (now I use similar approach to refactor much bigger legacy code base), and tree-sitter support is better Rust so it seemed like a good fit.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
it depends, obligatory xkcd https://xkcd.com/1172/
aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
Nice. Yeah, the general problem is how to divide and conquer. Your method is not always available (it depends on the language pair), in my case, Go packages didn't translate into Rust crates 1:1.
aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
Not at all. The example was an experiment.

I did because I have a huge legacy code base, a distributed monolith, a few millions lines of code. Ideally, I want to get rid of it.

At this point, I know a recipe to break the monolith, so I finally could eat the elephant piece by piece.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
Of course language concepts don't translate.

My point is that one can translate the data flow to another language.

You could imagine any program as input -> [blackbox] -> output. For example, same pixels rendered on the screen provided identical keyboard input.

I propose a way to decompose the blackbox.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
> if you just let it rip on the problem for hours

In my experience, you can get good results if Fable does't write code itself, only spawn subagents.

I can run Fable for 10 hours, and it would output 50k tokens and read 300k (30% of the context window). The resulting code is okay-ish. I would rarely merge LLM-produced code first try without an adversary review.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
Fable is good at instruction following, so just adding the snippet I mentioned in the post is good enough for the most cases.

There is a way to control tool invocations at the harness level when writing skills or agents.

Example: ~/.claude/agents/critic.md

    ---
    name: critic
    description: >
      Plan Critic. Reviews an implementation plan. Use before the implementation.
    tools: Read, Agent
    ---
For Claude skills, the frontmatter is different, the keys are:

    allowed-tools: Read Grep
    disallowed-tools: WebSearch Glob

https://code.claude.com/docs/en/tools-reference
aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
>feed the same input to the old Go app and the new Rust then diff the outputs.

Yes, I completely forgot to mention, this is exactly my case. Rune is a TUI editor, so I feeded the same terminal sequences to the old and new apps.

It didn't translate 1:1 (I ported core editor first, there were side panels, and different chrome elements) so I instructed LLM to use ttyd (tty -> browser render), Fable then could open both apps with playwright, make and compare screenshots.

To rephrase, one critical component is to establish a feedback loop for the model. This new generation of models: Opus 5, Fable, GLM-5.2, even Qwen3.8-27B can self-correct, provided they know whether they are progressing or not.

A month ago, especially smaller model would fall into a rabbit hole it dug for itself and would never recover. This generation can sometimes run tens of hours without losing track.

I still wouldn't trust a model after 70% context window, but the progress is noticeable.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I don't remember the details, roughly it was unexpected invocation of move semantic, causing use after free in a loop.

My all-time favourite example is (again, my memory, I may be a bit wrong):

    for (int i = 0; i < (size_t)limit; ++i) {
    }
at some point limit could potentially become greater than INT_MAX, the compiler decided that i<limit could never be true because that would cause signed int overflow which is UB, so it "optimized" the loop into

   while(true)
signed unsigned mismatch makes me shiver
aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
My understanding is, direct port is more expensive besides toy projects of course, looking at Bun and also listening to people who've done a few language conversions, they extract something first.

If not an intermediate representation, my first question would be: how to split the work. You cannot just prompt full rewrite of 60K LoC, you cannot do it module by module — modules do translate 1:1, like in my case golang packages did not matched Rust crates. Bun did file by file.

With hierarchical state machines in the middle, I did it almost in one shot.

aka-rider··on How accurate have Ed Zitron's AI skeptic predictions been?
It is all very unevenly distributed. SaaS and general web is basically on auto mode.

A lot of infra is vibe coded nowadays too.

Even prototypes are contributing to the speed of software development. Many people vibe code throwaway dashboards around the main platform which gives a lot of insights.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
>You aren't Claude at least.

I absorbed so many different models at this point :)

Thank you for the kind words.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I would be afraid to do this with C++.

My friend once sent me a snippet, maybe 10 lines of C+++, asking "can you spot the UB?".

So I'm staring at these 10 lines, I KNOW there is an UB. I wasn't able to find it without a hint.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
> I'd highly recommend a direct "port"

I'm sure there are other caveats. Also cost of the more or less straightforward Bun port was $165000 for 500KLoC.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I doubt that it is possible with GLM.

I haven't played with GLM 5.3, only with 5.2, so I cannot say for sure.

GLM is at the level of Opus. Fable is something different entirely. It is capable of tracing the data flows of the app, I even tried it in a huge PHP codebase, it works.

PHP is a weird beast because it allows something like

    $v = 'SomeClass' + 'Controller'
    ... // and later
    new($v)

In other words, it could be hard to understand the code without running it, Fable reads this.

And another distinct feature of Fable — it is an amazing orchestrator. I prohibit it basically read and write, and it operates a swarm of haiku and sonnet.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
I wrote this elsewhere. Reading so much LLM output may have affected how I write.

Probably I need some fresh air and a good fiction book.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
This is genuinely how I write :'(

It is probably because I read tons and tons of LLM output.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
But we know, Bun was 535496 lines for $165000.

The whole point of this experiment was to try and make the rewrite as cheap as possible.

aka-rider··on I used Fable to rewrite 65kLoC of Go in Rust. It cost $400
this is the meat, yes.
Page 1 of 2Next →