Even as recent as about one decade ago, the best way to learn a programming language is often buying a book or checking out a book from the library, because that's the only high-quality source on the topic. Since then we have had people creating complete tutorials like the Rust book and distribute it on the Internet, for free.
In the US, some professors profit from selling textbooks that get updated every few years, forcing students around the around to pay hundreds of dollars to get the latest edition. (That's still the norm.) Yet we are seeing less of that in the computer science field, especially with books like Operating Systems: Three Easy Pieces ( https://pages.cs.wisc.edu/~remzi/OSTEP/ ) -- the professors are literally practicing communism and giving away the book for free.