Recent

Author Topic: Interesting article about AI  (Read 15556 times)

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 584
Re: Interesting article about AI
« Reply #135 on: December 15, 2024, 06:27:21 pm »
Here in my country, everybody is at each other's throats over politics.  Let's not do that here over our code.  (Other places to discuss why we seem to be experiencing a period of high alienation everywhere).

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
Re: Interesting article about AI
« Reply #136 on: December 15, 2024, 08:19:25 pm »
LV if you’ve seen his code would you mind sharing the best parts with us?
If you don’t I will not believe you’ve seen it.

No need to wait. Here I quickly reviewed 300_ZydisInfoA, the code written by 440bx.

  • Every procedure and function is well-commented, has explanation about what it does and short information about its parameters.
  • Set $TYPEADDRESS on and $WRITEABLECONST off for stricter coding standard.
  • Using const parameters to prevent unintended changes of the parameter values in the function's/procedure' block.
  • Using assertion to prevent execution running into unexpected behavior.
  • Not 'stingy' in using line feed in the code, which will improve code readability.
  • Using otherwise statement instead of else, for better code readability.
  • Does not omit brackets for procedures and functions that do not have parameters.
  • Consistently using same number of spaces for tabs for formatting the code.
Many programmers who have years in coding, still not able to reach this coding quality. I have been coding in Pascal for more than 30 years, still have not reached this level of professionalism.

Compare to 440bx's code, mine looks very amateurish:

1. I am lazy,  provide comments on very important lines only.
2. I use writeable consts because I want the auto-initial-value-for-variable feature. But I can understand strict coding standard is important, especially on large projects.
3. I did the same in the past, but again because I am lazy so I no longer do it.
4. Yes, I do it too.
5. Because I started do programing on 80x25 monitor, it's my habit use less lines in my code so I can do less screen scrolling. But now I use large monitor, I think I should change the habit.
6. I use else, not otherwise. Yep, otherwise is better. Because else can cause confusion if the case block has if-then-else statements.
7. I do not do it. But I know it is good for differentiate between variables and functions/procedures.
8. I have different coding style, but I can see 400bx's style is better.

My score is 1/8.  :-[

Today I learned how to code like a professional.
Thanks 440bx.
« Last Edit: December 15, 2024, 08:21:06 pm by Handoko »

440bx

  • Hero Member
  • *****
  • Posts: 4984
Re: Interesting article about AI
« Reply #137 on: December 15, 2024, 08:28:11 pm »
@Handoko,

Thank you for the kind words, much appreciated.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

LV

  • Full Member
  • ***
  • Posts: 204
Re: Interesting article about AI
« Reply #138 on: December 15, 2024, 08:31:06 pm »
I was away for most of today.

LV if you’ve seen his code would you mind sharing the best parts with us?
If you don’t I will not believe you’ve seen it.

Please follow the link: https://forum.lazarus.freepascal.org/index.php/topic,67665.msg521439.html#msg521439.
Thanks to the author, I downloaded and unpacked the archives. Everything worked well. Here is an example. :)

ASBzone

  • Hero Member
  • *****
  • Posts: 717
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: Interesting article about AI
« Reply #139 on: December 15, 2024, 08:39:02 pm »
One of the saddest side effects of A.I is that it seems to have somewhat (mostly?) replaced expert systems.

You know, this is a very good point that I had not even considered previously -- and I do believe there is legitimacy to your observation.

Ultimately, I believe that AI usage will continue to grow, but it will not end up playing all the roles that people think about when they say "AI"...  At least not for a decade or more.

Meanwhile, more of the behind-the-scenes technologies in this space -- like machine learning -- will also continue to grow in usage and effectiveness, at a faster pace.  As long as AI continues to be seen and pushed as a more direct-to-end-user technology, it will have more issues, be more misunderstood, and fail to realize its true potential for a longer period of time.   
-ASB: https://www.BrainWaveCC.com/

Lazarus v3.5.0.0 (2216170cde) / FPC v3.2.3-1387-g3795cadbc8
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

