I went to a smallish private university and in the first year, there were about 50 people who intended to go for a CS degree. By year 2, there were about a dozen left. Every single one that said 'I heard there were good jobs in it' was gone. CS and writing code is not like many different arenas in that if the homework takes you 8 hours to understand, then it takes you 8 hours to understand. If you don't understand it, it is an order of magnitude more difficult to 'wing it' or get 'partial credit' when there is absolute proof of your lack of understanding with non-compiling or non-functional code.
I studied CS and Philosophy. I could phone in a philosophy paper if I wanted. I could not phone in a linked list implementation. I know companies loathe the idea like no other, but software engineering is a skill that is difficult for most people to acquire and is likely to remain that way. Mostly it boils down to peoples understanding and value they place on logic. Anyone with a good grasp on, or even just a high value for logic, can learn to code. No one who sees logic as 'nitpicking' can learn to build systems that function predictably, reliably, and accomplish a defined goal.