I come from a non-Computer Science background, and I'm exploring other paths in tech, one of which is software engineering.
I have a vision of a software engineer working on the same piece of logic daily: Is that what it's like and if so, can that get lonely? Or is that actually what most SWE love and find exciting?
I'd argue that you should not feel lonely if you're doing your job correctly as an engineer.
Of course, there's a difference between what should happen and what does happen: especially in the post-pandemic era where many people are remote or hybrid, many software engineers do end up feeling lonely.
But as I mentioned in this question, I fundamentally believe software engineering is a team sport. You should be having brainstorms, pair programming sessions, and reviews with your manager, peers, and broader team. These interactions are necessary to keep the team functioning well in a growth environment where engineers actually have autonomy and decision-making power. (read: a good company!!)
Some companies treat engineers as pure resources, just code monkeys who do their assigned work without much interaction. These engineers can feel lonely, and beyond that, their career growth will be stunted. The best thing for them to do is leave their job and find an actual team they can join.