I tried ssh -X
but it was unbearably slow.
I also tried RSE, but it didn't even support building the project with a Makefile (I'm being told that this has changed since I posted my answer, but I haven't tried that out)
I read that NX is faster than X11 forwarding, but I couldn't get it to work.
Finally, I found out that my server supports X2Go (the link has install instructions if yours does not). Now I only had to:
sudo apt-get install x2goclient
on Ubuntu),Everything is just as if I was working on a local machine, including building, debugging, and code indexing. And there are no noticeable lags.