News for hackers. Stuff that matters.
Re:Why Isn’t F# the King of .NET? by youdontknowtho on Monday September 19, 2016 @07:48AM (#12530580)
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.

Re:Why Isn’t F# the King of .NET? by pjmlp on Monday September 19, 2016 @07:49AM (#12530589)
> I haven't heard anyone against type inference.

I have seen C# style guides that forbid var.

Re:Why Isn’t F# the King of .NET? by pc86 on Monday September 19, 2016 @07:59AM (#12530642)
And 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"

Re:Why Isn’t F# the King of .NET? by nathanaldensr on Monday September 19, 2016 @08:03AM (#12530661)
This 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>>();
Re:Why Isn’t F# the King of .NET? by pc86 on Monday September 19, 2016 @08:22AM (#12530791)
Exactly 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.

Re:Why Isn’t F# the King of .NET? by jeswin on Monday September 19, 2016 @12:13PM (#12532506)
The 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.

Re:Why Isn’t F# the King of .NET? by pjmlp on Monday September 19, 2016 @08:26AM (#12530825)
That is one of the ways I usually use it, also auto in C++.
Re:Why Isn’t F# the King of .NET? by douche on Monday September 19, 2016 @07:59AM (#12530638)
I'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.
Re:Why Isn’t F# the King of .NET? by nathanaldensr on Monday September 19, 2016 @08:06AM (#12530673)
var 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! :)

Re:Why Isn’t F# the King of .NET? by masklinn on Monday September 19, 2016 @08:07AM (#12530680)
Isn't that exactly what GP is saying?
Re:Why Isn’t F# the King of .NET? by pc86 on Monday September 19, 2016 @08:00AM (#12530644)
Some people are just bad programmers.
Re:Why Isn’t F# the King of .NET? by Pica_soO on Monday September 19, 2016 @08:08AM (#12530685)
Ironically, being strictly against something looks like you know what you are doing. We should promote this guy, he prevents alot of bad things happening.
Re:Why Isn’t F# the King of .NET? by mhomde on Monday September 19, 2016 @08:08AM (#12530688)
I 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 :)
Re:Why Isn’t F# the King of .NET? by PJDK on Monday September 19, 2016 @08:43AM (#12530940)
It doesn't completely solve the problem, but if you set CS1998 to be a compile time error rather than a warning it will help. This means methods marked "async" must have at least one "await".
Re:Why Isn’t F# the King of .NET? by mhomde on Monday September 19, 2016 @09:33AM (#12531276)
thanks for the tip!
Re:Why Isn’t F# the King of .NET? by radicalbyte on Monday September 19, 2016 @01:16PM (#12532984)
It'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.

Re:Why Isn’t F# the King of .NET? by youdontknowtho on Wednesday September 21, 2016 @12:39PM (#12549828)
Whoa. That's...completely unnecessary. What the?