Commuting with a laptop that is powered on
In general that's not a good idea.
Hard drives with active protection systems will park the head on sudden shock (and these are more common than they used to be) and SSDs are nearly insensitive to shock. There seem to be more than one implementation of this, so you'll need to check with your hard drive model to be sure.
That said, your system will likely cook in a closed bag - especially when building files. Its also probably not healthy for your cooling system, and your overheating system may shut down midway through.
The orientation of hard drive was historically considered important.
Seeing that some versions of iPod's have the drive turned around all the time, one would think drive orientation change wouldn't matter.
However from personal experience with desktop drives, the "field" knowledge from multiple PC repair techs I have known over the years, as well as that expressed by other comments in various forums, I've personally taken a cautious view that changing orientation during use could be a real problem.
Specifically the common theme I've heard and experienced is that if you originally formatted the drive when it was horizontal, then using it vertically may make it more prone to read/write errors. Similarly if you originally formatted it while vertical, then it would be problematic when used horizontally. I have used that tidbit of info as an additional precaution while recovering an old drive that started clicking. However in laptop drives it may not be applicable since manufacturers expect the drive to be moved around a lot more than desktop drives. YMMV.
Your laptop drive was likely originally formatted when horizontal, so positioning vertically, especially while running builds because of large amount of reads and writes could be a problem, if the above holds for laptop drives.
Hard drive reader heads aren't exactly an equal length lever on both sides of the fulcrum (pivot). One side of the head is long and thin while the other side is short and heavy, crudely shown below:
[][]=(o)------------e
See a more accurate view of the geometry of the drives, here. This might be interesting as well, knowing that the core drive mechanical structure hasn't really changed in multiple decades.
The design is engineered to have the same weight on both sides of the lever to minimize mechanical energy expended in starting and stopping the motion. Two things happen here..
When rotating the head on another axis besides it's own pivot axis, the head is subject to gyro forces and as a result subject to mechanical stress during motion.
When pivot is vertical (i.e. head motion plane is horizontal) then the pivot has no stress moving it sideways. However when the pivot is horizontal (i.e. the head motion plane is vertical or the drive is vertical) then due to the weight of the head mechanism, the pivot will (due to its weight) put pressure on the bearings it is positioned on due to gravitational pull. No matter how precise the engineering, there will be some measurable effect on the bearings that will only come into play in vertical drives. This I guess, will be enough to cause the head to read the disk surface slightly offset.
Item #1 (gyro effect) could be a significant issue on multiple axes especially when the laptop is in a backpack and moving/bouncing up and down and rocking back and forth on the owner's back as the owner is walking. Though human motion is way slower compared to drive platters or readers' motion, so it may not be as significant as might be expected.
Item #2 could be an issue as well albeit less significant and much more automatically corrected with normal calibration that the modern drives already do.
In either case don't move your spinning drive like a pompom :-)
Regarding heat build up: Others have mentioned the heat accumulation inside the bag. I want to reiterate from personal experience that this can be a HUGE issue, and I'd really advise that you avoid putting a working laptop inside a bag for any longer than 1-2 minutes. Be careful with the sleep button, too. Sleep can fail if an error dialog pops up and you don't realize it. If that happens, your laptop can overheat, CPU protection may kick in, and you could lose your work, or worse.
If you really have to keep your laptop in the bag, see if you're able to get a vertical airpath with at least one air entry in the bag near the bottom and at least one air exit near the top. And make sure your laptop has vents that align with the bag's air entry points, only then will it be safe to leave your laptop in there for any longer than 5 minutes.
Reference:
https://superuser.com/a/50422/212609
Does vertical position affect the lifespan or integrity of a hard drive?
https://serverfault.com/a/14245
http://hardforum.com/showthread.php?t=1512482
http://hardforum.com/showpost.php?s=8249ef649e3616f32823f34b635aeeac&p=1035610869&postcount=2
http://www.tomshardware.com/forum/241026-32-vertical-horizontal-mounted-harddrive#5980965
http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/Archives/Computing/2012_October_3
http://answers.yahoo.com/question/index?qid=20110321205213AAhwSDV
http://www.extremetech.com/extreme/142911-ibm-3390-the-worlds-largest-and-most-expensive-hard-drive-teardown
http://en.wikipedia.org/wiki/File:Harddrive-engineerguy.ogv
I think that the spinning hdd will take damage with high-G movements, as the reading needle can accidently scratch the disk plates (the strong magnets prevent this from low-G movements).
Apart from this, the battery time and ventilation should be your main concern. When I do this myself, I only do it for shorter travels (max. 1 hour) and place my laptop in the bag with the ventilation opening upwards and the backpack slightly open to enable it to cool just a little.
If it gets to warm, my laptop goes to sleep, so no real damage happens though...