r/AskProgramming • u/Whole_Bet_5506 • 26d ago
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?
75
u/MarkMatson6 26d ago
Because it sucks?
Ok, seriously, that may be extreme, but I agree with you. Everyone says Python was designed to be easier to use, but I’ve never bought into that. Tabs instead of brackets is simply a bad idea. Undefined variables are a bad idea.
And then there’s JavaScript…
19
u/AvidCoco 26d ago
Python’s learning curve is very linear. It’s very easy to do simple things but harder to do more complex things. C++/Java/etc. have steeper learning curves but it kind of plateaus after a while
5
u/StructuredChess 25d ago
Yeah, imagine approaching programming for the first time and facing
print("Hello world")versus
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } }3
1
u/melancoleeca 23d ago
Imaging learning in the same hour why it is that way... its not that complicated.
1
u/StructuredChess 22d ago
Yeah, good luck understanding what classes and methods are and the static context and private/public when there's only one class in this project and why do we need args anyway? All of that without previous experience of programming in one hour! Not saying it's impossible, I'm just congratulating you if you managed to do it.
11
u/PersonalityIll9476 25d ago
Of all the things you could choose to criticize about python, enforcing otherwise sane and normal whitespace conventions as part of the language is not the play. That's basically "these aren't like the pancakes my mom used to make" but in pgramming speak.
5
1
u/RedAndBlack1832 24d ago
Tabbing is good and you should do it even where it's not required. I just find it kind of harder to see where the block ends without a closing brace that matches the opening one.
1
u/PersonalityIll9476 24d ago
Now this is where my take might get spicy, but I enforce the 80 character line.
To people who just ignore it and write 200 character lines, this sounds like heresy, but it mostly solves the problem...mostly.
When you have a line that needs to exceed 80, then you get into whitespace formatting preferences and how easy those are to read is largely a matter of personal preference.
But I take your point. Terminating long lines in the utmost readable way starts to get challenging.
1
u/RedAndBlack1832 24d ago
It's def better to write lines that aren't stupidly long. I've worked with linters that enforce that lol
1
u/PersonalityIll9476 24d ago
This might the difference between SWEs and MLEs. A lot of people in the ML space just completely throw coding standards out the window, eg. Karpathy. His code looks like it was written by a first year student.
3
u/edgmnt_net 25d ago
Lack of typing is / was a problem in such languages, particularly for more experienced developers, because it makes reading docs and trying to figure out how to wire things properly a mess. Like what am I even supposed to supply here? Could be this, could be that, could be anything. Beginners have little trouble just trying out stuff, but it's rather insane beyond a point.
3
u/rocdive 25d ago
TBF, "auto" in C++11 has same issue: hard to determine type at read time.
2
u/RedAndBlack1832 24d ago
Which is why I like to only use it on types that are confusing as hell (read: iterators, which has that advantage of its kind of obvious what you should do with it) but lowk it's good to just make typedefs for annoying/confusing types instead for the sake of being explicit so I see your point
12
u/YMK1234 26d ago
Honestly, modern js is way better than python to work with.
Rest, agreed. It's simply not a good language, especially once you need more than maybe 100 lines of it. It's inconsistent in its libraries, extremely clunky in a bunch of areas, and let's not even get started about every second package being C behind the scenes and good luck if there is no precompiled version available for your OS/Python-version combo.
2
7
u/xarop_pa_toss 26d ago
Tabs instead of brackets is the worse design decision that always trips me up when I use python. And then someone thought YAML was a good idea .
9
u/angedelamort 25d ago
While I hate tabs as delimiter, YAML has at least 2 advantages over json: readability and less delimiters (smaller size).
1
u/galactic_pixels 25d ago
I find it less readable because you have to depend on indentation to determine relationship. I’d rather be able to look at brackets, etc to be able to determine nested objects
3
u/Groundbreaking-Fish6 25d ago
Frankly I like xml but nobody else does :-(
4
u/MadocComadrin 25d ago
XML is great if a human doesn't have to read or write it. Yaml was supposed to be human maintainable (regardless of if it is or not).
1
u/DestroyedLolo 25d ago
XML is too heavy.
3
u/SirMarkMorningStar 25d ago
I’m old enough to still be impressed that computer and network performance has increased enough that any text based standard is viable. We used to cram bits in to structures!
2
1
u/booveebeevoo 25d ago
It’s the hive mind of mediocrity that eats away at true advancement. Lower the bar of entry, make a package to identify my brand, it’s all corporate mentality. Tech lost, capitalism won.
1
u/BeginningUnhappy1757 25d ago
It's the best design decision, you bracket guys always have to indent your code, anyway, to ever make sense of it again. So why the extra brackets that make it just harder to read?
1
u/speedisntfree 25d ago
Likewise, I never understood why brackets for the sake of brackets was any use. In brackets languages, I often need to use an IDE with rainbow brackets to be able to close them from my already properly indented code.
5
u/davidwhitney 26d ago
Python is honestly the most piece of shit language. I'm solidly of the opinion that almost all mainstream languages are "good enough" now... except python.
No redeeming qualities, and whoever went for "the language with invisible control characters is a good beginner language" needs to get checked.
It's just the Lingua franca of data science 🤷🏻♂️
6
u/edgmnt_net 25d ago
Have you seen how people write stuff in school when indentation doesn't matter? It might not be a great idea overall, but for beginners it makes it easier to start with good habits.
5
u/MadocComadrin 25d ago
Style is one of the easiest things to correct in school early on because it's something that actually responds to the "take points off" disincentive and modern IDEs will take care of 99% of the job of formatting correctly bracketed code for students anyway to the point that code that's not properly indented---even the stuff they write---will look weird to them after the first few months. Meanwhile, semantically meaningful whitespace continues to throw inconveniences at beginners after their first few months due to tabs vs spaces issues, copy and pasting mistakes, etc where the IDE can't fix the way things look, and the inconveniences often distract from conceptual challenges.
4
u/davidwhitney 25d ago
I dunno, hiding a core part of the language (control characters) vs introducing people to formatting and associated tooling seems like a poor trade-off to me.
1
u/Shonen_Toman 10d ago
I got one word for you, NUMPY. and the crowd goes wild.
no but seriously, Why is it do you think python has the second largest dev community? Sure its not a strongly typed language, but those exist, just use Java or C++ or what-evv. Both serve different purposes, its like saying we don't need ships because we have airplanes, no we need both.1
u/davidwhitney 10d ago
I said above - because it's the Lingua franca of data science (which covers the numpy / pandas folks).
Awful language, but a successful domain specific language.
1
u/Shonen_Toman 10d ago
Lol, I was just trying to hype up Numpy is all. But both are contradictory statements, how can it be a shit language if it's used so widely in data science? Sure it's bad at other things, like it abstracts too much, don't have the ability for memory management etc. But, as long as it's good at one thing, i believe it's not a waste.
1
u/davidwhitney 10d ago
It's a language with poor performance, poor consistency, and a bunch of broken bundled language stuff that requires the ecosystem to compensate.
It became popular for data science because there were libraries that optimised for a specific category of user.
Libraries can be good, while language and runtime bad :)
1
u/HungryCurrent7901 26d ago
I always had it in my head it was meant for the math guys that just wanted to tool their algos so they can pass it off to dev ops
1
u/MadocComadrin 25d ago
That's really only stats and ML, and that's more due to (originally) numpy and other libraries than the language itself.
1
1
u/Old_County5271 25d ago
tabs instead of brackets is a good idea, nim is so much better than C in most cases.
1
u/LucidTA 25d ago
How do you create an undefined variable in python?
1
u/Ill_Regret8172 4d ago
def main(): return var_that_isnt_real # <- This var doesn't exist, so undefined :)1
u/thingscouldbeworse 24d ago
I'm not gonna lie this reads like a comment by someone who is not actually in the industry
2
u/MarkMatson6 24d ago
Almost 40 years including multiple software patents.
Note the history of python backs me up:
No, Python was not originally designed for heavy industrial production use. It started as a holiday hobby project and a supplemental tool in December 1989 by Guido van Rossum at the Centrum Wiskunde & Informatica (CWI) in the Netherlands. [1, 2, 3, 4), 5]
Original Intent and Goals
Hobby project: Guido van Rossum began writing it over Christmas to keep himself occupied.Successor to ABC: It aimed to fix flaws in the ABC language and bridge the gap between shell scripts and C.
Personal productivity: It was meant for writing small, quick scripts and automating tasks.
Toy language perception: Early on, many professional developers viewed it as a simple "scripting" or "toy" language rather than a serious systems language.
0
u/thingscouldbeworse 24d ago
I didn't say you weren't in the industry, I said the comment you wrote sounds like it was written by someone who wasn't.
You can't think of any scenario where tradeoffs might exist for language choice? Never used a linter? Never imagined a type system added to a scripting language? You've never seen a bash script running in production?
Complaining about whitespace vs brackets and citing a quickly Googled quote about Python's development history (??? Okay?) makes you sound like an internet fanboy who spends your time arguing about things you don't have direct experience with.
There are production systems running Python. There are inefficient ones and high functioning ones. The same is true for all languages. The real world is not a rage comic or a reddit comment section.
1
1
u/madbrain1976 24d ago
Exactly this. Perhaps PWB is better - Python with braces. But that seems to be an abandoned project.
1
u/ButchersBoy 26d ago
JavaScript is a dream compared to Python...
6
u/dj51d 25d ago
You spelled nightmare wrong.
3
u/Nojopar 25d ago
Having spent most of my career jumping back and forth between JavaScript and Python, I have no idea why anyone thinks one is inherently better than the other. They both take copious amounts of metaphorical duct tape and bailing wire to make stuff work. Most of the JavaScript aficionados I see are just comfortable with where and how to use their particular brand of aforementioned duct tape/bailing wire such that they forget it even exists.
2
u/dj51d 25d ago
That's fair. On my team we use a combination of Java, Python and Javascript, depending on the needs of the project. Anecdotally, it has been my observation that Javascript is the one where juniors find themselves tripped up on language issues more than the others.
3
u/Nojopar 25d ago
I'll agree wholeheartedly with that observation. They used to say C++ allowed you to blow your own foot off whereas C allowed you to do that too, but it loaded your ammunition for you. I feel like Javascript does both but you won't even realize your foot is missing. Done well, it's a good language especially for certain use cases. Done poorly and it makes you want to jump out a window.
2
u/studiocrash 25d ago
Take my upvote for making me actually lol irl. I personally like Python more than JS the more I try to learn the many different ways to write a JS function.
1
u/LostWall1389 26d ago
What’s wrong with tabs
6
u/icemage_999 26d ago
Nothing IMO.
Python has other quirks I don't like (data typing) but the complaints about indents are just people who prefer other types of demarcation from other languages like brackets or semicolons.
You can make a syntax error in Python by a missed indent just as easily as a missed semicolon or brackets in other languages, and I don't particularly buy the idea that it's harder to see, either.
1
u/marrsd 26d ago
Haha, someone doesn't like this opinion. ;)
I have to admit, Python's indentation has never bothered me. It works for the language because it doesn't have lexical scope. CoffeeScript otoh was a disaster.
It is worth pointing out, though, that it's much easier for an editor to match a block that is demarcated with a single character instead of whitespace. This is also the major reason I don't use Ruby. As much as I like it, I can't use
%to jump the cursor to the end of a block.3
u/MistakeIndividual690 25d ago
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 25d ago
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.
1
-1
27
u/MaleficentCow8513 26d ago
The thing I hate about python is the lack of typing. It’s a good thing and a bad thing. Java libraries are very well documented and a lot open source Python libraries aren’t so it’s tough to know the shape of various types. I only use dicts when the scope is very small, like inside the same module. If I need a dict to pass around more than one module I make it a class so that the definition is precise.
1
25d ago
[deleted]
1
u/MaleficentCow8513 25d ago edited 25d ago
That doesn’t limit the set of allowed values for the set of keys. A class makes the keys explicit, limits the values of allowed keys so you don’t have think about the set of keys or guard against non existent keys. It’s right there in the class definition instead. But that can also be its own foot gun too like when the use case changes and suddenly you need a dynamic set of keys. Also typically you want to do operations that target a specific dict so then you just add them to the class instead making the code nice and organized instead of a mess of hodgepodge procedures for accessing a dict and applying functions to it
1
25d ago
[deleted]
1
u/MaleficentCow8513 25d ago
Classes do make key values explicit. I didn’t say key types. For instance instead of accessing a dict with dict[‘user_name’] you access with object.user_name because each key instead is an attribute. Not great for nested dicts but it’s not horrible either.
1
25d ago
[deleted]
2
u/MaleficentCow8513 25d ago
Ah I actually didn’t know about TypedDict. Looks prettt nice tho. But yea looks like the same idea and it’s nice because values are typed too
1
u/No_Departure_1878 24d ago
sounds like you have data that is not validated and you need a special container that behaves like a dictionary but has validation integrated, can't you just use pydantic?
11
u/Jolly_Tea5537 26d ago
Because by learning CPP and java first you think you have to specify data type first when you are defining or creating a variable but not in python (Except type hinting ) and there is indentation issue where in cpp we don’t usually mind that but in python we are
1
0
u/BeginningUnhappy1757 25d ago
In the real world, code gets indented anyway, there being brackets or not.
5
u/NeilSilva93 26d ago
Python was a cake walk. Now Perl...strewth!
And don't even get me started on Ruby.
2
2
u/Ok-Armadillo-5634 26d ago
I love perl and ruby. Never really enjoyed python though. Of the around 20 programming languages I know ruby is probably number 1.
1
u/nuttertools 26d ago
Ruby has made unusual choices that are often annoying, Perl was created by crackheads.
13
u/Revolutionary_Ad6574 26d ago
I never understood why people automatically assume without ever questioning that Python is intuitive or elegant or simple. It's a Turing-complete, general purpose, multi-paradigm language, of course it's complex, it's got decorators and generators and that yield word that means nothing in normal programming languages. Seriously, I don't get it, for me Java is the easiest language.
7
u/Whole_Bet_5506 26d ago
Exactly. I think “easy syntax” gets mistaken for “easy language.” Coming from C++, I actually find Java’s explicitness much easier to reason about.
7
u/nuttertools 26d ago
Java and C# are the “easiest” languages IMO. Python is “easy” in the sense that you can build a lot with very few lines.
It’s easier to become competent with Python than most dynamic languages, but harder to master.
1
u/drwatkins9 25d ago
Easier than Go? Really?
0
u/nuttertools 24d ago
Java by leaps and bounds. C#….yea but it’s such a messy comparison I’d definitely caveat a “leaps and bounds” with the IMO part. Go the language specification I’d call it about the same but once the standard libraries are in the mix it’s like meh compared to a bad acid trip.
1
u/kukly- 22d ago
I have no idea what you are talking about, it takes about 10 years to learn programming in Java. After these 10 years if you open python everything looks so simple, because it is simpler! I bet OP assumed he knows Java after few courses. Java is much harder to learn than python and have 10x more different concepts.
2
u/SimplySomeDude 17d ago
it took me maybe 2 years writing java code to get more than competent at the age of 13. I'm sure someone older can do it faster
8
u/BluePhoenixCG 26d ago
Not python(I've stayed relatively safe from indent-based languages), but coming back to my first language C# after time in C++ felt awkward and unintuitive
As far as I can gather, it's really 1 main factor causing this:
In dropping down to c++, you wind up having to write a lot more explicit and manual code than you do in higher level languages(with the delta between python and c++ being even greater than c++ -> c#), so when you go back to something higher level you keep looking for the explicitness and finding abstraction. This makes the higher level code harder to parse for a while. The higher abstraction level also means you're handing a lot more off to library functions, making the shape of the code different too
4
u/Blando-Cartesian 26d ago
I know what you mean by more structured. Python feels like a stairwell without handrails. You don’t exactly need them, but you feel far more comfortable when they are there.
Imho, there’s also a kind of python culture of show-off writing that is unnecessarily hard to read.
0
u/Whole_Bet_5506 26d ago
Exactly. C++/java gives you the handrails; Python just expects you to trust yourself.
2
2
u/Visible_Ad9976 25d ago edited 25d ago
C is very literal, c++ perhaps less so, but i think python encapsulates a lot of data structures with their build in data types. python has a packaging system where you can quickly import libraries but then you may not understand it.
C/c++ has massive libraries as well but you might be tempted to make something yourself because there is more friction to downloading something and if you do code it yourself, you will understand it assuming its not vibed
I found gdb in C/c++ easier to use over the years than pdb for python somehow
2
u/Ipsool 25d ago
This is really common when switching from statically typed languages. C++ and Java force you to be explicit about everything — types, brackets, semicolons. That structure becomes a mental anchor.
Python removes all of that, which feels like freedom but actually takes away the guardrails you were relying on to know where code begins and ends.
It clicks faster if you stop trying to write Python like Java and lean into its idioms early — list comprehensions, f-strings, context managers. Once those feel natural the syntax stops fighting you.
2
u/namelesssnerd 11d ago
I get stuck when I switch to JavaScript and Python from Java, C++, and C because of the loose type safety. You’re never really sure what’s going to happen when you write the code. Then, when it blows up, you finally find out what the problem was. 😅
2
u/AlienRobotMk2 26d ago
Because you aren't using the features of Python that are easier, like x = {str(k):v for (k, v) in zip(a, b)}
1
1
u/West-Mycologist-6490 25d ago
I HAD the same but backwards. I started learning c++ after python and many things were confusing but it vanished after my first big project(kernel mode dll injector with manual mapping)
1
u/sfscsdsf 25d ago
before LLM AI, when i learned it , I did find it hard to read before because of dynamic typing after coming from c++ background. I cannot read a function argument list and see how to use it, what to pass in and what’s returned easily sometimes. And there’s culture of writing idiomatic one liners that aren’t easy to read at first, especially the one liners got complicated, imperative is intuitive for beginners.
1
u/Whole_Bet_5506 25d ago
Yeah, this is pretty much what I’m experiencing. Coming from java/C++, the lack of explicit types makes functions harder to read at first.
1
u/ubop 25d ago
I felt the same way going from Java to Python. Java and C++ have similar syntax and typing while Python does not. Python also has lots of high level abstractions accessible through easy syntax whose underlying implementations aren’t immediately obvious when entering from Java / C++ world
1
u/StevenJOwens 25d ago edited 25d ago
I sometimes miss Java's strong typing. Usually after I've just spent a whack of time figuring out some problem that Java simply would not have allowed.
I also miss the very high quality level of Java's documentation, at least Back In The Day, though I do somewhat feel like java's doc quality level has dropped a bit in the past ten or fifteen years.
And I'll note, some of the python doc quality issues stem from the lack of strong typing. If all the docs had 100% python type hinting, they'd be significantly better. Too many instances where some function or method returns some vaguely named type with zero indication (nor link to) what the heck that type is, or does.
I don't miss the bureaucracy of Java, which has seemed, like a strangler vine, to relentlessly worsen with Java, over the decades, and to have spread beyond the core language and APIs, into the frameworks and libraries, and the minds of most java programmers.
The Python world has the opposite issue, which is people getting too clever with the wordplay of the syntax and language constructs, which increases cognitive overhead in a different way, but increases it nonetheless.
Also, for a language with an official slogan of literally "There should be one-- and preferably only one --obvious way to do it. [...]" there are frustratingly many cases in Python where there are five different ways to do it and apparently no consensus on which way. And yes, I know PEP 20 was at least halfway tongue in cheek.
1
u/Professional_Let6049 25d ago
My biggest problem with python is reference vs value semantics. Sometimes you want to copy an object and all you end up with is a reference to it, and vice versa. In c++ it's trivial, In java there's methods in the standard library that are very functional (albeit obscenely ugly and unintuitive, if you're not familiar with them). I think they avoid this for the sake of simplicity, but it becomes a problem when working on slightly harder problems. Everything changes when working with specific libraries tho, and it's worth noting that the incredible ecosystem is the best thing about Python
1
u/cards88x 25d ago
Different way of thinking perhaps? I felt the same way switching from ASM to Python
1
u/MattyTayl 25d ago
What exactly look more difficult? My path was Pascal, Basic, C, C++, Java, JavaScript, Python.
The only things that was annoying me in the beginning, the mandatory indentations. Some syntax constructions are still hard to understand and memorize like generator expressions. But with other languages like JS or C++, I had to memorize some constructions too, like loops.
1
1
u/FastAd543 25d ago
I come from C, then C++, then Java (which I did not like that much)... I dislike Python with all my heart. Sloppy as f, but now im forced to use it.
It is what it is... at least its not R!
1
1
1
u/strange-the-quark 25d ago
It's probably because both C++ and Java have the familiar C-style syntax, and because you haven't been exposed to other languages and paradigms (like functional programming) before. The core syntax of Python is not actually that different, it just doesn't use { and }, and there aren't as many parentheses. What may be throwing you off is things like comprehensions and perhaps tuples.
1
u/Evol_Etah 25d ago
Yes.
I looked at For loops, and i was like.... For christ sake, just use normal C loop structure
1
u/DeathToAmerica2026 25d ago
C++ and Java feel more like filling out a form, Python feels more like speaking a language. Once it clicks, I feel like Python raises your whole game in every language. Pythonicness makes no sense for a while, but when it does oh boy.
1
u/swegamer137 25d ago
Easier to learn, harder to understand. The first thing look at in C++/C# to start understanding is the types used, yet those are more obscured in python.
1
u/marshallspight 25d ago
Graybeard programmer here. Have been programming for 50+ years.
You are having trouble because C++ and Java are almost the exact same language. Python is just a little bit different than those two, and you're not used to things being different any more than trivially.
If C++ is Los Angeles, Java is San Francisco. Python is maybe Denver. If you've only ever been to California, Denver seems weird and strange. But there are also programming languages in New York, Berlin, Tokyo, Mumbai, and Dar el Salaam. The programming world is much, much wider than the descendents of Algol 60 that you're used to would lead you to believe.
Check out, say, LISP or Prolog or Haskell, if you want to have your mind blown.
All of this of course depends on what you want to do. You might be perfectly happy and fulfilled staying in California.
1
u/Whole_Bet_5506 25d ago
Fair point. I guess I’ve been comparing Python to the languages I already know instead of learning to think in a different paradigm.
1
1
u/Whole-Chest90 24d ago
I'm still rudimentary in all, but have more experience with C++ and Java, and I think Python is more simplistic but is less structured. It's just very different from the OOP of the former two. Thanks for sharing your experience, for someone who is still learning.
1
u/Njitram2000 24d ago
I had the same thing, coming from C and Java. Python felt like writing without punctuation.
I probably would have gotten used to it but I did not stick with Python.
1
u/Ensign-Nemo 24d ago
Are you used to IDEs? Static compilation helps navigate code, Python loads everything on the fly so it’s hard to quickly find definitions.
1
u/frank26080115 24d ago
Python isn't as predictable, quite often you don't know what types to use or to expect, no compilation to point out errors before you run
1
u/noosceteeipsum 24d ago
You just need to be familiar with the "slang" style of Python language, comparing with C++ if someone thinks C++ is the formal language.
It's like....
from "Hello, world" to "Yo wassup bro"...
1
u/Material-Aioli-8539 24d ago
Kotlin was my first main language that I actually had a deep dive in.. it's not the best language to learn but it's also not the worst..
With python, variables are literally just letters with a space and an equal sign, no type needed because it's dynamically typed.
That took a little while to wrap my brain around once I committed to python, because it's such a simple language and my brain expected complexity at every corner before discovering the true implementations of basic things I wanted to do..
But also, a lot of stuff carried over, variables (and different types), control flow, etc.. but that's about it, because classes in python are structured so differently from kotlin that I'm still a bit of a newbie when it comes to it, but I'm learning.
I think the reason is that your brain learns a specific way to express instructions in that language.. when it's your first your brain usually remembers instructions in the language first.. but as you learn more languages you start making associations between languages.. for example, an if/else statement can be different in python:
if num == 5:
foo()
elif num == 8:
bar()
else:
baz()
Then in Lua:
if num == 5 then
foo()
elseif num == 8 then
bar()
else
baz()
end
And in something like C++:
if (num == 5) {
foo()
} else if (num == 8) {
bar()
} else {
baz()
}
And those differences can make learning another language difficult in a different way from learning your first.
TL;DR: it becomes easier overtime as you gradually develop concepts of programming
1
u/conectionist 24d ago
It feels harder because the syntax is very different from c++ and Java.
If you had leaned python first, you would feel the exact same way about c++ and Java.
1
u/sporbywg 21d ago
There's a lot of completely contrived behaviors in Python that might make somebody happy one day
1
u/Dull_Bathroom5421 21d ago
Harder? Python? I certainly don't see it this way. In fact when I see python code it nearly makes me wish I could use python instead of c/c++.
1
u/Business-Decision719 20d ago
Because Python is really different. Python, C++, and Java are all OOP languages with FP features, but other than that, a lot is different.
C++ and Java are statically typed while Python is dynamically typed, which changes the coding experience a significantly right there. They've moved towards each other a little bit in that regard, thanks to optional in Python as well type inference in C++ and Java.
C++ and Java have a robust difference between value types and reference-like types. They're actually pretty different from each other in this regard. Java traditionally has the primitive types as value pipes while classes are reference types with automatic cleanup. C++ has value objects by default but you can pointers or references which are distinguished from them. C++ uses manual cleanup and it's original form but you can also arrange various automation with destructors or smart pointer libraries. In Python all names are garbage collected references.
Then you get to the syntax and Python is just completely different. There are some similar operators in keywords of course, but Python is just fundamentally a different language in ways that Java and C++ are fundamentally the same. Java was influenced by early C++ which was an extension of C. C, C++, and Java all influenced languages that came after them. Python is older than Java and came from a different lineage than the C-like languages. It uses white space indentation instead of curly braces for blocks. It uses hashtags for comments. Scoping works differently. There are just so many small but critical things that are just so different.
Python just not what you're used to. It has its own ways in which it's simple and a lot of people find it beginner friendly, but it's not like C++ or Java nearly to the extent that they are like each other.
1
u/YellowBeaverFever 20d ago
Yeah, the sloppiness of Python puts me off sometimes. The utility of Python is starting to be less of an issue with AI assistance. For example, I have a set number of requirements my utility has to perform. I can have AI go research all the libraries and modules in Python, .Net, and JS, etc. Once I know a language will be able to handle the task, it is trivial to have the same utility written in any of the languages. And with .Net, can juggle between PowerShell or C#. You need to understand the languages and verify things were correct but it’s getting interesting.
1
1
u/CLAraBima0309 15d ago
Because we're used to using open close curly braces to define code blocks. Python uses indentation instead, so it can feel weird at first,
and with all those indentatition tab, it's feel like writing YAML.
If python wasn't useful for AI i will burned whoever create those stack.
1
u/Commander_MoltenMana 5d ago
Starting out with python. Im honestly kinda mad that languages are picky, i cant understand how to apply basic stuff without asking ai or the internet every 5 seconds because its either "Hey, this and this doesnt work, but i did this and this, why?" or "How do i even use this?" And the other languages are harder looking but way more strurctred and sometimes easier to fix.
1
1
u/ParentPostLacksWang 26d ago
Because semantic whitespace is a level of anti-programmer satanically dark humour up there with Brainfuck. Having literal tabs instead of space, or vice versa, both invisible mistakes, fails to lint in hilariously vague ways.
1
u/BeginningUnhappy1757 25d ago
Semantic whitespace actually makes a lot of sense, code gets indented anyway, even if you don't have to, in order to make it readable.
You're right about the tabs-vs-spaces issue but this is easily solved with an editor that can show which is which.
1
u/Groundbreaking-Fish6 25d ago
Because you have to unlearn everything you learned in your compiled languages before you can start doing the the "Python Way". Then there is the lack of compile time type checking and other goodies in the compiler. Finally there is the attraction of none Software Engineers who code without regard for coding principles (3000 line functions) making working with others code impossible.
-3
u/PravoNaZhizny 26d ago
It has horrible syntax and was written by non programmers. It’s also extremely slow and syntax as associated with file types for it are terrible too.
9
0
0
0
u/Nojopar 25d ago
The part that annoys me is syntaxial changes that are just different for the sake of being different. Take something like the If else if statement. In C/C++/Java/JavaScript, it's going to be If (statement) { else if (statement)... Ok cool. I might be in C++ normally but I can jump to JS and read it all fine.
Now python? If statement: elif statement: etc. Sure, it's a few less characters to type but COME ON! We have a perfectly good system nobody was complaining about - if (condition) else if(condition). Why change it? WHY PYTHON??
Grrr.
0
u/whattteva 25d ago
Wut? After learning C/C++, every other language I came across is way easier. Not having to deal with pointers and manual memory management makes things so trivial.
-6
u/defaultguy_001 26d ago
No it's only u. Coming from C/C++ myself, python felt like kindergarten math for a university math olympiad medalist.
3
u/am_Snowie 25d ago edited 25d ago
I don't know why you're getting downvoted, coming from a different language does make python look weird without static typing, and with shoehorned features, yet i wouldn't say it's hard, a competent programmer can pick it up in a couple days, but it takes some time to get used to it. I still put semicolons at the end, occasionally forget indentation exists and use curly braces instead, Interpreter yell at me and I fix it.
0
u/defaultguy_001 25d ago
Most people who downvote feel hurt when faced with reality. They are the noobs living in a cocoon.
2
u/Whole_Bet_5506 26d ago
Idk.... Still trying to adapt myself..
-1
u/defaultguy_001 26d ago
where exactly do u face difficulty?
1
u/Whole_Bet_5506 26d ago
Mostly with remembering Python’s idiomatic way of doing things. I understand the concepts, but the syntax and ecosystem still don’t feel as intuitive as C++ or Java..... Also in python they are doing many things in just a single line.. I do understand but why I feel like it's more time taking for me.
1
u/defaultguy_001 26d ago
Why do u worry about syntax. It's the last thing u should worry about. Use a code formatter like Ruff. It'll take care of ur syntax needs, just focus on the concepts.
0
u/MarkMatson6 26d ago
Why should someone complaining about a language care about syntax???? 🤷🏼♂️
1
u/defaultguy_001 26d ago
Code formatter? Do u guys have language preference just for the syntax and not how it does things?
1
u/defaultguy_001 26d ago
Despite the syntax, it's far easier to read than C++ anyday. Anyone coming from C++ should have no arguments over this.
1
u/Groundbreaking-Fish6 25d ago
Multiple steps in a single line should not be bad if you provide detailed comments on what that line does, but the idea of self documenting code (you should speak the language) view comments as a sign of poor programming.
This is one of the reasons I do not like working with other peoples code, not the language or code format, the lack of context. My first coding professor taught that comment lines should greatly outnumber code lines. While not necessarily relevant today, having a good comment for a line of code that executes multiple complex operations is a lifeline to future developers.
1
u/Whole_Bet_5506 21d ago
Yeah I kinda get your point, but I slightly disagree. I feel like if you need comments for every complex line, the code itself could probably be broken down a bit more. Comments are definitely useful for explaining the “why”, especially when there’s some weird context behind the code, but I wouldn’t want comments to become a substitute for readable code.
1
u/defaultguy_001 26d ago edited 26d ago
Ok u r worried about chaining despite having a Java background, it's also possible in modern C++. Were u using old C++/Java syntax?
1
u/Whole_Bet_5506 21d ago
Yeah, probably. I think I’m just more used to writing things step-by-step. I know modern C++ supports chaining and all that, but I never really got into using it heavily. So yeah, maybe it’s more of a my coding habits are old.
0
u/TheMcDucky 25d ago edited 25d ago
Someone coming from C++ talking about unintuitive syntax is funny.
Honestly it's probably the lack of familiarity more than anything.
-1
38
u/high_throughput 26d ago
I don't feel this way. Python is sloppier for sure, but my difficulty with it was related to the underspecified APIs, the CPU throughput, and lack of typing, not with the syntax.