Curiosity about IC pinouts

I've often wondered, as I look at IC datasheets and do PCB layouts, why don't manufacturers keep related pins together?

Example: 74HC597 and CD4021 parallel/serial interface ICs are both 16-pin DIPs with 8 ins or outs. Yet, invariably, they're not sequential. You'll have I/O #2 and #3 on different sides of the chip for instance. I'm sure current fabrication is just following suit with legacy parts, but somewhere in a lab long ago, an engineer decided to randomize the pinout.

Why?

Op-amps OTOH generally have a very sane layout, like the TL074 for instance. The +, -, and out pins are in order, and those groups are mirrored on each corner of the IC. (Although, the V+ and V- pins are on opposite sides of the TL072 and TL071 variants, which almost cost me two chips from my own carelessness. :cold_sweat: So maybe it's a universal sadism?)

Is there a good reason (breaking up coupling for instance) or just an engineer trying to impress upon the world the same manner of chaos as might be found at his work area?

Is there a good reason (breaking up coupling for instance) or just an engineer trying to impress upon the world the same manner of chaos as might be found at his work area?

No there is a good reason for the way pinout is performed although it might always not make sense to the final user.

The main considerations are that the pins are close to the areas of silicon associated with that function and that the leads are short. Laying out a chip is very much like laying out a PCB, there are restrictions.
There is a degree of compatibility, for example the 74 series of logic chips had the power pins in opposite corners of the package. This was fine for the large decoupling capacitors of the time and the way power bussed were laid out. Nowadays with surface mount capacitors power pins are best put next to each other.