Recent

Author Topic: What's the single "craziest" unit of Object Pascal source code you've ever seen?  (Read 6367 times)

Akira1364

  • Hero Member
  • *****
  • Posts: 561
By which I mean, a unit that was either sufficiently long enough or complex enough that you can't imagine how the author wrote it without completely losing track of what was going on?

My vote goes to "PAPPE.pas", which is the single source file for the "Pascal Powerful Physics Engine" by Benjamin Rosseaux. It's thirteen thousand lines of complex high-level 3D math, with little to no comments.

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Maybe we should have an "obfuscated pascal" competition?

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
There was MacOSAll.pas in the rtl (or packages) directory which is about 5MB in size. "Unfortunately", it got splitted into smaller units. The top 10 in repository are:
Code: Bash  [Select][+][-]
  1. 5.6M    ./packages/rtl-unicode/src/collations/collation_zh_le.inc
  2. 5.6M    ./packages/rtl-unicode/src/collations/collation_zh_be.inc
  3. 4.6M    ./packages/rtl-unicode/src/inc/cp936.pas
  4. 4.5M    ./rtl/java/jdk15.inc
  5. 4.3M    ./packages/rtl-unicode/src/inc/cp949.pas
  6. 4.1M    ./packages/rtl-unicode/src/inc/cp950.pas
  7. 3.8M    ./packages/rtl-unicode/src/inc/cp932.pas
  8. 3.2M    ./rtl/android/jvm/androidr14.inc
  9. 2.5M    ./packages/rtl-unicode/src/inc/ucadata_le.inc
  10.  
The jdk and android part seems to be generated by code, no idea about the others.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
googled: https://sourceforge.net/p/pappe/code/HEAD/tree/PAPPE.pas

It is long, but that is all. But it is by no means complex or unreadable.

Reading it obviously would require knowledge on the underlying topic (physics simulation), but that (requirement of knowing the topic) applies to most code.

If you only want long: older versions of fpc had a unit with 300.000 lines in it.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
googled: https://sourceforge.net/p/pappe/code/HEAD/tree/PAPPE.pas

It is long, but that is all. But it is by no means complex or unreadable.
I can second that.
All routines are pretty much straight forward physics-math functions.
I'd probably moved file reading/writing function to a separate unit.

It's quite good solution. Since there's a very little Pascal physics libraries (compared to C/C++ based counterparts)
But anyways, the project has been added to the wiki not to be forgotten and hopefully to find future maintainers.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Oh yeah, I wasn't trying to say it was "bad" or "unreadable", I think it's a great library actually... just impressive/hard to imagine (for me at least) how the author could keep track of the thousands of lines of lengthy math equations and still know what was going on at any given time, with not much other than the method names to go by.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Oh yeah, I wasn't trying to say it was "bad" or "unreadable", I think it's a great library actually... just impressive/hard to imagine (for me at least) how the author could keep track of the thousands of lines of lengthy math equations and still know what was going on at any given time, with not much other than the method names to go by.
That's what an IDE with powerful source navigation feature is for ;)

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Well the craziest I have spotted in real life in a real company with real programmers is not a unit but basically this:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$APPTYPE CONSOLE}
  3. var
  4.   i:integer;
  5.   step:Integer absolute i;
  6. begin
  7.   for i := 0 to 9 do
  8.   begin
  9.     inc(PInteger(@step)^);
  10.     writeln(i);
  11.   end;
  12.   readln;
  13. end.
  14.  

Note it is also Delphi compatible to this day.

And yes, it was introduced to quick fix a VB translated piece of code.... <sigh>
« Last Edit: February 13, 2016, 12:11:31 pm by Thaddy »
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
It's thirteen thousand lines of complex high-level 3D math, with little to no comments.

I always tell people Pascal is self-explaining when properly used  >:D. It doesn't need documentation except for the language itself. O:-) :o
Or am I talking gibberish again :)  :D
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
On a more serious note: have a look at kol.pas.
Even for me it is very very hard to explain what everything does at any given time.
Even Embarcadero uses it to test if their parsing is still ok.
It is about 65K lines and really bigger than that, because of includes. Silly. But I live with it, because I like it a lot. Shameless plug: http://kolmck.net
Specialize a type, not a var.

airpas

  • Full Member
  • ***
  • Posts: 179
pappe is old , the author (bero) has another engine called craft , which is longer 1.11mb .
https://github.com/BeRo1985/kraft/blob/master/src/kraft.pas
 

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
pappe is old , the author (bero) has another engine called craft , which is longer 1.11mb .
https://github.com/BeRo1985/kraft/blob/master/src/kraft.pas
Thank you! I added it to the wiki!

Did you note that BeRo is working on popular subjects. Such as JavaScript interpreter (besen), Regular expressions (fire, brre), the physics engine and even a pascal compiler :) Now he seems to be working on a parallel-processing/multi-processing library.

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
pappe is old , the author (bero) has another engine called craft , which is longer 1.11mb .
https://github.com/BeRo1985/kraft/blob/master/src/kraft.pas
Thank you! I added it to the wiki!

Did you note that BeRo is working on popular subjects. Such as JavaScript interpreter (besen), Regular expressions (fire, brre), the physics engine and even a pascal compiler :) Now he seems to be working on a parallel-processing/multi-processing library.

And he is an active member of our forum: http://forum.lazarus.freepascal.org/index.php?action=profile;u=49596 :)

 

TinyPortal © 2005-2018