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

Rust

5949 readers
1 users here now

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

Wormhole

[email protected]

Credits

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

founded 1 year 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
[–] [email protected] 2 points 7 months ago (1 children)

then x is created in the scope in your snippet

Saying "x is defined somewhere in the entire program" isn't satisfactory to many users. Also, you didn't tell me what type x has. Can I do x + 5?

[–] [email protected] 1 points 7 months ago (1 children)
  1. That isn't what I said at all. Reread?
  2. Find references / go to definition / rename has absolutely nothing to do with types.
[–] [email protected] 1 points 7 months ago (2 children)

Find references / go to definition / rename has absolutely nothing to do with types.

It absolutely does. Without static types an IDE/LSP can't reliably find all the references / definition and therefore can't refactor reliably either.

Consider something like this:

class Foo:
  bar: int

class Baz:
  bar: str

def a(f: Foo) -> int:
  return f.bar + 1

def b(f: Baz) -> str:
  return f.bar + "1"

Now imagine you want to rename Foo.bar or find all references to it. Impossible without the type annotations.

[–] [email protected] 1 points 7 months ago

Ah, I see. You're talking about object properties. I don't see any issue with finding references to variables, but for properties, yeah.