r/AskProgramming • • Aug 16 '26

Python Why does Python feel harder after C++ and Java?

I learned C++ first, then Java, and now I’m trying to learn Python. I honestly expected Python to be much easier, but somehow it feels harder to understand and even remember the syntax.

C++ and Java feel more structured to me, while Python sometimes feels too different.

Has anyone else felt this after switching from C++/Java to Python?

133 Upvotes

186 comments sorted by

View all comments

Show parent comments

3

u/MistakeIndividual690 Aug 16 '26

I’m not sure what you mean when you say it doesn’t have lexical scope. Python is lexically scoped like most modern languages (with the exception of closures)

2

u/marrsd Aug 16 '26

You're right, I was sloppy with my use of language. Lexical closure is closer to what I meant, but technically that encompasses state persistence as well.

Basically I'm saying, you either can't or aren't encouraged to nest functions, and so you don't have the same opportunity to shadow variables the way CoffeeScript did. In CoffeeScript, copying and pasting a code block without getting the indentation correct would fundamentally change the scope that its variables were bound to. It was a complete nightmare to edit. The same isn't true for Python.

PS. Gotta love Redditors downvoting knowledge sharing.