DEV Community

Discussion on: Why all this hate about Python?

Collapse
 
lochsh profile image
Hannah McLaughlin

Python was the first language I learnt, and the first I could consider myself any kind of expert in. I love that it has clearly stated design goals, and that one of them is being readable. The dynamic typing definitely makes it faster to get stuff going, which I think can be crucial for new programmers -- getting that reward for your coding is so important for it to be enjoyable. Other languages can make it feel a lot harder to even get something simple working.

That said, the more I program in languages with static typing and powerful type systems (like Rust), the more appreciation I have for how many bugs can be completely eliminated by these languages. I hate that in Python there is always a possibility that everything will crash because a variable of the wrong type gets passed into a function, and there's no way to guarantee this won't happen. Good test coverage reduces the likelihood of this kind of bug, but it's frustrating to have to write tests for things that other languages simply do not allow -- it's a lot more work for me, and will never have the same guarantees a compiler can give me.

I think that people can be unkind when comparing programming languages, often simply to make themselves look smarter. Try not to let these people bother you :)

If you want to know more about different type systems, I recommend Destroy All Software's article here :) destroyallsoftware.com/compendium/... It does a nice balanced job of explaining and comparing different approaches, including Python's.

Collapse
 
alysivji profile image
Aly Sivji

Great post!

Python 3.5+ supports type hints, but that's only for your linter (and other static code analyzers) versus not having it compile.

It's a step! =)

Collapse
 
kenseehart profile image
kenseehart

And unit tests. Unit tests contribute much more to reliability than type checking.

Collapse
 
antero_nu profile image
Antero Karki

How often does wrong type bite you though? Many strongly typed languages allow passing null as any type anyway and I find that a far bigger problem than passing foo when a bar is required.

Collapse
 
jasongabler profile image
Jason Gabler

I hear what you're saying about the dynamic (or, weak) typing. But I've always believed that weakly typed languages are a bad choice for beginners -- for exactly the reasons you've been learning to appreciate stronger typing. Weak typing might lead to more instantly gratifying accomplishments in the beginning, but as the beginner's software grows into something more complex, already established bad type-ing habits lead to some of the more difficult to debug errors rooted in the subtleties of weak typing. As you've pointed out, strong typing removes that ambiguity, leading to clearer code. It might be more verbose at times, and also less tricky and impressive. But when it comes to the actual computing that happens down under, there's really no difference. And when someone else takes on the maintenance of that code, the one thing their going to want is straightforward, obvious code. Cool, trick, obfuscated solutions waste time and money.

Like I've been saying in this thread, Python is good for what it's good for. As for pedagogy, especially for those who wish to be industrial software developers, I don't think Python is it. I believe schools who start out with Python do so because it's the in thing right now.

Collapse
 
kenseehart profile image
kenseehart

Python is good for what it's good for. For the rest, I code an extension in the appropriate language for the task and call it from python :)

Collapse
 
lochsh profile image
Hannah McLaughlin

I think it's really interesting to think about what is a good programming language for people to start with. It's something I have conflicted feelings about.

I think you might be right that Python is not a good first-language choice for people who want to be professional software developers. But I also think that software should be open to more people than that.

I think it's difficult to balance the advantages of learning things "right" the first time, and the concern that people might not learn anything at all if the content feels inaccessible. I worry about people picking up bad habits/not ever learning what is going on under the hood of their Python program, but I worry even more about people giving up on learning to program altogether.

Perhaps the answer is better teaching approaches & materials for languages that are considered more difficult to learn. Perhaps our entire approach for teaching programming needs updated so that the chosen language is less of a big deal. I don't know.

I think you may be right that some schools start out with Python because it's trendy, but perhaps there's a reason for that trendiness. It's definitely more accessible than, say, Haskell.

Collapse
 
ronbarakbackal profile image
RonBarakBackal

Hi Jason! I think I agree with you that Python is not a good language to start with. But what is your suggestion for a starting language?
Actually I've seen that Oxford starts with Haskell, which I think is pretty unique. I can tell you I mostly see either Python or Java for starting choice! Usually after covering Python and Java there is gonna be some short C/C++ just to ensure everyone is on the same page.
I tried experimenting with Julia(incredibly easy to math your way to a result), Go and Rust and there was something satisfying about those(I'll say how easy it's gonna be Julia-->Go-->Rust or Julia-->Rust-->Go)

Collapse
 
hasnatbabur profile image
Hasnat Babur

Atleast treating white space (indent) as a language structure always seems to me odd.

Collapse
 
kenseehart profile image
kenseehart

The combination of braces to implement structure while using indentation to visually convey structure seems odd to me. Seems like a violation of the DRY principle.

Python removes that redundancy by using indentation for both, that way visual structure is always consistent with actual structure.

Whereas many other languages are redundant in that respect, which does not respect the DRY principle.

Wait, did I already say that?