The present invention relates to compounds of formula (I) or a pharmaceutically acceptable salt, hydrate, solvate, or prodrug thereof, wherein X1, X2, X3, X4, X5, W1, W2, W3, and W4 are as described. The present invention relates generally to inhibitors of histone deacetylase and to methods of making and using them. In one aspect, the invention relates to selective HDAC3 inhibitors useful for protecting ß-cells and improving insulin resistence. The selective HDAC3 inhibitors are also useful for promoting cognitive function and enhancing learning and memory formation. Compounds of the invention are useful for treating, alleviating, and/or preventing various conditions, including for example, a metabolic disorder such as type 1 or type 2 diabetes, dyslipidemias, lipodystrophies, liver disease associated with metabolic syndrome, polycystic ovarian syndrome, or obesity; inflammatory disease; neurological disorder; a memory or cognitive function disorder/impairment; an extinction learning disorder; fungal disease or infection; viral disease or infection such as HIV; hematological disease; liver disease; lysosomal storage disease; or neoplastic disease in humans or animals.