Unofficial Hacker News companion — get notified on comment replies, and more.

Borland's DOS compilers, rebuilt from their own binaries (opens external site)

260 points by frostbyte7 2 days ago | github.com | 95 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (20)

  1. Sincere question: why? Source like this is a notch better than raw decompiler output in the pre-AI era, but what's the expectation / use case?

        if((ES_B(_BX,MEMB_FLAGS)&3)==3) {
            _DI=ES_W(_BX,MEMB_VALUE);
            _ES=SYMBOL_POOL_SEG;ES_W(0,SYM_TYPE)=base;
            if(ES_W(_DI,SYM_FUNC_KIND)==2) {
                while(!TYPES_COMPATIBLE(TYPE_W(SYM_W(_DI,SYM_TYPE),TYPE_TARGET),TYPE_W(base,TYPE_TARGET),0)) _DI=SYM_W(_DI,SYM_NEXT_OVERLOAD);
            } else {
                while(!SAME_SIGNATURE(SYM_W(_DI,SYM_TYPE),base)) _DI=SYM_W(_DI,SYM_NEXT_OVERLOAD);
            }
            if(_DI==0) {_DI=_DI;goto next_param;}
    
    I grant you that it's a thing you can do with agents, and it's impressive that it works, but once the tokens are spent, what does anyone get out of it? I guess I wonder if AI projects are becoming a bit of a "social proof of money spent".
    Replies (7)
    1. Oh, that's basically assembler
      Replies (2)
      1. I wonder how much of the original source was assembler and this is trying to turn it into the C code that it never was.
        Replies (1)
        1. I've spent some time on the problem of deriving equivalent C to codebases that were not originally C and it is quite challenging. For documentation purposes and future maintainability I think it's useful, but decomposition is an active area of research with a lot of open problems.
      2. Turbo C actually let you use _BX and _ES as plain variables. Borland's own compiler would take that code without blinking.
    2. Is it even better than raw decompiler output? Frankly, I have been saying this forever but always criticized: getting C output that compiles has always been the easy part, getting stuff that is readable is actually where the problem is, and franky these "AI decompilers" are hardly an improvement so far.

      But people act as if "well we got something that compiles down to the same binary, this must be the actual C source!" Welp. It couldn't be more different than the original source. In fact, it's probably even distracting if your goal is to reconstruct the original source. This is just AI slop in a form that you can't even easily recognize.

      Not to mention the licensing aspect of all of this. One should be wary of Watcom because of its terrible license, even though it is technically Open Source.If as a consequence Watcom is kind of a minefield, I don't even know how to start describing this. The trenches at Verdun?

      Replies (1)
      1. IMO there are two things that decompiling is useful for:

        1. Understanding how the program works. But for this you need a good decompilation, not just "portable assembly in C"

        2. Porting to a new platform. Once you have something that builds with a C compiler, you can rebuild it for a different platform, usually more performantly than running in an emulator. And it's often doable (if a lot of work) to also swap out graphics APIs, etc. But I'm not sure there's anyone who would care to run Borland DOS compilers on e.g. apple-aarch64, and DOSbox is more than good enough for anyone who does.

        Replies (2)
        1. Portable assembly in C is a good first step. Then you can start to name leaf functions and variables… and look for common inlined bits. You can confirm all your higher level transformations continue to produce equivalent bits.

          You can leave a model to crank on this for a couple of days and get something much closer to idiomatic source.

          It will not be THE source but it will be readable source that produces the same bits.

        2. Note that generating portable C is not as easy as generating "C that compiles to the same bytes", either.
    3. I guess AI projects are mostly for individual’s fun. It’s OK.
      Replies (1)
      1. I mean, it can also be fun to buy a fast car or spend money on an NFT of a monkey, but we were never celebrating that on HN. Historically, hobby projects on the front page focused on personal growth, practical utility, or a more abstract sense of wonder: "whoa, I didn't know you can do that with a computer".

        I guess now, we're to some extent running on "it looks like a thing that would have required skill and determination in the bygone days, but now just requires $1,000, and the author had $1,000".

        Replies (3)
        1. I agree with you and I’d not brag about AI vibe coding if I ever did it. But for a lot of people it’s very fun and they are probably the majority.
        2. Pretty much you need less than 10 dollars to do this with DeepSeek...
        3. > just requires $1,000, and the author had $1,000

          Huh? What is that attitude of HN that mocks people for trying new things. Do you know how much effort the author spent to do this? Just a prompt?

          Do you also mock people for using chainsaw to make furniture instead of more basic tools?

          Replies (1)
          1. If the furniture looked good, I'd be amazed at someone who used a chainsaw to make furniture. That would be an impressive feat!

            (I expect this exists, even.)

            Replies (1)
            1. Its a meme... If you can do it with a chain saw, there is a chain saw contest for it. There are multiple I-can-make-an-adrondac-chair with a chain saw contests, and no I-can-roll-a-cigar with a chainsaw.
    4. That's just wrong usage of agents in this project, many models are capable of reconstructing idiomatic and really close to the original source code with a proper tooling and prompting (I mean, you need to understand what you're doing to get such result). It's sad to see this level of reconstruction with all the resources we have available.
    5. if i have 20 versions of one function to try, i can test all 20 from one script, no DOS. in the Ultima 7 test, all 922 C compiles matched old Borland. ugly code yes, but this part i would use :)
    6. I would imagine it would make a good material for AI to learn from.

      Given the hardware constraints software engineers had at the time, that code is a piece of art in terms of optimisations. We don't write like that anymore. Now days we optimise for readability and mintainability (rightfully so - optimize later).

      Not many people now days can write a complete IDE which can run on a machine with 64 kilobytes of RAM... :)

    7. Some of the code style in the repo is really odd. Typically all caps in a C identifier means it's a macro. Some code I saw used it for function names.

      Seems weird that an LLM would make that choice.