>If you value the freedom to pursue your own research direction and share your work freely, then choose academia
Perhaps it is more free, but my understanding has always been that professional academia still restricts freedom of research. You have to apply for funding, convince the board that your direction will be fruitul.
An archaeologist can't just dig wherever. They compete with their peers for a limitted funding pool. If the school's board is more interested in the bronze age than the paleolithic, you're probably not going to get your dino dig approved.
The same is true for CS, I assume. You can't just "i would like spend university resources developing brainfuck 2.0" because the other teams are more likely to get their funding over you getting yours.
Both corporations and university's have finite budgets, both with bottom lines and margins. The uni wants their research done in a popular field that will attract students because students generate income that funds research that attracts students that generate income that funds research that...
Academic research is free in the same sense as running your own business. You can try whatever you want if you can find the funding, but you still have to deal with people and regulations.
Universities are mostly just administrative organizations. They have little control over your research, they rarely fund it, and they are usually not even interested in it.