I would argue that it only becomes "research" when reading up on existing literature is involved. Basically, if inspiration hits you and you just fire up your IDE to test it, you are not aware if what you are doing is in any way novel. That's not really the nature of research.

**Edit:** (I should add that even if something is not novel in a scientific sense, it can still be extremely interesting and cool to do - however, it will likely never lead to a paper)

That is not to say that a researcher is never allowed to just follow her/his inspiration. It has certainly happened to me more than a few times that I had a crazy idea and just ran with it. Oftentimes, the quickly led nowhere and I just forgot about it. Sometimes, initial results proved interesting and **then I went ahead and did proper research before going further**.