I review the geometry of heterotic string compactifications leading to supersymmetric gauge theories in 4 and 3 dimensions. The data of these compactifications are specified by a quadruple (Y, V, TY, H) where X is a 6 or 7 dimensional manifold with a G-sturcture (a certain SU(3) structure in 6 dimensions or an integrable G2 structure in 7), V is a vector bundle over X with a Yang Mills connection which satisfies instanton constraints, TY is the tangent bundle over Y with an instanton connection, and H is a three form on Y defined in terms of the B-field and the Chern-Simons forms for the connections on V and TY (the so called anomaly condition). We recast all the constraints on the geometry of these compactifications in terms of an extension bundle Q over Y which admits a differential which squares to zero. We show that the tangent space of the moduli space is then given in terms of the first cohomology group with values in Q. Time permitting, we discuss the fact that all our results can be reproduced from a superpotential. We find a Kahler metric on the moduli space which is a natural inner product on the moduli space, with a Kahler potential taking a remarkably simple form, and as in type II special geometry, it is quasi-topological.