Using an engine like Unity can teach you a bit about programming if you're a total beginner, but frankly its more designed for productivity than anything, you'll maybe learn the syntax of the language and get some work in with it, but not necessarily complex topics. You'll learn more about making games as an overall production experience than you will about coding them in particular, you'll have a lot of drag and drop where you would be coding yourself.
If you don't want to learn to make games but just to program you probably should be starting with tutorials or something and just making some simple applications, sure you can make things like console text games simply, and they test your language knowledge. That said, trying to make something like a 2d or 3d game from scratch, even with the help of a framework like XNA or even SFML or something, is extremely challenging. Frankly you'll learn a lot of stuff that won't even be remotely useful to you in a lot of programming fields, and some that will be.
Game coding in particular tends to take an amalgamation of other programming fields and shove them together to make games. We focus a lot of graphics and 2d/3d world interaction(simulation is all about this) we might end up writing GUI systems for ingame menus and user interfaces that rip the event based model right out of your standard GUI programming libraries like QT, we end up having to deal with time, on a very precise level as well as things like physics, ai, audio. A lot of that stuff isn't even remotely applicable to certain fields.
I guess what i'm trying to say is that you should be specific about what your most important goal is, making games can be fun but in general its a -lot- of work, even just making tech demos really puts your coding knowledge through the wringer sometimes, forget the people doing innovative stuff like inventing new ways of doing everything, its a challenge just to implement existing things usually.