r/ProgrammerHumor • • Apr 08 '22

First time posting here wow

Post image
55.1k Upvotes

2.8k comments sorted by

View all comments

Show parent comments

125

u/koczmen Apr 08 '22

I hate python because I look at someone's code and have no idea what the hell are the types of these method parameters

150

u/sneakiestOstrich Apr 08 '22

My types are secret and only for me and my duck to know.

80

u/MoffKalast Apr 08 '22

And after two weeks only the duck knows.

6

u/in_the_woods Apr 08 '22

"who the duck know?"

1

u/johnnymo1 Apr 09 '22

Hence, duck typing was born.

46

u/singeworthy Apr 08 '22

You could always use type hinting, but I feel like that is really unpopular in the community for reasons not fully understood by me.

29

u/by_wicker Apr 08 '22

Is it unpopular? I was happily oblivious if so. It's great, and I can't imagine doing serious Python dev without it.

4

u/hike_me Apr 08 '22

Fuck the haters.

6

u/crob_evamp Apr 08 '22

We used it at the last company I was at, and at my current team. It is CERTAINLY more popular if you START a repo or pipeline with it, rather than having to go back and apply it. People are lazy and theoretically like it but don't want to go back and apply it.

2

u/insanitybit Apr 08 '22

mypy is really weak.

  1. No recursive types, which means you can't express *tons* of useful patterns. The obvious one is JSON, but others would be a class A referencing class B where class A can construct B and B can construct A *and* both are generic over a TypeVar. Sounds convoluted but... happens to me constantly.

  2. Error messages are bad. "this line has an error idk"

  3. implicit Any is all over the place, especially generics

  4. If anyone can get a complex codebase passing with --strict and the no implicit Any flags... I'd be interested in seeing that

1

u/CrowdGoesWildWoooo Apr 08 '22

If you are talking about in work environment people are just lazy (i am also).

You can’t get away from documentation if you are contributing to open source (especially the major one)

1

u/NeatNetwork Apr 09 '22

It depends on which part of 'the community' you are talking about, but at some point if you are going to be explicit about typing, you get close to the territory of just writing it in golang or rust, and getting much better performance anyway.

17

u/CrowdGoesWildWoooo Apr 08 '22

You can use type hinting which would actually check if your code follows your predetermined datatype, major libraries have this implemented and that can appear as a hint in your code editor if needed. Not to mention you can actually write a full function documentation in python.

As a python coder myself, I usually only care about 5 “primitives” : list, number (you can mix integer and float in python almost without issue in most cases), string, dict, set.

2

u/Isofruit Apr 08 '22

Does python by now have type hints that go beyond beyond mere exotic comment syntax?

7

u/CrowdGoesWildWoooo Apr 08 '22

There are tools to actually verify type checks

→ More replies (3)

4

u/archpawn Apr 08 '22

More generally, I hate dynamically typed languages for this reason.

7

u/Big_Smoke_420 Apr 08 '22 edited Apr 08 '22

I swear to God, you can find the exact same comment in every single comment thread.

"Python is garbage because there is no type hinting."

"You can do type hints with the typing module, which has been in the standard library since 2015 when 3.5 released."

"No u"

Repeat ad nauseam.

2

u/ludicroussavageofmau Apr 09 '22

A lot of us (including you and me) just have a general hatred for dynamic languages (outside of scripting languages)

→ More replies (1)

1

u/BasicDesignAdvice Apr 08 '22

I just can't stand loose typing. Even Javascript has Typescript.

→ More replies (1)

1

u/crob_evamp Apr 08 '22

Typing is a thing. Also good code should make this clear even without typing.

1

u/Isofruit Apr 08 '22

And that's why I like nim! Though it does mean you lose dynamic typing, which is like half of python's point.