Choosing a PhD field, based on short term or long term decision?
By and large, I would recommend you to go with what is more interesting to you right now. As you say yourself, nobody can predict the future, and a vague sense that your specific chosen subfield may go out of style at some point does not seem like a good enough reason to settle for your "second choice" (especially since nobody can guarantee you that the "second choice" will stay relevant).

Further, I think you are overestimating to what extend the topic of your PhD will lock you into a specific field. I have personally switched topics somewhat after my PhD (from distributed systems closer to software engineering), and plenty of other people have done similar switches.

Finally, in cases where a specific topic of research becomes outdated (not uncommon in Computer Science, a buzzword driven field after all), there is usually some sort of "natural progression" for the researchers involved with the topic. That is, professors that used to do a lot of grid computing research 10 years ago now publish on cloud computing, etc.