Severance packages are common in tech for layoffs. That is effectively many weeks notice, you just don’t have to work during them which is nicer.
If you’re being fired for underperforming, that’s usually many weeks in the making and you’re given many written notices (HR departments like really clear paper trails).
The only times I hear of where termination is sudden without notice or compensation is when people get fired for something egregious or the company literally ran out of money (startups can be rough).
Caveat: all of the above applies to the tech industry. I understand it can be much worse for employees in other industries.