I think you might be underestimating how much custom code has been written by companies like twitter and Facebook, think php to c++ compilers, databases, rpc servers, log frameworks etc etc. even if all of the designs of all of that software was given upfront I doubt any small team could build it within a month or so.
And the reason that custom code gets written is because it's specific to that environment. The wide majority of the software available is focused on either a very generic target or a very specific one. If you use something that is very generic, you need to customize it because one size does not fit all. And you can't use the very specific one because it doesn't match your use case. Or what's available is designed for a single webserver and a single database server, so it's really tempting to use that when you're small then you'll most likely need to replace that at scale. And by then, you're writing something that is specific for your use case, which you've discovered has grown dynamically and organically based on changing business and technical requirements.
It's difficult to take technology or software from one place and transplant it into another. The best we can do is take what we learn on past projects and past companies and keep those lessons in mind when making new decisions.
If the design and spec job was done with full knowledge of current state-of-the-art "web frameworks, databases, rpc servers, log frameworks, etc etc." - and requirements adjusted to suit "off the shelf" tested and reliable code, only speccing "custom code" where absolutely necessary, I think my claim is still supportable. I don't want a spec that says "you need to write this in php - therefore you need to write a php compiler to scale it". I want those problems solved by the spec. The "coders" just want APIs and datastructures and wireframes and finalised graphic design and content/content-inventory. I reckon I know people who could do it.