5 ms·
They actually explicitly used to say...do your UI in VB or C# and your compute intensive work in F#. F# just wasn't their focus. They were productivity language
by youdontknowtho 10y ago
They actually explicitly used to say...do your UI in VB or C# and your compute intensive work in F#. F# just wasn't their focus. They were productivity language/tooling focused.
I haven't heard anyone against type inference. Not saying that it doesn't happen. Every place has it's weird "thing"...just haven't seen it personally.
I guess I'm saying that I don't think it was some kind of conspiracy or anything. I just think that there focus was/is elsewhere.
- pjmlp 10y ago> I haven't heard anyone against type inference. I have seen C# style guides that forbid var.
- douche 10y agoI've worked with people that couldn't be convinced that using var in C# was not the same as the old terrible untyped Variant type from VB.
- pc86 10y agoSome people are just bad programmers.
- nathanaldensr 10y agovar is not the same as Variant. var is merely a placeholder for the real type, which the compiler infers from the RHS expression type. Variant is closer to object than var. EDIT: It turns out the parent and I agree 100%. Darn double negatives! :)
- masklinn 10y agoIsn't that exactly what GP is saying?
- Pica_soO 10y agoIronically, being strictly against something looks like you know what you are doing. We should promote this guy, he prevents alot of bad things happening.
- pc86 10y agoAnd I've seen style guides that forbid var unless the type is clear e.g. var example = new CustomClass(); and style guides the require it unless the code will actually break. To quote the GP: > Not saying that it doesn't happen. Every place has its weird "thing"
- nathanaldensr 10y agoThis is how I've had my ReSharper code formatting rules set up for years. I only use var when the type name explicitly appears on the RHS of the equal sign (e.g., in an explicit cast, a generic type parameter, a constructor, etc.) var is an excellent way to reduce redundancy in an assignment expression; it helps avoid stuff like: Dictionary<int, List<CustomClass>> dictionary = new Dictionary<int, List<CustomClass>>();
- pc86 10y agoExactly how I use it (var) as well, only I haven't taken the time to tell ReSharper that's how I do it :) Basically if I know what the type is by looking at that line of code, I will use var. If I don't, I won't.
- pjmlp 10y agoThat is one of the ways I usually use it, also auto in C++.
- jeswin 10y agoThe more widely held view is that var should be used as much as possible, as you can see in Resharper defaults. You needn't care about the types, if the compiler handles it for you. Code like int sum = getSum() needn't break if the getSum() implementation switched to using longs. There will be exceptions, of course. People get by with dynamic types. Much better with structural types. You're having full nominal typing and using LHS declaration for documentation. Which if ever needed (typically you shouldn't), hovering over it gives you anyway.
- mhomde 10y agoI generally like var, however one thing I've found to bite me in the ass occasionally is using var for results returned from asynchronous operations... and then forgetting to use await on it :)
- radicalbyte 10y agoIt's because for interfaces you must declare the interface because the concrete type is inferred. So you get a cookie cutter ban. I personally start with min noise and add stuff (accessibility, explicit types, this, LINQ query syntax) based on the team. The only hard standard is braces: I like terse but too often you then get massive unreadable blocks.
- youdontknowtho 10y agoWhoa. That's...completely unnecessary. What the?