News for hackers. Stuff that matters.
Re:Writing Python Like Rust by uv-depression on Thursday June 29, 2023 @11:03AM (#36521363)
I don't think there are generally agreed upon definitions of strong vs. weak, but I think a useful definition is about changing the type _while referring to the same data_ as weakness. In your Python example there, I think we can say it's dynamically + strongly typed because you're assigning the name `a` to three different objects with different types, not changing the interpretation of any actual data in memory. C would be statically + weakly typed, because you can cast the same exact data to whatever type by using `void*`. Rust is static + strong, and I can't really think of a dynamic + weak language. Probably that would be a nightmare to work in.
Re:Writing Python Like Rust by tgv on Thursday June 29, 2023 @02:08PM (#36524387)
You're right, there are none. The link from the GP shows several.

> changing the type _while referring to the same data_ as weakness

Python performs arithmetic and comparison on ints mixed with floats. In other languages, you have to cast those first. It does array subscription on a string. You could even see an expression like 3 * "x" as a type change.

> I can't really think of a dynamic + weak language

It depends on what you call a type, I guess. Is [1, 2] a different type than ["a", "b"]? You can't tell in Python, because there is no type declaration. That makes comparison with polymorphism moot. You can think that the type of b in a + b must be "whatever a's plus operator accepts", but I wouldn't call one or two sanity checks before adding strong typing.

Re:Writing Python Like Rust by dunefox on Saturday July 01, 2023 @05:46AM (#36548410)
> I can't really think of a dynamic + weak language.

Javascript comes to mind. https://www.destroyallsoftware.com/talks/wat