ASBzone

  • Hero Member
  • *****
  • Posts: 717
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: Interesting article about AI
« Reply #140 on: December 15, 2024, 08:54:02 pm »
The real magic won't happen until competing AI systems start feeding on/off each other.

It feels like a better sentence for what you have described is:

"The real chaos won't happen until competing AI systems start feeding on/off each other."
-ASB: https://www.BrainWaveCC.com/

Lazarus v3.5.0.0 (2216170cde) / FPC v3.2.3-1387-g3795cadbc8
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

Bogen85

  • Hero Member
  • *****
  • Posts: 702
Re: Interesting article about AI
« Reply #141 on: December 15, 2024, 09:26:34 pm »
LV if you’ve seen his code would you mind sharing the best parts with us?
If you don’t I will not believe you’ve seen it.

Please follow the link: https://forum.lazarus.freepascal.org/index.php/topic,67665.msg521439.html#msg521439.
Thanks to the author, I downloaded and unpacked the archives.

I don't have access to a Windows environment, so I just downloaded ZydisE.7z and ZydisB.7z from the above thread to look at on a Linux based system.

I've played with Zydis before using C++, but not with Free Pascal.

@440bx, your code looks very well organized and is easy to read. I'll have to take your word and the word of others who use Free Pascal and Lazarus on Windows as to how well it works, and I have no reason to doubt you or them.

If I had a Windows environment to work in and Lazarus/FPC set up in it I'd definitely try it out.

If I were to want to use Zydis with Free Pascal on Linux I would not be doing it with Lazarus, but from what I can see in ZydisB (have not looked at the other archives yet that you posted for this) it looks like you already did most of the needed hard work.

VisualLab

  • Hero Member
  • *****
  • Posts: 624
Re: Interesting article about AI
« Reply #142 on: December 15, 2024, 11:09:35 pm »
Many programmers who have years in coding, still not able to reach this coding quality. I have been coding in Pascal for more than 30 years, still have not reached this level of professionalism.

It used to be called simply neatness (carefulness) of writing. Of course, I also believe that neat writing of source code and generous use of comments is useful/necessary. And after some time it pays off. Even for yourself. Especially when creating something more complex. Except that my code is definitely not as neat as 440bx's, because... I use classes! :D

I think people have different predispositions to neat source code writing. It's hard to say whether it's a matter of laziness. I also used to (a long time ago) have not very neat code and few comments. But quite quickly I started taking care of legible writing. Maybe it's similar to predispositions to handwriting. Some people have very nice (almost calligraphic) handwriting (and achieved it without much effort) and others scribble (sometimes even despite many years of training). But in the end, both are able to convey information. Of course, neatness (carefulness) in engineering work is helpful, because it often has an impact on achieving (or not) the intended goal. In particular, whether the project is successfully continued or not (the code is not very readable and confusing, and even the author often does not want to expand it). However, the code can always be tidied up.

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1317
Re: Interesting article about AI
« Reply #143 on: December 15, 2024, 11:12:10 pm »
Bogen85 thanks for files tutorial. I always thought of files as stored on disk.

I’m glad that 440bx has some nice code but I can’t download it and therefore will never be allowed to see it. Being excluded from seeing the code is even worse than it not existing...
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

440bx

  • Hero Member
  • *****
  • Posts: 4984
Re: Interesting article about AI
« Reply #144 on: December 16, 2024, 01:29:47 am »
Again, I want to thank all those who had kind words for my code.

The purpose of this post is to state that the Zydis examples code is _not_ what I consider professionally written code, it is what I consider decent code.

To my embarrassment I've never written what I consider professionally written code for myself but, that said, I've written code for myself that comes close to it. 

I cannot share any of my professionally written code because I don't own it.  I was paid to write it and the code belongs to the entities that paid for its development.

However, there is a program I've shared here,
link: https://forum.lazarus.freepascal.org/index.php/topic,46617.msg459635.html#msg459635
that comes reasonably close to what I consider professionally written code.

The most obvious difference is the organization of the code which is very formal (sequencing as an Activity on Arc diagram which is obtained by doing a topological sort on function/procedure dependencies.)  The result is very close to what is shown in the first attachment which is a directory listing of the source code.

