Please note that both H1B and "Diversity Visa" are lotteries, there is no guarantee that you succeed. I read about a situation of a Silicon Valley startup founder, who applied for H1B visa (as student in Stanford U), failed, and was not able to work in his own startup, only remotely from Europe.
Are you willing to wait few years, hoping to win H1B visa? For company low success rate when applying for such visa it does not matter: if they know that current success rate is say 30%, they apply for 3 times as many positions as they have to fill (it just cost more). But for you, failure to win means one more year spent in limbo, waiting. Are you ready for that?
H1B application is quite expensive (company may need a lawyer to do it correctly), and success rate in GC Lottery is obviously rather low.
There is another way. You can apply for immigration to Canada, which has saner and more predictable immigration policy (based on skills, and as a programmer, you have interesting skills they like). Even for non-programmers, Canada has point-based system, so aspiring immigrant can estimate own chance before paying lawyers. If accepted, you can live and work in Canada. From there, you can decide if you are just fine in Canada (make sure you look into what a mess is healthcare in USA - for me that was the ugliest surprise here), or after becoming Canadian, you can apply for TN visas (NAFTA) to live and work in USA. This way is much slower, but final outcome is much more predictable.
Yet another way is to get a visa based on marriage (not sure if you are married now). If you have a friend in USA, you can get a fiancee visa, which allows you to enter USA and if you don't get married in few months, you return home.