News for hackers. Stuff that matters.
Re:Var and val in Java? by x0x0 on Saturday March 26, 2016 @03:20PM (#11367018)
Are you seriously arguing we should optimize the java language for people who aren't familiar with the language?
Re:Var and val in Java? by gravypod on Saturday March 26, 2016 @03:25PM (#11367034)
I'm saying that a language should be easy to understand by anyone.

Hell, I'd have a hard time debugging new code if I saw var x, y, z;

Var means nothing! It has no implicit meaning. It just means whoever wrote the code was too lazy to write out the type names.

If you agree with that or not, just know that the few seconds it would have taken you to type out a full type name will probably save someone debugging your code in the future hours and make it infinity easier for someone who comes along and needs to start working on your code base.

Re:Var and val in Java? by deanCommie on Saturday March 26, 2016 @03:33PM (#11367065)
Well, lucky for you "var x, y, z" is never going to happen in a statically typed language.

dynamic, on the other hand....<looks shiftily into C#'s direction>

J/K. I Love dynamics.

Re:Var and val in Java? by masklinn on Saturday March 26, 2016 @03:59PM (#11367186)
> Well, lucky for you "var x, y, z" is never going to happen in a statically typed language.

Why not?

    let (a, b, c);
is perfectly valid Rust, it just declares 3 locals a, b and c.
Re:Var and val in Java? by gravypod on Saturday March 26, 2016 @04:13PM (#11367250)
What type are they?
Re:Var and val in Java? by heinrich5991 on Saturday March 26, 2016 @04:20PM (#11367285)
Depends on what you assign to these variables.

    fn main() {
        let (a, b, c);
        a = true;
        b = [1];
        c = "foobar";
    }
https://play.rust-lang.org/?gist=ebedd0cd5b6707410aff&versio...
Re:Var and val in Java? by gravypod on Saturday March 26, 2016 @05:32PM (#11367551)
That's my problem. YOU can't tell. You cannot just look and see what is going on.
Re:Var and val in Java? by masklinn on Saturday March 26, 2016 @06:11PM (#11367689)
Sure you can, it's pretty clear that a is a boolean, b is an array on the stack and c is a string. If the code is so complex you can't eyeball a local scope you probably have bigger problems than whatever the type of the variables are, and if you get one wrong the compiler will yell at you.
Re:Var and val in Java? by masklinn on Saturday March 26, 2016 @04:33PM (#11367330)
Whatever type the compiler infers based on the assignments you make afterwards (and a compilation error if there isn't any/enough information to infer the type).
Re:Var and val in Java? by pohl on Sunday March 27, 2016 @03:28PM (#11371140)
One wonders how these people were able to learn Java in the first place.