Earlier quoted context omitted.
Come on, please don't be a jerk on HN.
I think this was misunderstood due to not being phrased right; I do not believe, let alone wish to insinuate, that torstenvl is a newbie who doesn't understand pointers. I mean, that doesn't even make sense. Though flagged, it was also upvoted to +2 at one point.
Pointers in C (2010)
111–113 of 113 posts
Re: Pointers in C (2010)
#112Earlier quoted context omitted.
> var is Java 10, though I believe it should not be used in production code, ever Is that your opinion of var in general, or something about Java's implementation of it? If the former, I'm really curious why, as a C# dev who's used it for many years.
Unless you are using a constructor to fill the var, it makes reading/exploring/understanding source code more difficult. If the value comes from a method, enjoy chasing it down in your VCS. In your IDE you only need to hover it, but it's still an unnecessary extra step. Sometimes I explore source code on GitHub, excessive use of var makes reading it very uncomfortable. Turning it around, what are the benefits of var?…
RE your sibling comment about dynamic: I primarily use it with json. It's useful for things like one-off error responses where you just need to grab a message or code to return/throw and there's really no benefit from introducing a class for that one usage. I did once work on a project where that was attempting to re-use some awful legacy code in a new app, and they leaned on dynamic a lot to make the legacy code work without to re-architect it correctly. It was about as terrible as you're imagining.
Re: Pointers in C (2010)
#113Earlier quoted context omitted.
I'm not a java dev, and I don't anything around introduction var into java. But I am a c# dev, and in the early days when var was introduced a lot of people avoided var because of misunderstanding of how it works. People thought it was dynamic rather than inferred, is it the same here?
Java does not have anything that can be used like C# dynamic. If you want to replicate it, you'd have to use several lines of reflection. See my reason for not using it above. As someone who holds no mastery over C#: Is it appropriate to ever use dynamic anywhere besides horrifying interop code?