News for hackers. Stuff that matters.
Re:Do Python developers want static typing? by bko on Saturday February 27, 2021 @06:28PM (#26289127)
> Doesn't it just require you to express the interface you're already using and expecting to use?

Depends on the type system. Some type systems have a lot of ceremony around types and force you into contrived abstractions. For instance, in Scala, if you wanted to have a function that can print a name of an animal or person, you could overload the function, create a "nameable" trait and have both Person and Animal implement it, or create a union type.

In typescript you could just write

sayHello(thing: {name: string}) { ... }

or a union type

sayHello(thing: Person | Animal)

or even Pick out a group of parameters of both Person and Animal

sayHello(thing: Pick<Person | Animal, "name">)

Same with Omit

Types in typescript are incredibly flexible and useful despite being discarded at compile time. I hope python goes down this route.

Re:Do Python developers want static typing? by EdwardDiego on Saturday February 27, 2021 @08:09PM (#26289744)
FWIW Scala can do structural typing like Typescript, but it has a slight performance impact due to using reflection so is generally avoided.

Compile time structural typing like approaches tend to use typeclasses and implicits. Bit more boilerplate, but no runtime hit or risk of failure if reflection access is denied by the JVM security manager.