News for hackers. Stuff that matters.
Re:Python is two languages now, and that's great by jjoonathan on Monday February 27, 2023 @11:25AM (#34958282)
Duck Typing always struck me as utterly absurd wishful thinking. Two different types built for the same task will almost certainly not happen to be API compatible.

Am I missing something?

Re:Python is two languages now, and that's great by mandevil on Monday February 27, 2023 @11:33AM (#34958418)
I have bounced back and forth between typed and untyped languages in my two decades of employment history, and I prefer typed languages myself, even when I've been writing libraries nested deep in what I think the author would describe as the "infrastructure layer," but this is what I believe the original author of the linked piece is arguing.
Re:Python is two languages now, and that's great by moron4hire on Monday February 27, 2023 @11:40AM (#34958527)
* * *
Re:Python is two languages now, and that's great by hobs on Monday February 27, 2023 @11:27AM (#34958314)
No, in my experience you are trading off ease of coding for order of magnitude more production bugs.
Re:Python is two languages now, and that's great by mharig on Wednesday March 01, 2023 @07:09AM (#34981441)
So you do not write tests?
Re:Python is two languages now, and that's great by hobs on Tuesday March 07, 2023 @08:50AM (#35055273)
I absolutely do, and one of those effective tests is a simple type annotation.
Re:Python is two languages now, and that's great by jcranmer on Monday February 27, 2023 @12:16PM (#34959070)
There are cases where it can be useful. One thing that comes to mind is numerical code, where your algorithms are generic over things that have *,/,+,-,==,!=, conversion from 0 or 1 [or some subset thereof] do the "right thing". Trying to define proper interface types for what constitutes the "right thing" is somewhat tedious without much relative gain.
Re:Python is two languages now, and that's great by alanwreath on Monday February 27, 2023 @02:54PM (#34961054)
Its worked for us when dealing with local operations vs. cloud bucket operations. Protocols also help when you really don’t care to litter your code with some vendor specific object but instead just declare what functionality should be expected from the object passed in. It helps describe what you’re doing with it anyway, it’s why typing with Iterable can be helpful if you don’t care if it’s a list, set, or tuple.
Re:Python is two languages now, and that's great by martinflack on Tuesday February 28, 2023 @12:27AM (#34965973)
In sequences, even just too calls like "more?" and "next" will let you entertain all kinds of strict and lazy possibilities.