Live data from Hacker News

The unexpected effectiveness of one-shot decompilation with Claude

blog.chrislewis.au

101–110 of 133 posts

Re: The unexpected effectiveness of one-shot decompilation with Claude

#101
post #99

Yeah, it works great for porting as well. I tried it on the assembler sources of Prince of Persia for Apple ii and went from nothing to basics being playable (with a few bugs but still) on modern Mac with SDL graphics within a day.

That's impressive. Did you convert POP from 6502 to C?

Yup. Still fighting some collision bugs, but it mostly works. I'll post it when it's complete. What I actually wanted to do is try to put fluid movement into it - something closer to Dead Cells, just for fun to see how it would change the feel of it.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#102
post #38

For anyone else who was initially confused by this, useful context is that Snowboard Kids 2 is an N64 game. I also wasn't familiar with this terminology: > You hand it a function; it tries to match it, and you move on. In decompilation "matching" means you found a function block in the machine code, wrote some C, then confirmed that the C produces the exact same binary machine code once it is compiled. The author's p…

I'd like to see this given a bit more structure, honestly. What occurs to me is constraining the grammar for LLM inference to ensure valid C89 (or close-to, as much can be checked without compilation), then perhaps experimentally switching to a permuter once/if a certain threshold is reached for accuracy of the decompiled function.

Eventually some or many of these attempts would, of course, fail, and require programmer intervention, but I suspect we might be surprised how far it could go.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#103
post #37

Earlier quoted context omitted.

It would be "source available", if anything, not "open source". > An open-source license is a type of license for computer software and other products that allows the source code, blueprint or design to be used, modified or shared (with or without modification) under defined terms and conditions. https://en.wikipedia.org/wiki/Open_source Companies have been really abusing what open source means- claiming something is…

But clean room reverse engineered code can have its own license, no?

If we're talking about actual clean-room reverse engineering where only the overall design or spec is copied and not the specific code, then yes. In this process, one person would decompile the original and turn it into a human-readable spec, and another person would write their own implementation. But the decompiled code itself is never distributed.

That's very different from the decompilation projects being discussed here, which do distribute the decompiled code.

These decompilation projects do involve some creative choices, which means that the decompilation would likely be considered a derivative work, containing copyrightable elements from both the authors of the original binary and the authors of the decompilation project. This is similar to a human translation of a literary work. A derivative work does have its own copyright, but distributing a derivative work requires permission from the copyright holders of both the original and the derivative. So a decompilation project technically can set their own license, and thereby add additional restrictions, but they can't overwrite the original license. If there is no original license, the default is that you can't distribute at all.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#104
post #12

Makes me wonder if decompilation could eventually become so trivial that everything would become de-facto open source.

If progress continues, someday it'll be possible to generate the source code for any binary and make a native port to any other platform. Some companies might be upset, but it'll be a huge boon for game and software preservation.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#105

Earlier quoted context omitted.

But, for example, isn't Cannonball (SEGA Outrun source port) open source? https://github.com/djyt/cannonball

No it is not. There is no license in that repository. Relevant: https://github.com/orgs/community/discussions/82431 > When you make a creative work (which includes code), the work is under exclusive copyright by default. Unless you include a license that specifies otherwise, nobody else can copy, distribute, or modify your work without being at risk of take-downs, shake-downs, or litigation. Once the work has other c…

There is a license: https://github.com/djyt/cannonball/blob/master/docs/license....

...but it's very clearly not an open source license.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#107
Rather than insisting on byte perfect matches, sometimes you can prove code equivalence of machine code sequences using SAT solvers. That might be an interesting extension, maybe giving clearer code output and/or solution to difficult functions in some cases.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#108
post #42

Earlier quoted context omitted.

Documentation is one place where humans should have input. If an LLM can generate documentation, why would I want you to generate it when I can do so myself (probably with a better, newer model)?

I definitely want documentation that a project expert has reviewed. I've found LLMs are fantastic at writing documentation about how something works, but they have a nasty tendency to take guesses at WHY - you'll get occasional sentences like "This improves the efficiency of the system". I don't want invented rationales for changes, I want to know the actual reason a developer decided that the code should work that w…

Exactly. Often this information is not actually present in the code itself which is exactly why I would want documentation in the first place, given that I can always read the code myself if needed.

Re: The unexpected effectiveness of one-shot decompilation with Claude

#109

Earlier quoted context omitted.

Documentation is one place where humans should have input. If an LLM can generate documentation, why would I want you to generate it when I can do so myself (probably with a better, newer model)?

That's great if those humans are around to have that input. Not so much when you have a lot of code from 6 years ago, built around an obscure SDK, and you have to figure out how it works, and the documentation is both incredibly sparse and in Chinese.

If you want to have an LLM piece together and translate documentation, this seems fairly reasonable

Re: The unexpected effectiveness of one-shot decompilation with Claude

#110
post #50

Earlier quoted context omitted.

Documentation is one place where humans should have input. If an LLM can generate documentation, why would I want you to generate it when I can do so myself (probably with a better, newer model)?

Because it takes time and effort to write documentation. If people __can__ actually read undocumented code with the help of LLMs, why do you need human-written documentation really?

I can read code without the help of LLMs, too. Human documentation tells me why the code was written.
Post reply on HN