Using the first-principles calculations a comparative analysis of electronic structure and optical properties of crystalline Si with cubic Mg 2 NiH4 and monoclinic Mg 2 NiH4 has been performed. It is found that the band structure of cubic Mg 2 NiH3 is similar to that of crystalline Si (c-Si), whereas the band gap of monoclinic Mg 2 NiH4 is similar to that of the hydrogenated amorphous Si (a-Si:H). It is shown that cubic Mg 2 NiH4 possesses the features of semiconductors such as wide fundamental band gap, capability for nand/or p-type electrical conductivity, and small carrier effective masses. It is concluded that Mg 2 NiH4 can be considered as a candidate, which is capable to replace c-Si and a-Si:H. It might be useful for the processing of electronic devices such as, e.g., solar cells at low temperatures. Advantages of using hydrides in semiconductor electronics are discussed.