this post was submitted on 28 Mar 2024
242 points (94.2% liked)

Rust

7274 readers
3 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
 

Slide with text: “Rust teams at Google are as productive as ones using Go, and more than twice as productive as teams using C++.”

In small print it says the data is collected over 2022 and 2023.

you are viewing a single comment's thread
view the rest of the comments
[–] FizzyOrange@programming.dev 5 points 1 year ago (14 children)

Without static type annotations you can only make best effort guesses that are sometimes right. Better than nothing but not remotely the same as actual static types. The LSP you linked works best when you use static type annotations.

Also I would really recommend Pylance over that if you can - it's much better but is also closed source unfortunately.

[–] asdfasdfasdf@lemmy.world 2 points 1 year ago (13 children)

Why would it just be best effort? To find references for a specific thing, it still would parse an AST, find the current scope, see it's imported from some module, find other imports of the module, etc.

[–] Buttons@programming.dev 5 points 1 year ago* (last edited 1 year ago) (8 children)
if random() > 0.5:
    x = 2
else:
    x = "hello"

Where is the definition of x? What is the type of x? If you can't identify it, neither can the LSP.

This kind of thing actually happens when implementing interfaces, inheritance, etc. Thus, LSPs in dynamic languages are best effort both theoretically and in practice.

[–] Miaou@jlai.lu 1 points 1 year ago (1 children)

Tbf this example can be deducted as string | int just fine.

[–] SorteKanin@feddit.dk 1 points 1 year ago

The real problem is when you start using runtime reflection, like getattr(obj, "x")

load more comments (6 replies)
load more comments (10 replies)
load more comments (10 replies)