The dominant narrative on how research "should be" done is to begin with a literature survey and then make your own contribution.
But I get the impression that it often happens the other way around - at least in fields such as CS where the cost of knocking some lines of code together is low (compared to, say, a 3 year medical testing programme). Creativity knows no rules.
The obvious risk of this approach is that the research is subsequently found to be old hat, or better versions of the same thing exist already, or it commits an error already widely known in the field.
The reward, on the other hand, is that such creation might never have happened if the requirement of surveying the literature first was always met. (Indeed some grad students have been known to quit before finishing the lit review their supervisor asked for - maybe they'd have done better if allowed to exercise their creative nature first?).
So I would conclude that it's an acceptable strategy when the individual is happy with that risk/reward balance (provided they already know enough about what they're doing to have some inspiration in the first place, that is).
Are there other arguments/perspectives I've missed here?
There are a lot of very good answers here and there is no one right answer. I'm not quite sure how to handle that. In my experience this is the kind of thing that tends to lead to questions being closed as "not constructive" on SE sites. I'm glad nobody has done so yet because I think the full range of opinions expressed below is a very worthwhile thing to read through. Thanks all for your contributions.