←back to thread

498 points azhenley | 2 comments | | HN request time: 0.416s | source
Show context
hyperhello ◴[] No.45767863[source]
> I wish it was the default, and mutable was a keyword.

I wish the IDE would simply provide a small clue, visible but graphically unobtrusive, that it was mutated.

In fact, I end up wishing this about almost every language feature that passes my mind. For example, I don't need to choose whether I can or can't append to a list; just make it unappendable if you can prove I don't append. I don't care if it's a map, list, set, listOf, array, vector, arrayOf, Array.of(), etc unless it's going to get in my way because I have ten CPU cores and I'll optimize the loop when I need to.

replies(8): >>45768027 #>>45768166 #>>45768207 #>>45768240 #>>45768356 #>>45769342 #>>45769717 #>>45770340 #
throwaway2037 ◴[] No.45769717[source]
In my IntelliJ (a recent version), if I write a small Java function like this:

    private static void blah()
    {
        final int abc = 3;
        for (int def = 7; def < 20; ++def)
        {
            System.out.print(def);
        }
    }
The variable 'def' is underlined. Mouse-over hint shows: 'Reassigned local variable'. To be clear, 'abc' is not underlined. When I write Java, I try to use the smallest variable scopes possible with as much final (keyword) as possible. It helps me to write more maintainable code, that is easier to read.
replies(3): >>45771853 #>>45774068 #>>45774408 #
1. e-topy ◴[] No.45774408[source]
This works in RustRover as well! Super useful.
replies(1): >>45775348 #
2. sn9 ◴[] No.45775348[source]
Rust's type system specifically facilitates more powerful tools: https://github.com/willcrichton/flowistry