It is much more motivating to be learning to program with a particular project in mind. I'd argue it also teaches you to program better because you can't avoid the bits of the task that you find difficult or tedious. I'm a scientist but I spend a lot of my time programming experiments, models or analysis code.
I teach a research methods module to undergraduate life sciences students. The vast majority of these people have never programmed and never expect to. This is a bit strange when so much of being a professional scientist in my field involves programming. Recently, we changed the research assignment they have to do so that it now involves some very basic programming. Mostly GUI stuff where they build a timeline and a "flow" out of blocks, but there are a few lines of code they need to write too.
I was expecting there to be much wailing and gnashing of teeth about the content being too difficult, and a rebellion against being made to program. In reality, nobody complained and most of the students seemed to enjoy it. Some of them got very excited about writing a program that made a computer do what they wanted it to do. They also got quite competitive about writing their programs better than their colleagues (to the point of argument, but it was still encouraging to see). These people were not nerds, and talking to them I got the impression some thought computers were just "magic". One student didn't even understand that computer programmers existed who wrote software to make computers do things.