Teaching yourself to code while getting a CS degree is best IMO.
Just teaching yourself you'll likely miss lots of topics and not challenge yourself as much.
Conversely I've met plenty of students that don't really care about the topic and are just taking the class to get a job.
So do both! Take the class and teach yourself. In other words pursue your hobbies and use code where those hobbies match. Learn the things you need to achieve your hobby goals. All while taking CS classes and as much as possible making those two things overlap
Just teaching yourself you'll likely miss lots of topics and not challenge yourself as much.
Conversely I've met plenty of students that don't really care about the topic and are just taking the class to get a job.
So do both! Take the class and teach yourself. In other words pursue your hobbies and use code where those hobbies match. Learn the things you need to achieve your hobby goals. All while taking CS classes and as much as possible making those two things overlap