Hacker News new | ask | show | jobs
by JulianMorrison 1400 days ago
Pascal family languages parse quickly because they won't let you use anything before it's defined.
4 comments

True, AIUI, but there's a bit more to it than that.

This paper is very readable and talks about Niklaus Wirth's ruthless approach to compiler optimization. https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90...

Probably a controversial opinion, but I absolutely wish this was more common. It's a thing in F# as well. With JS/TS projects I always ensure the ESLint rule for only using what's been declared before is enabled.

I don't want to scroll up and down a file constantly when referring to previous things that might reference something at the bottom of the file, which then references something near the top, which then references something in the middle, which then references something at the bottom again... I despise working in that manner.

I find it a non issue when you can use go to definition and go to previous position shortcuts.
There's a reason book chapters are in order...
That's not why Pascal compiles quickly. Resolving undefined symbols isn't difficult or slow, it just means that you have to keep track of what's resolved and what's unresolved and that takes up memory, which was very precious back in the old days of Pascal. Pascal is designed for very fast single-pass compilation, but symbol resolution is only a small part of it.
Well, not really. Consider the following:

  type
      ItemPtr = ^Item;

      SomeOtherType = record
        a,b,c:integer;
      end;

      Item = record
        Data:string;
        Next:ItemPtr;
      end;
The first time the parser hits "Item", its not defined.
Pascal require(s|d) a "forward" declaration on such a type, no?