There is more to do in Barcelona city than in Madrid, but Madrid has the day trips to the historic cities such as Toledo and Segovia.
Madrid closes down in August and it is unpleasntly hot whereas Barcelona is cooler thanks to the sea.
Have a look at TimeOut's guides on the two cities
Neither would be my first choice. I've been to both, and Seville was far, far more captivating. Salamanca and Santiago de la Compostela were great, too.
It depends upon what you want. Madrid isn't all that old by Spanish standards, so the architecture isn't anything special. In my opinion, its must-sees are the art museums. Barcelona has older & bigger churches and more interesting architecture and a small maze-like medina, and I liked the park-like pedestrian boulevards.
You don't say how long you're spending there, but both cities have nearby attractions. Madrid has Toledo some other places, and Barcelona has some monasteries in the mountains west of town and a Roman provincial capital (Tarregona) about an hour south along the coast.
If you want nature and have time to spend, I suggest high-tailing it for 1) Leon and Los Picos Europa (from Madrid) or 2) the Pyrenees (from Barcelona).
Madrid is a Spanish city, the capital of Spain. Barcelona is not really Spanish, it's Catalan, in Catalonia we have a different language, culture and identity.
However, both are interesting cities. Madrid has better museums, a livelier night-life without being so touristy as some areas in Barcelona, but Barcelona has an older history and the architecture is much more interesting.
Barcelona
My family and I are soon going for a trip to Spain. The thing is that we have to choose between Madrid and Barcelona. Let me clarify that we are going as a family and we don't really want any "nightlife activities" like clubs and parties. Just something a family would do. Also we hate beaches. Please tell me more about Madrid and more about Barcelona and which is better, cheaper, nicer people, more museums and nature, fun places etc.