this post was submitted on 06 Apr 2024
57 points (86.1% liked)

Programming Languages

1151 readers
2 users here now

Hello!

This is the current Lemmy equivalent of https://www.reddit.com/r/ProgrammingLanguages/.

The content and rules are the same here as they are over there. Taken directly from the /r/ProgrammingLanguages overview:

This community is dedicated to the theory, design and implementation of programming languages.

Be nice to each other. Flame wars and rants are not welcomed. Please also put some effort into your post.

This isn't the right place to ask questions such as "What language should I use for X", "what language should I learn", and "what's your favorite language". Such questions should be posted in /c/learn_programming or /c/programming.

This is the right place for posts like the following:

See /r/ProgrammingLanguages for specific examples

Related online communities

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 5 months ago (1 children)

I was already assuming I was working on the same codebase. I am not going to stash my work, checkout the branch and wait for the LSP to start up (if it's working) just to confirm that your types aren't doing anything weird. I'd rather just have them annotated correctly in the first place and just read the PR and trust the CI.

[–] [email protected] 3 points 5 months ago* (last edited 5 months ago) (1 children)

You don't need to restart your LSP to switch to a new branch. You also don't need an LSP to find the types.

Even with all of these issues aside, I can't think of the last time I was reviewing a PR where it wasn't clear from context what the types were, or they were irrelevant.

[–] [email protected] 1 points 5 months ago (1 children)

wth is your position then? If I can know the types from just looking at the code then it must have adequate type annotations and none of this matters. If I can't tell the types and I have to pull the code locally to figure it out then I'm not starting the review on a good foot.

I think people here are thinking about type inference in a very local scope and not at a public function level which I understood the author to be complaining about.

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

If I can know the types from just looking at the code then it must have adequate type annotations and none of this matters

That's not really true. It depends on the language. In Rust, it's common to read a function without any explicit types except for the arguments and return type. So you may not know what types are used in the body without referring to the signatures of functions called.

If I can’t tell the types and I have to pull the code locally to figure it out then I’m not starting the review on a good foot.

It's rare that knowing the types is critical to actually reviewing the code. Types are mostly for the compiler to help you. When reading the code, it's more important that you see idioms, descriptive names, and test cases. There are rare occasions where it's necessary to determine a type to resolve some ambiguity in how the code works, and in those cases, there are tools to help you do this (usually the same tools you use while writing code, e.g. LSP editor plugins and grep).

I think people here are thinking about type inference in a very local scope and not at a public function level which I understood the author to be complaining about.

In my very first comment, I said I can't comment on OCaml. I am only really speaking on Rust here, where you have local inference and mandatory function type signatures.