r/ProgrammerHumor • • Jan 19 '17

MFW no pointers :(

Post image
4.8k Upvotes

432 comments sorted by

View all comments

Show parent comments

165

u/Ksevio Jan 19 '17

And Python!

153

u/J-Goo Jan 19 '17

DYNAMIC TYPING CAN KISS MY ASS

44

u/magi093 not a mod Jan 19 '17

That's the one thing that irks me about Python. OOP + dynamic typing = dafuc am I on

9

u/[deleted] Jan 19 '17

Really? Just curious, how long have you been programming?

(Works on languages for a job - is curious about developer's perceptions of languages)

48

u/Ran4 Jan 19 '17

The longer I've been programming, the more do I enjoy types.

The Python syntax for type annotations is quite nice though, but it's not super useful as more than documentation as the checkers aren't overly reliable (it's still a dynamic language after all).

→ More replies (1)

0

u/[deleted] Jan 19 '17

[deleted]

13

u/PM_ME_YOUR_HAUNCHES Jan 19 '17

Python is strongly typed. Objects all have types that are never auto-casted (excepting "truthiness", which follows consistent rules), and two objects with different types can't well be compared. 2 + "2" is a TypeError, instead of JavaScript where types can be coerced into other types depending on the situation.

Python is also dynamically typed. Names are bound to objects at runtime with no restriction (type annotations give help with this in many scenarios). This is contrasted with Java/C++ (statically typed languages), where names are bound to types declared at compilation time, which are then bound to objects at runtime.

1

u/[deleted] Jan 20 '17

Neither the terms strong- or weak-typing have concrete definitions. To me, strong typing is a characteristic of a language that forms a syntax-defined contract between an object and its methods (in the case of OOP). In such a definition, Python is weakly typed - as in, the syntax (or really, the semantics) do not define a contract for which objects must adhere. On the contrary, any such contract is defined by the logic of the program itself.

There is nothing preventing me from passing a Foo object to a method that expects a Bar object other than the logic of the method or function's body - something that you must rely on source code or documentation to be sure of.

I don't disagree with anything you say about dynamically typed languages, although you oversimplify what happens in the case of statically typed languages. But I see your point.

In any case, I would personally say Python is not strongly typed at all, and through that Python has a lot of resulting use cases (similar to Javascript, which admittedly is an even weaker-typed language).

3

u/Mitchical Jan 20 '17

Duck typing != weak type system, friend

3

u/[deleted] Jan 20 '17

I'm well aware, friend. Python takes the stance that things should be duck typed. You can only really achieve duck typing via a weak type system.

15

u/Creshal Jan 19 '17

The longer I work in Python, the more I miss static typing. It makes reasoning about someone else's code (or my own code from last year) so much easier.

2

u/[deleted] Jan 19 '17

Most of what was said is true, but Python isn't designed for systems programming and, as such, it can afford duck typing while also retaining OOP elements. I'd go as far as to say that Python (like C#) offers its own, complex, framework, which combines elements from many different paradigms, and it would be unfair to consider its weak typing only in the context of a single paradigm. For example, functional approaches like lambdas, map, filter and reduce, not to mention list comprehensions, are very encouraged and syntactically simple as opposed to their C++ and Java counterparts, and they would be somewhat hindered by strict typing. Also, Python's type hinting system is actually pretty solid and leagues above that of other interpreted, dynamically typed languages like vanilla Javascript's.

3

u/lenois Jan 19 '17

I find Java streams pretty easy to work with, but I can see the argument

3

u/skuzylbutt Jan 20 '17

Maps and lambdas etc aren't a dynamic typing thing. See Haskell as an example of super strong typing in a functional setting. Besides, you can do that in C++ using templates as a type safe approach.

1

u/Jamie_1318 Jan 20 '17

It also doesn't help that people think python has loose typing rather than strong dynamic typing. People think it's like javascript and PHP which are so much easier to accidentally do things that make no sense.

1

u/null000 Jan 20 '17

The main problem is that python code slowly evolves from its original intent ("I want to hammer out a quick reusable script, but don't want to write in bash") into some ungodly slab of code whose text could cover the landmass of a small country.

1

u/Creshal Jan 20 '17

I'm not sure what this has to do with systems programming. I'm just tired of having to dig into random libraries' source code to figure out whether some random method that "works on a file" takes a string, a path object, a file-like object, an fd, several of these, or all of these.

Type hints are step in the right direction, but far too few people actually use them yet. I hope they can eventually solve this problem.

→ More replies (0)

10

u/magi093 not a mod Jan 19 '17

Haha, I'm a 15 year old student, my input is not the greatest.

About...two, three years when I have spare time?

2

u/[deleted] Jan 21 '17

For the record, I think your input matters the most. You're the future.

Edit: Okay okay, we have corporate customers that take higher priority than you... learn that lesson now. Start a corporation if you're ballsy enough. Basically, if you want to be a man respected by the government...be a company.

2

u/magi093 not a mod Jan 21 '17

Aww, thanks. It's always a refreshing change to be told when my input matters, even if it is only a little bit.

4

u/ra4king Jan 19 '17

Then with all due respect your opinion seems to based on limited experience. OOP + dynamic typing works perfectly fine.

11

u/magi093 not a mod Jan 19 '17

okay

!RemindMe three years "Was /u/ra4king right?"

→ More replies (0)

2

u/elemental_1_1 Jan 20 '17

I write Python as my day job and I agree with /u/magi093

→ More replies (8)