How much the shelves will sag depends not only on the materials you use, but also whether or not the shelves are fixed, whether there's a hardwood strip along the length, and how they are attached. The magic number to watch out for is 1/32" (about 0.8 mm) of sag per foot.
MDF is incredibly heavy - your bookshelves will weigh a ton if you construct them entirely from it. Further, they will sag under their own weight if the span is wide enough, so be cautious if you intend to make the shelves wide without additional support. You might consider attaching hardwood edge strips or building a small torsion box frame beneath each shelf if you intend to have wide spans. This, of course, is bulky and unsightly.
That said, MDF does rout and paint incredibly well if that's more important to you and your design doesn't call for wide, unsupported expanses. However, tight-grained, close-pored hardwoods also paint well. If you can find Poplar or Maple veneered plywood (all of my local home centers carry both), that should work pretty well. You can also fill the pores of open-pored woods to make them accept paint better.
As for the edges of plywood, a common technique is to attach a hardwood strip because it allows for routing without all the ply layers showing through, and it adds quite a bit of load bearing capacity. Also, you shouldn't have problems with plywood warping if it's kept in a relatively dry area, especially in a climate-controlled area like inside your house. And if you go all out and get high-quality plywood from a lumber yard rather than a home center, it's often even more stable due to a greater number of plies and less voids/gaps.
I wouldn't even go near chipboard. I'll admit a little bias because all of the manufactured furniture I've ever owned made from chipboard either sagged, chipped, or buckled under stress (in a matter of 2-3 years, in most cases).
Check out http://www.woodbin.com/calcs/sagulator.htm if you get a chance. You can play with various materials, edging strips, whether or not the shelf is fixed or floating, and so on. It also has great tips to watch out for.