Would it be ethical for a computer science PhD student to hire an assistant (programmer)?
I don't think it is inherently unethical to do this.  If all relevant parties know about it and you scrupulously acknowledge this other person's work, then I see no specific problem.

Whether it is advisable is a different question...and one you should certainly ask your advisor.  I have to say that it does not sound like such a good idea to me.  Your thesis work is for you to do...almost by definition.  It is perfectly fine to get help from others on your thesis, and some people are better programmers than others (even in CS, I imagine), so getting some pointers from a friend is actually a good idea.  But paying someone to do a part of your thesis work just doesn't sound good to me.  Either the programming is an important part of your thesis or it isn't.  If it is, you should do it yourself.  If it isn't, maybe you don't need to do it at all, or don't need to do it to the degree that an outside professional would.  

There is also the issue of the impression this subcontracting would make on others.  Perhaps the cultural norms in your field are very different from mine (again: ask your advisor), but I would have a rather negative impression of a PhD student who did this: they don't seem to be very committed to their own work.  

Added: To be clear, I am interpreting the question as meaning that the doctoral student himself is doing the hiring: i.e., that this is his idea and he is using his own funds.  (If his university is giving him funding and simply asking him to pick someone to work with, then even asking the question "Is it ethical?" becomes less plausible.)  

In terms of suspecting that this is not a good idea, I hope I was clear that this is my personal opinion, with experience from a field (mathematics) which is rather closely related to CS but is not necessarily identical.  As I said, the OP should consult their advisor about this.  However, for what it's worth I find it hard to believe that the reaction will be "Sure, spend your money."  While not unethical on the OP's part, it seems, shall we say, suboptimal if both advisor and student feel that this is the best way to proceed.