The _00 group is the core high level program logic.
The _05 group is the logic breakdown in blocks
The _55 on down are the general utility functions used by the _05 group.

Except for the _00 group, the elements are in dependency  blocks ordered by dependency sequence (that's what determines their sequence number.)

The result is that all that's needed to see the structure of the program is to do a "dir".  No need to even open a source file.

here is the _00_98_PeDump.lpr code:
Code: Pascal  [Select][+][-]
  1. {$include _00_00_A98_PEDUMP_COMPILER_DIRECTIVES.inc                           }
  2.  
  3.  
  4. { STARTING_ERROR_NUMBER: none                                                 }
  5.  
  6.  
  7. program _00_A98_PeDump;
  8.  
  9.  
  10. USES
  11.   _00_00_Notes,                    // dummy unit to hold notes
  12.  
  13.   _05_00_DumpFile,
  14.   _05_10_ProgramHeadings,
  15.   _05_20_CommandLine,
  16.   _05_30_FileMap,
  17.   _05_40_PeChecks,
  18.   _05_50_PeData,
  19.   _05_52_RuntimeFunctions,
  20.  
  21.   // dump PE file headers
  22.  
  23.   _05_60_000_DumpPE,
  24.   _05_60_010_DumpDosHeader,
  25.   _05_60_020_DumpDosStub,
  26.   _05_60_030_DumpNtHeader,
  27.   _05_60_040_DumpFileHeader,
  28.   _05_60_050_DumpOptionalHeader,
  29.   _05_60_060_DumpDataDirectory,
  30.   _05_60_070_DumpSectionHeaders,
  31.   _05_60_080_DumpImageHeadersFillerBytes,
  32.  
  33.   // data directories
  34.  
  35.   _05_60_090_DumpExportsDirectory,
  36.   _05_60_100_DumpImportsDirectory,
  37.   _05_60_110_DumpResourcesDirectory,
  38.   _05_60_120_DumpExceptionsDirectory,
  39.   _05_60_130_DumpCertificatesDirectory,
  40.   _05_60_140_DumpRelocationsDirectory,
  41.   _05_60_150_DumpDebugDirectory,
  42.   _05_60_160_DumpArchitectureDirectory,
  43.   _05_60_170_DumpGlobalPointerDirectory,
  44.   _05_60_180_DumpTlsDirectory,
  45.   _05_60_190_00_DumpLoadConfigDirectory,
  46.   _05_60_200_DumpBoundImportsDirectory,
  47.   _05_60_210_DumpImportsAddressTableDirectory,
  48.   _05_60_220_DumpDelayLoadImportsDirectory,
  49.   _05_60_230_DumpDotNetDirectory,
  50.   _05_60_240_DumpReservedDirectory,
  51.  
  52.   // coff symbol table
  53.  
  54.   _05_60_250_DumpCoffSymbolTable,
  55.  
  56.   // pe information
  57.  
  58.   _05_60_300_DumpPeInformation,
  59.  
  60.  
  61.   // program termination functions
  62.  
  63.   _05_70_FileUnmap,
  64.   _05_80_ProgramEnd,             { this is where the program/process ends     }
  65.  
  66.   // shared routines and data
  67.  
  68.   _55_FormatLine,
  69.  
  70.   _60_DataDirectoryTypes,
  71.   _60_DisplayHeaders,
  72.   _60_Dwarf,
  73.  
  74.   _70_FormatDec,
  75.   _70_FormatGuid,
  76.   _70_FormatHex,
  77.   _60_ImportTables,
  78.   _60_Io,
  79.   _60_RvaInfo,
  80.   _70_TypesAndConstants,
  81.  
  82.   _60_DumpHex,
  83.  
  84.   _70_FormatDate,
  85.  
  86.   _70_LineFields,
  87.  
  88.   _80_ImageTypes,
  89.   _80_wintypes,
  90.  
  91.   // API definitions
  92.  
  93.   _90_kernel32,
  94.   _90_ntdll,
  95.   _90_shell32
  96.   ;
  97.  
  98.  
  99. begin
  100.   { note: Dumpfile does not return                                            }
  101.  
  102.   DumpFile();
  103. end.
  104.  
Note how the uses clause mirrors the directory listing.  The _05 functions are executed exactly in the sequence the are listed in the uses clause. 

In Lazarus and with two editor windows open this file provides access to all the blocks of code by right clicking on any of the uses lines and opening the corresponding file in the second window.  This provides a very quick and convenient way of inspecting the program's  code while never losing sight of the location being inspected in the global program logic.

Here is the _0560_00_DumpPe code:
Code: Pascal  [Select][+][-]
  1. {$include _00_00_A98_PEDUMP_COMPILER_DIRECTIVES.inc                           }
  2.  
  3.  
  4. { STARTING_ERROR: none             } { TODO                                   }
  5.  
  6.  
  7.  
  8. // ----------------------------------------------------------------------------
  9. // the following defines are present to suppress output during developement
  10.  
  11.  {$define dosheader                           }
  12.  
  13.  {$define dosstub                             }
  14.  
  15.  {$define ntheader                            }
  16.  
  17.  {$define fileheader                          }
  18.  
  19. // even though the data directory is part of the optional header, it is dumped
  20. // separately to keep the program's logic simple
  21.  
  22.  {$define optionalheader                      }
  23.  {$define datadirectory                       }
  24.  
  25.  {$define sectionheaders                      }
  26.  
  27.  {$define imageheadersfillerbytes             }
  28.  
  29.  
  30. // ---------------------------------------------
  31. // data directory references
  32.  
  33.    { NOTE: commenting out the processing of the exports directory requires    }
  34.    {       commenting out the processing of the load config directory and the }
  35.    {       imports directory because the processing of these two directories  }
  36.    {       create two tables (exports and imports respectively) that _may_ be }
  37.    {       used when processing the LOAD CONFIG.  if those tables are needed  }
  38.    {       and they are not present an access violation will occur            }
  39.  
  40.   { 01 }  {$define exportsdirectory            }
  41.  
  42.   { 02 }  {$define importsdirectory            }
  43.  
  44.   { 03 }  {$define resourcesdirectory          }
  45.  
  46.   { 04 }  {$define exceptionsdirectory         }
  47.  
  48.   { 05 }  {$define certificatesdirectory       }
  49.  
  50.   { 06 }  {$define relocationsdirectory        }
  51.  
  52.   { 07 }  {$define debugdirectory              }
  53.  
  54.   { 08 }  {$define architecturedirectory       }
  55.  
  56.   { 09 }  {$define globalpointerdirectory      }
  57.  
  58.   { 10 }  {$define tlsdirectory                }
  59.  
  60.  
  61.    { NOTE: processing the load config directory requires that the processing  }
  62.    {       of the exports directory and imports directory _not_ be commented  }
  63.    {       out because the load config _may_ need the table of imports and    }
  64.    {       exports created when processing them                               }
  65.  
  66.   { 11 }  {$define loadconfigdirectory         }
  67.  
  68.   { 12 }  {$define boundimportsdirectory       }
  69.  
  70.   { 13 }  {$define importsaddresstabledirectory}
  71.  
  72.   { 14 }  {$define delayloadimportsdirectory   }
  73.  
  74.   { 15 }  {$define dotnetdirectory             }
  75.  
  76.   { 16 }  {$define reserveddirectory           }
  77.  
  78.  
  79. // ---------------------------------------------
  80. // PE file areas not in directories
  81.  
  82.   {    }  {$define coffsymboltable             }
  83.  
  84.   {    }  {$define PeInformation               }
  85.  
  86.  
  87.  
  88. UNIT _05_60_000_DumpPE;
  89.  
  90.  
  91. // -----------------------------------------------------------------------------
  92. INTERFACE
  93. // -----------------------------------------------------------------------------
  94.  
  95. USES
  96.   _05_50_PeData
  97.   ;
  98.  
  99. // -----------------------------------------------------------------------------
  100.  
  101.  
  102. function DumpPE(var InoutPeData : TPE_DATA) : boolean;
  103.   // outputs all the parts of a PE file
  104.  
  105.  
  106. // -----------------------------------------------------------------------------
  107. IMPLEMENTATION
  108. // -----------------------------------------------------------------------------
  109.  
  110. USES
  111.   _05_60_010_DumpDosHeader,
  112.   _05_60_020_DumpDosStub,
  113.  
  114.   // IMAGE Headers
  115.  
  116.   _05_60_030_DumpNtHeader,
  117.  
  118.   _05_60_040_DumpFileHeader,
  119.   _05_60_050_DumpOptionalHeader,
  120.   _05_60_060_DumpDataDirectory,
  121.   _05_60_070_DumpSectionHeaders,
  122.   _05_60_080_DumpImageHeadersFillerBytes,
  123.  
  124.   // DATA DIRECTORY
  125.  
  126.   _05_60_090_DumpExportsDirectory,
  127.   _05_60_100_DumpImportsDirectory,
  128.   _05_60_110_DumpResourcesDirectory,
  129.   _05_60_120_DumpExceptionsDirectory,
  130.   _05_60_130_DumpCertificatesDirectory,
  131.   _05_60_140_DumpRelocationsDirectory,
  132.   _05_60_150_DumpDebugDirectory,
  133.  
  134.   _05_60_160_DumpArchitectureDirectory,
  135.   _05_60_170_DumpGlobalPointerDirectory,
  136.  
  137.   _05_60_180_DumpTlsDirectory,
  138.   _05_60_190_00_DumpLoadConfigDirectory,
  139.   _05_60_200_DumpBoundImportsDirectory,
  140.  
  141.   _05_60_210_DumpImportsAddressTableDirectory,
  142.  
  143.   _05_60_220_DumpDelayLoadImportsDirectory,
  144.   _05_60_230_DumpDotNetDirectory,
  145.  
  146.   _05_60_240_DumpReservedDirectory,
  147.  
  148.   // PE file areas not in directories
  149.  
  150.   _05_60_250_DumpCoffSymbolTable,
  151.  
  152.   // output some notable PE features/characteristics found in the module
  153.  
  154.   _05_60_300_DumpPeInformation,
  155.  
  156.  
  157.  
  158.   // ---------------------------------------------
  159.   // support functions
  160.  
  161.  
  162.  
  163.   _60_Io
  164.   ;
  165.  
  166. // -----------------------------------------------------------------------------
  167.  
  168.  
  169. function DumpPE(var InoutPeData : TPE_DATA) : boolean;
  170.   // outputs all the parts of a PE file
  171.  
  172. begin
  173.   result        := FALSE;
  174.  
  175.   // ---------------------------------------------------------------------------
  176.   // MS DOS header and stub
  177.  
  178.   {$ifdef dosheader                   }
  179.     Newline();
  180.     Newline();
  181.     Newline();
  182.     if not DumpDosHeader                        (InoutPeData)       then exit;
  183.   {$endif}
  184.  
  185.   {$ifdef dosstub                     }
  186.     Newline();
  187.     Newline();
  188.     Newline();
  189.     if not DumpDosStub                          (InoutPeData)       then exit;
  190.   {$endif}
  191.  
  192.   // ---------------------------------------------------------------------------
  193.   // image headers
  194.  
  195.   {$ifdef ntheader                    }
  196.     Newline();
  197.     Newline();
  198.     Newline();
  199.     if not DumpNtHeader                         (InoutPeData)       then exit;
  200.   {$endif}
  201.  
  202.   {$ifdef fileheader                  }
  203.     Newline();
  204.     if not DumpFileHeader                       (InoutPeData)       then exit;
  205.   {$endif}
  206.  
  207.   {$ifdef optionalheader              }
  208.     Newline();
  209.     if not DumpOptionalHeader                   (InoutPeData)       then exit;
  210.   {$endif}
  211.  
  212.   {$ifdef datadirectory               }
  213.     Newline();
  214.     Newline();
  215.     if not DumpDataDirectory                    (InoutPeData)       then exit;
  216.   {$endif}
  217.  
  218.   // ---------------------------------------------------------------------------
  219.   // section headers
  220.  
  221.   {$ifdef sectionheaders              }
  222.     Newline();
  223.     Newline();
  224.     Newline();
  225.     if not DumpSectionHeaders                   (InoutPeData)       then exit;
  226.   {$endif}
  227.  
  228.  
  229.   // ---------------------------------------------------------------------------
  230.   // image headers filler bytes
  231.  
  232.   {$ifdef imageheadersfillerbytes     }
  233.     Newline();
  234.     if not DumpImageHeadersFillerBytes          (InoutPeData)       then exit;
  235.   {$endif}
  236.  
  237.  
  238.   // ---------------------------------------------------------------------------
  239.   // data directory
  240.  
  241. {  1 } {$ifdef exportsdirectory            }
  242.          Newline();
  243.          Newline();
  244.          Newline();
  245.          if not DumpExportsDirectory            (InoutPeData)       then exit;
  246.        {$endif}
  247.  
  248.  
  249.  
  250. {  2 } {$ifdef importsdirectory            }
  251.          Newline();
  252.          Newline();
  253.          Newline();
  254.          if not DumpImportsDirectory            (InoutPeData)       then exit;
  255.        {$endif}
  256.  
  257.  
  258. {  3 } {$ifdef resourcesdirectory          }
  259.          Newline();
  260.          Newline();
  261.          Newline();
  262.          if not DumpResourcesDirectory          (InoutPeData)       then exit;
  263.        {$endif}
  264.  
  265.  
  266. {  4 } {$ifdef exceptionsdirectory         }
  267.          Newline();
  268.          Newline();
  269.          Newline();
  270.          if not DumpExceptionsDirectory         (InoutPeData)       then exit;
  271.        {$endif}
  272.  
  273.  
  274. {  5 } {$ifdef certificatesdirectory       }
  275.          Newline();
  276.          Newline();
  277.          Newline();
  278.          if not DumpCertificatesDirectory       (InoutPeData)       then exit;
  279.        {$endif}
  280.  
  281.  
  282. {  6 } {$ifdef relocationsdirectory        }
  283.          Newline();
  284.          Newline();
  285.          Newline();
  286.          if not DumpRelocationsDirectory        (InoutPeData)       then exit;
  287.        {$endif}
  288.  
  289.  
  290. {  7 } {$ifdef debugdirectory              }
  291.          Newline();
  292.          Newline();
  293.          Newline();
  294.          if not DumpDebugDirectory              (InoutPeData)       then exit;
  295.        {$endif}
  296.  
  297.  
  298. {  8 } {$ifdef architecturedirectory       }
  299.          Newline();
  300.          Newline();
  301.          Newline();
  302.          if not DumpArchitectureDirectory       (InoutPeData)       then exit;
  303.        {$endif}
  304.  
  305.  
  306. {  9 } {$ifdef globalpointerdirectory      }
  307.          Newline();
  308.          Newline();
  309.          Newline();
  310.          if not DumpGlobalPointerDirectory      (InoutPeData)       then exit;
  311.        {$endif}
  312.  
  313.  
  314. { 10 } {$ifdef tlsdirectory                }
  315.          Newline();
  316.          Newline();
  317.          Newline();
  318.          if not DumpTlsDirectory                (InoutPeData)       then exit;
  319.        {$endif}
  320.  
  321.  
  322. { 11 } {$ifdef loadconfigdirectory         }
  323.          Newline();
  324.          Newline();
  325.          Newline();
  326.          if not DumpLoadConfigDirectory         (InoutPeData)       then exit;
  327.        {$endif}
  328.  
  329.  
  330. { 12 } {$ifdef boundimportsdirectory       }
  331.          Newline();
  332.          Newline();
  333.          Newline();
  334.          if not DumpBoundImportsDirectory       (InoutPeData)       then exit;
  335.        {$endif}
  336.  
  337.  
  338. { 13 } {$ifdef importsaddresstabledirectory }
  339.          Newline();
  340.          Newline();
  341.          Newline();
  342.          if not DumpImportsAddressTableDirectory (InoutPeData)      then exit;
  343.        {$endif}
  344.  
  345.  
  346. { 14 } {$ifdef delayloadimportsdirectory   }
  347.          Newline();
  348.          Newline();
  349.          Newline();
  350.          if not DumpDelayLoadImportsDirectory    (InoutPeData)      then exit;
  351.        {$endif}
  352.  
  353.  
  354. { 15 } {$ifdef dotnetdirectory             }
  355.          Newline();
  356.          Newline();
  357.          Newline();
  358.          if not DumpDotNetDirectory              (InoutPeData)      then exit;
  359.        {$endif}
  360.  
  361.  
  362. { 16 } {$ifdef reserveddirectory           }
  363.          Newline();
  364.          Newline();
  365.          Newline();
  366.          if not DumpReservedDirectory            (InoutPeData)      then exit;
  367.        {$endif}
  368.  
  369.  
  370.   // ---------------------------------------------------------------------------
  371.   // PE file areas not in headers and directories
  372.  
  373.   {$ifdef coffsymboltable             }
  374.     // don't output any separating lines unless there is a COFF
  375.     // symbol table to output
  376.  
  377.     if not DumpCoffSymbolTable                   (InoutPeData)      then exit;
  378.   {$endif}
  379.  
  380.   {$ifdef PeInformation}
  381.     Newline();
  382.     Newline();
  383.     Newline();
  384.     if not DumpPeInformation                     (InoutPeData)      then exit;
  385.   {$endif}
  386.  
  387.  
  388.   result := TRUE;                          // let the fat lady sing now
  389. end;
  390.  
  391.  
  392. END.
  393.  
  394. // end of file.
  395. // -----------------------------------------------------------------------------
  396.  
Note the parallelism between the code, the uses clause and the directory listing.  This file also serves to have quick access to all the major logical blocks of the program.

I hope it is fairly evident that due to its structure this program is fairly easy to understand and maintain.

Essentially, among other things, it is the additional care invested in the program structure that makes the program a "professionally" written piece of code.  This program is close enough even though there is still a little room for improvement.

Another characteristic that makes this program close to a "professional" program is that there is a test suite of about 700 PE files to cause _almost_ all execution paths to be taken.

Lastly, there are no try/except nor try/finally(s) anywhere.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1317
Re: Interesting article about AI
« Reply #145 on: December 16, 2024, 02:56:56 am »
440bx That’s a clever idea to use file naming conventions to keep the files belonging to program grouped together and organized in the file directory.
I’m not sure how feasible it is if different projects were to share files though...
I don’t much care for all the empty lines because It requires extra scrolling.
I do agree that well written code should not contain try .. except blocks.
« Last Edit: December 16, 2024, 04:19:53 am by Joanna from IRC »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

440bx

  • Hero Member
  • *****
  • Posts: 4984
Re: Interesting article about AI
« Reply #146 on: December 16, 2024, 05:07:04 am »
I don’t much care for all the empty lines because It requires extra scrolling.
I rarely need to scroll because _all_ the code is in my mind and if I forget, all I have to do is look at the directory listing to refresh my memory.

The directory listing is proof that whitespace makes sequences much easier to see by separating them which in turn makes them easier to memorize because the whitespace makes the groups visually obvious.

The human mind is _not_ good at memorizing blobs of text.  It is good at memorizing patterns, e.g, color coding, such as syntax highlighting, is a way of creating patterns.

Because of the way I structure code I can normally _automatically_ (effortlessly) memorize the entirety of what I've already inspected.  In addition to that I normally set bookmarks to locations in the code I know I will have to revisit.  This is the reason I requested that Lazarus bookmarks restore the _exact_ text location (thank you Martin) because that way, the bookmark causes the text in the window to match what is stored in my memory.

However, during initial development, scrolling is often necessary.  In that situation it is scrolling speed that is important and the reason I still use Multi-Edit for development and the Lazarus editor almost always to edit code only during debugging (though I occasionally use it while developing too, I think it's the only editor I occasionally use during development outside of M.E.  Using the VS editor for more than 3 seconds is intellectually excruciating.  How anyone can use that thing is beyond my comprehension.)

If I didn't have M.E, I'd develop an editor like it because without it, I would stop programming.  I am yet to see another editor that can come somewhat close to replacing it.  The Lazarus editor is the best I've seen so far outside M.E but it is no match to M.E but at least, unlike most other editors, it is usable.

Lastly, codetools (when it works) often eliminates the need for scrolling.  The code explorer can also be helpful to avoid scrolling.

In real estate the adage is "location, location, location!", in programming it should probably be "patterns, patterns, patterns!".
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1317
Re: Interesting article about AI
« Reply #147 on: December 16, 2024, 12:33:27 pm »
I’ve seen bookmarks in Lazarus before but I have no idea how to use them.
Do you mean that they can be named in the bookmark ?
Sometimes when I’m working on code I leave a syntax error to make it easier to return to the place I was working on or I try to remember the line number and goto line number. Other than that it’s find or scrolling. I tend to rework code everytime I find a better way so I don’t know what would happen to bookmarks for deleted code.

My file system often lies to me about file ages so I have created my own file naming convention that includes last year changed in file in filename to keep track of how recently I changed a file.

I wouldn’t mind seeing more of your code  :)
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

VisualLab

  • Hero Member
  • *****
  • Posts: 624
Re: Interesting article about AI
« Reply #148 on: December 17, 2024, 01:02:01 am »
The human mind is _not_ good at memorizing blobs of text.  It is good at memorizing patterns, e.g, color coding, such as syntax highlighting, is a way of creating patterns.

That I'll ask sneakily: "how can it be true"? That would mean that people are much better at GUI than CLI. And apparently CLI is the best UI in OSes? (after all, it is the main face of "Penguin")

But seriously - it's true. What's more, the human mind copes well with diverse graphic patterns. With their recognition, classification, inference or extraction of specific features. This is most likely why people so commonly use different types of charts in the fields of science and nature. As well as different diagrams or schemes for abstract representation of objects and processes. On the other hand, the human mind copes poorly with processing a "wall of text" or a "text tapeworms". It needs a time to process such content. "Half the trouble" when it is descriptive text. Worse when it is a set of densely written symbols (math, command line, etc.).



I’ve seen bookmarks in Lazarus before but I have no idea how to use them.
Do you mean that they can be named in the bookmark ?
Sometimes when I’m working on code I leave a syntax error to make it easier to return to the place I was working on or I try to remember the line number and goto line number. Other than that it’s find or scrolling. I tend to rework code everytime I find a better way so I don’t know what would happen to bookmarks for deleted code.

It's an abstract equivalent of a bookmark (paper, plastic or ribbon). You can place many bookmarks between the pages in a book. Their ends stick out from between the pages. You insert the bookmark where you finish reading and put the book down. And when you come back to it, you grab the end of the bookmark and open the book where the bookmark is.

IDEs have abstract (virtual) bookmarks. You place them in a file with the source code. These files are text files and consist of lines. Bookmarks are specific markers placed in lines of code that the user inserts. Many different IDEs have this option. Each source file can have its own bookmarks (if you place them). You insert a bookmark. Then you scroll through the source code to another place in the file that interests you. Then to go back, you simply select the bookmark you set and the IDE quickly jumps to that line. A file can have many such bookmarks. Bookmarks are saved together with the code.

To insert a bookmark, place the cursor in the selected line of code that interests you and right-click. The editor context menu will appear (as in the attached screenshot). There are two options in this menu:
  • Toggle Bookmark – used to insert and remove bookmarks,
  • Goto Bookmark – used to jump to the selected bookmark.
Each bookmark has its own number. To go to a bookmark, display the context menu and select its number or use the keyboard shortcut Ctrl + X, where X is the bookmark number (faster). You can also move up or down the source code by bookmark. You can remove one bookmark at a time or all bookmarks at once when they are no longer needed.
« Last Edit: December 17, 2024, 01:20:21 am by VisualLab »

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1317
Re: Interesting article about AI
« Reply #149 on: December 17, 2024, 02:59:17 am »
Thanks visualLab it seems similar to web browser bookmarks except for no label or line number. I would probably not remember what is located at numbered bookmarks unless they were placed at beginning of code for each class or something like that.
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

 

TinyPortal © 2005-2018