I have read in a somewhat old book that castling was to be done as soon as possible, but some of my playing friends don't bother to do it in the opening. What's the modern usage?
It's normally a very good idea to castle early, but 'as soon as possible' is not really a correct rule. It depends on a number of factors, including your choice of opening, and your opponent's response.
Leaving your king in the middle of the board is a bad idea. Your pieces can be pinned, you're much more vulnerable, and your rooks can become isolated, trapped on the sidelines. One exception to this rule sometimes arises if you have exchanged queens. Once this happens it is considerably harder to mount a successful direct mid-game assault on the king, and it may sometimes be reasonable in this situation to treat the king as an additional fighting piece, rather than as a delicate thing to hide away on the sidelines and protect at all costs.
There are a couple of rare openings where not castling is a valid strategy, but they are unusual. Castling does not occur, or occurs very late, in some variations of the French Defense. See for example Kramnik-Anand, 2008. Similar things can happen in the Sicilian Taimanov and the Hedgehog Defense. Sometimes giving up castling is a valid line for white, as happens for example in some variations of the King's Gambit Accepted such as the King's Bishop's Gambit, where Black checks on h4, and white plays Kf1.
Castling is still done in "modern" openings, but it doesn't quite have the urgency that it used to.
"In the old days" (until about 30-40 years ago), the accepted practice was to develop as quickly as possible, castle (usually kingside), and then start an attack against the enemy king. "Nice" for White (who gets the first move), not so great for Black.
With increasing frequency, Black started to play for positional compensation elsewhere on the board other than kingside (center or queenside). Such maneuvers often required extended sequences in which (early) castling would be a wasted move. White, in turn, sometimes delays castling to counter these maneuvers.
And there are other sequences in which Black waits for White to start an attack on one side of the board, and then castles on the OTHER side. The idea is to cause those attacking moves to be "wasted," thereby nullifying the advantage of White's first move.
Castling early is still a good general rule of thumb for beginners. I believe it is more related to actual playing strength than playing "modern" openings (which I don't believe in either, I only believe in modern lines). Strong (or very strong) players, with their better and more precise understanding of the game, know when and how to identify exceptions and break the rules with very clear justifications, such as:
- they get sufficient compensation (particularly king safety) for late/not castling, such as in cases where the center is blocked
- the a/h files for respective rooks will become open/semi-open through exchanges/pawn captures, thus removing a need to develop them by castling
- the opponent hangs a piece that can be captured by moving the king or the rook, it never hurts to win material this wway