Both are essential. Generally on most AP's you'll get a mana item, then needlessly large rod item, and then void staff. when behind or when enemies are stacking mr ealier, most people just go mana item --> void staff, buying the nlr item later.
Both are essential on a mage. Get Rabadon's Deathcap if the enemies don't have much Magic resist and get Void Staff if they have built some Magic Resist items. Get both either way.
Neither are essential in all situations. There are situations that the enemies are silly enough not to buy MR (thus not taking void staff) and situations where plain ability power will help less than other ability power granting items. However, most enemies will get MR later on in the game and there will be most of the time a spot for deathcap, so yeah, get them both :P
Void staff will start to do more damage based on the enemy's magic resist, so it's a better item late game.
Not by me, but an example of some mages/assassins that are AP.
(edit: GET BOTH!)
Both are late game items, cap gives bonus AP base on already exist AP and the other allow you to make fun of the enemy's MR. Rigidly speaking, cap early is usually the better choice than void, void could be postponed till 3th-4th item in most case.
It's about scalings though. If the champion has bad scalings but high base damage, Void Staff is usually better choice. And if the scalings are great, get Rabadon's Deathcap
I think rabadon, since void staff amplifies your damage by a percentage, Raw ap is needed to increase your damage by a flat amount. let say a Q that deals 200 damage with 100% ap scaling vs... nope, I dont do math. just go for flat ap, void staff is used to deal with m.resist. if you want damage, go for rabadon first then later on, void staff.
(edit: GET BOTH!)