Hacker News new | past | comments | ask | show | jobs | submit login

> Q. Is the compiler engine itself written in Delphi? How much does it differ from the Borland Pascal 7 compiler?

> A. The compiler is written in assembly language.

That's amazing to me. My first real language was Java, then Ruby, C#, JavaScript, Python, etc. -- and only a smattering of C/C++ in college.

I can't imagine building anything complex in x86 assembly, let alone a freakin' compiler!




Back then assembly makes sense and many pieces of "large" software were written in assembly (or at least a critical part of them).

Go back another decade and people naturally take assembly as the second language after they are done with BASIC. Those were teenage hobbyists. Machines then (Apple ][, C64, BBC, etc.) were much simpler and didn't have a lot of memory. It was a lot easier to wrap your head around it. Nowadays it's impossible to do so I think, unless you have a long track of assembly career.


I still would love to learn z80 assembly... I tried and failed to do so in high school (trying to write a game for my TI-83 calculator).


It was by far the fastest compiler I'd ever used. A full 10x faster than their Borland C++ compiler, which was faster than gcc. Delphi didn't do as many optimizations, but the compiled code had runtime performance within a few percent of C, and the lightning fast compiles were worth it for productivity.

It doesn't surprise me to hear it was written in asm.


FWIW i wrote a small raytracing benchmark in C and Pascal (99% the same code just "translated") some time ago[0], mainly for comparing compilers for retrocoding and in my results Delphi 2 produced code that took around the 149% the time the Visual C++ 6 program took. Interestingly Borland C++ 5 was slower, though it predates Delphi 2 (also i forgot to benchmark Borland C++ Builder).

(note that this is from the second table where i check compilers that can generate code running on Pentium 1 Win9x - the first table was with whatever compiler i had installed on my PC at the time)

Perhaps i'll try benchmarking it again some day, including running on actual older hardware.

[0] http://runtimeterror.com/tools/raybench/


Well, yeah, maybe if you are writing ray tracers. The focus of Delphi was object oriented data structures (especially for UIs) and there isn't a lot that the compiler can optimize when the function is packed full of method calls, which is why UI in Delphi was nearly identical performance to one in C++. If you want vector math to run fast, those C++ compiler optimizations are a lot more important.

Just to clarify, my main point was the speed at which it would compile the code, which was an order of magnitude faster than anything else.


FWIW what i wanted to point out was that even for something as a raytracer Delphi 2 wasn't really that much slower :-P. And as i mention on the site, if i was to use that on retro hardware i'd rather use Delphi 2 and write better code (IMO a good profiler is much more important than a good optimizer when it comes to writing fast code anyway) instead of VC++6 because Delphi 2 is much faster to use.

In practice it'd be fast enough anyway. Sadly i do not have anything fancy made with Delphi 2 specifically, but in this video[0] i play a software rendering 3D game i made for an MSDOS game jam last year (it also works on Windows 95[1]) which was made in Free Pascal that from the table i linked at produces executables with around the same performance as Delphi 2 (at least for the 32bit version without using any modern CPU instructions). The majority of the time is spent in the rasterizer, the innermost bits of which are written in assembly, so even if Delphi 2 was much worse at codegen it wouldn't matter much anyway.

(sometimes i do consider out of curiosity to convert the code to be compatible with Delphi 2, but it relies on language features like generics for the collections and on some FPC-specific bits for object de/serialization that would make the conversion non-trivial)

[0] https://www.youtube.com/watch?v=pk6pu4iRb5c

[1] https://i.imgur.com/iOhcUtf.png


> I can't imagine building anything complex in x86 assembly, let alone a freakin' compiler!

Note that it's massively simpler than a modern compiler. Simple data structures, very simple passes. If you're thinking about complex graphical manipulation like compilers now, that's not really what it was.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: