Usually, your web application is published as: www.yoursite.com/. The ~ character matches the root of the site, /.
However, if you publish your site withing a virtual directory www.yoursite.com/mywebapp/, then the ~ character would match /mywebapp/.
Hard-coding URLs with the “/” character would cause incorrect page references.