[fpc-other] What makes a Compiler project (like FPC) special?

Florian Klämpfl florian at freepascal.org
Thu May 25 20:48:32 CEST 2017


Am 25.05.2017 um 16:18 schrieb Graeme Geldenhuys:
> This is directed at Florian primarily, but any other FPC core member is welcome to chip in.
> 
> different to any other software project... It has really bugged me...
> Why is it different, and What is different?

Because they are basically a mess of spaghetti code and modules :) And this is not the writers fault
but simply their nature, they are a very complex piece of software were everything is inter winded.
In theory, everything sounds simple: one has a front end consisting of a scanner and a parser and a
back end consisting of an optimizer, a code generator and an assembler. Front end and back end are
accessing the symbol tables. However, in practice things look different. We try to keep fpc layered
and everything, nevertheless, the unit dependency graph looks terrible, see attachment (resized, I
can send a full fledged pdf if someone is interested). Simple things often mean that one has to dig
upside down and one is often bitten by several side effects or interferences of changes. I am really
familiar with the code of FPC, but I do not want to know the hours I spent in e.g. r36325 (which is
basically 100 lines of new code, rest is copy&paste and moving code around) due to such effects.
Code sample for the "spaghetti" nature, just look at the needtemp function in fpc/compiler/ncal.pas
at line 4589: it determines if an argument of an inlined subroutine needs to be copied to a temp.
The code is commented very well, it is almost literate programming, everything is split into
multiple if statements, nevertheless it is very unreadable. Of course,
EveryIfStatmentCouldBeMovedToAnExtraFunctionWithADescribtiveLongName, but I doubt that it makes it
more readable in the sense of being understandable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fpc_fullgraph.jpg
Type: image/jpeg
Size: 74759 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-other/attachments/20170525/a2d92484/attachment-0001.jpg>


More information about the fpc-other mailing list