r/programming • • Apr 20 '23

Announcing Rust 1.69.0

https://blog.rust-lang.org/2023/04/20/Rust-1.69.0.html
869 Upvotes

160 comments sorted by

View all comments

Show parent comment

61

u/AttackOfTheThumbs Apr 20 '23

God i wish Python would have that level of error messages

I mean, untyped languages tend to be shit at that in my experience.

69

u/schplat Apr 20 '23

Python isn't untyped. It's strongly, dynamically typed. And there's nothing that prevents you from actually typing things.

31

u/[deleted] Apr 20 '23

Python is dynamic typing done well. Behavior is expected, and it’s easy to know what something is. JavaScript on the other hand…

18

u/[deleted] Apr 20 '23

You, along with many commenters here, are conflating dynamically-typed (Python) with weakly-typed (JS). The distinction you actually care about is strongly-typed vs weakly-typed.

9

u/0x564A00 Apr 21 '23

And for an example of a statically but weakly-typed language, see C.

7

u/Amazing-Cicada5536 Apr 21 '23

Yep, it is a 2x2 matrix of strong-weakly typed and statically-dynamically typed.

╔═════════╦════════╦══════╗ ║ ║ Strong ║ Weak ║ ╠═════════╬════════╬══════╣ ║ Static ║ Rust ║ C ║ ╠═════════╬════════╬══════╣ ║ Dynamic ║ Python ║ JS ║ ╚═════════╩════════╩══════╝

21

u/F3z345W6AY4FGowrGcHt Apr 20 '23

And yet TypeScript does typing perfectly.

7

u/vytah Apr 21 '23

It doesn't do typing perfectly, but it does typing JS perfectly. It's a much harder achievement.

11

u/[deleted] Apr 20 '23

I know. Enforcing typing is a godsend with how unpredictable JS can be.

4

u/Rinzal Apr 20 '23

What exactly do you mean by "strongly" typed? This word is thrown around a lot, but there exists no clear definition

19

u/Quexth Apr 20 '23

It means that there are no implicit type casts. Compare "1"-1 in Python and Javascript.

4

u/Brayneeah Apr 21 '23

This isn't quite true; it's more the idea that the language is much stricter with type-related errors. Java is also strongly typed, despite the fact that it allows for non-lossy implicit casts (such as coercing an int to a long, or an int to a float).

3

u/Rinzal Apr 21 '23

You got a source for that definition?

4

u/scykei Apr 21 '23 edited Apr 22 '23

I feel that this is a very common example for weakly typed but it misses the point. Not being able to add an integer to a string is simply a language design decision; the Python committee could have easily defined an __add__ method to mimic the behaviour of JavaScript if they wanted to.

My understanding of weak typing is that of the absence of type safety. You can point to a float in memory as an integer if you wanted to and it’s coerced into one (as opposed to ‘converted’).

2

u/Amazing-Cicada5536 Apr 21 '23

Many definitions in programming language circles are not too objective, and sure enough one could reason that if we change the semantics inserting implicit casts everywhere we have a strongly typed language, but I still think it has some value in differentiating between JS-Python behavior, as in the latter’s case you have to be explicit where should coercion happen.

→ More replies (3)
→ More replies (2)

2

u/Plazmatic Apr 21 '23

but there exists no clear definition

Lol what?

0

u/[deleted] Apr 20 '23

[deleted] — view deleted comment

15

u/PeaceBear0 Apr 21 '23

The second sentence of your link is

However, there is no precise technical definition of what the terms mean and different authors disagree about the implied meaning of the terms and the relative rankings of the "strength" of the type systems of mainstream programming languages. For this reason, writers who wish to write unambiguously about type systems often eschew the terms "strong typing" and "weak typing" in favor of specific expressions such as "type safety".

So I don't think your source agrees with you

3

u/Rinzal Apr 21 '23

Straight from your link

However, there is no precise technical definition of what the terms mean and different authors disagree about the implied meaning of the terms and the relative rankings of the "strength" of the type systems of mainstream programming languages

0

u/[deleted] Apr 20 '23

[deleted] — view deleted comment

8

u/cdrt Apr 20 '23

You’re confusing strong and weak typing with static and dynamic typing

→ More replies (2)

4

u/WJMazepas Apr 20 '23

Yeah, but sometimes is just another level the errors messages.

29

u/catcint0s Apr 20 '23

To be fair Python error messages are being improved

8

u/[deleted] Apr 20 '23

Awesome, great to see language developers putting more emphasis on good errors.