From: robin_listas@es.invalid   
      
   On 2026-01-07 14:50, Lars Poulsen wrote:   
   > On 2026-01-07, Carlos E.R. wrote:   
   >> [Pascal strings] those store the size of the used string as the first   
   >> byte. We also need the maximum size of the string variable.   
   >> The compiler knows.   
   >>   
   >> Turbo Pascal generated code to check the bounds of a variable in runtime   
   >> and aborted the program if surpassed. I was amazed at seeing production   
   >> code disabling the check (for speed?).   
   >   
   > Of course, it is possible to bounds check every access. Incurring a huge   
   > loss of runtime performance. And maybe that should be a compiler option.   
      
   Not that huge. Depends on the application.   
      
   >   
   > In most programs of any size, most strings are dynamically allocated,   
   > so the compiler does NOT know their size. The runtime COULD know it from   
   > the malloc() header, but then they are different from static strings.   
   > You COULD paper that over by having the header on static strings, but   
   > then you lose the ability to have a string in a packed struct.   
   >   
   > C++ eliminates those issues by allowing you to define a string class   
   > that must be allocated by "new", but string handling is so widely used   
   > that you'd have to rewrite a LOT of runtime libraries.   
   >   
   > Much of the performance power of C comes from NOT incurring the overhead   
   > of this safety net.   
      
   Indeed, but most bugs found later (even years) are due to not checking   
   and accessing beyond the limits.   
      
   >   
   > ** digression **   
   >   
   > In my own world, the real-time control of radio devices with   
   > microsecond packet timing prescheduled so we can account for   
   > time-of-flight (speed of light x distance) depends on knowing   
   > the maximum interrupt latency and being able to limit the time   
   > interrupts are disabled. We count instructions in the interrupt   
   > service routines from the time the serial framer says "packet to   
   > my address detected" to the point where we can set the trigger   
   > that allows the "end-of-packet" to un-gate the transmit clock.   
   >   
      
   Basically what my teacher said was that few applications, like the one   
   you describe, need be made in C, by professionals that know what they   
   are doing. The rest (think M$ Office) does not need it and should use   
   other languages without freedoms.   
      
   > When Motorola got out of the chip business, first spinning it   
   > out as FreeScale, then passing it off to NXP, the support for   
   > bare-bones developers disappeared for new members of the family,   
   > and they more or less insisted that the embedded products had   
   > to run Linux.   
   >   
   > We decided not to move to the newer versions. For over a decade,   
   > we have been able to live off the last-time-buy   
   > of each chip that went out of production. The approaching   
   > end of that stock fortuitously dovetails with our desire to   
   > retire and shut down our business - with proper time buffer   
   > to allow us to give our customers 2 years of warning and   
   > make their own last-time-buy. But it is hard to convince a railway   
   > company in Taiwan that we REALLY are going away.   
      
   Heh.   
      
   I was not aware that Motorola had gone out of the chip business. I loved   
   68000 assembler.   
   --   
   Cheers, Carlos.   
   ES🇪🇸, EU🇪🇺;   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|