Hosting code online allows developers to securely store code, experiment safely without risk of damage, and gain feedback through collaboration. Services like BitBucket offer free hosting of Git and Mercurial projects, including wikis, issue tracking, and pull requests. BitBucket is written in Python using the Django framework and provides similar functionality to GitHub for hosting Git repositories.