News for hackers. Stuff that matters.
Re:An analysis of the C#/.NET platform by _random_ on Saturday November 02, 2013 @03:24PM (#6660356)
I really wish F# was as approachable as Scala is. Every time I consider it I see no strong selling point. Loosing ReSharper + a steep learning curve make it too much for me.
Re:An analysis of the C#/.NET platform by profquail on Saturday November 02, 2013 @04:36PM (#6660694)
If you know C# and you want to learn F#, consider reading Real-World Functional Programming: With Examples in C# and F# (http://www.amazon.com/Real-World-Functional-Programming-With...). It's been well-received by C# developers, IMO because it does a great job of explaining the purpose of certain F# features, and how they can be used to simplify some common C# coding patterns.

There's also the excellent F# for Fun and Profit website, which has lots of good F# tutorials: http://fsharpforfunandprofit.com/

As an active contributor to the F# open-source community, I can tell you that there is a lot of effort -- both from Microsoft and the wider community of developers -- to build out the F# ecosystem of tools and libraries. For example, Deedle (https://github.com/BlueMountainCapital/Deedle), a data frame library for F# and C# was released a few days ago; this gives you the kind of data-manipulation functionality as you'd get with Pandas or R. JetBrains even started an open-source project to bring F# support to ReSharper: https://github.com/jetbrains/fsharper

Re:An analysis of the C#/.NET platform by _random_ on Saturday November 02, 2013 @05:22PM (#6660858)
I hate to be a negative guy. I have actually read some chapters of that book - thanks for links, I do appreciate. Maybe the problem is that my job is DB + GUI + simple business logic type of projects. Which is probably similar to most other jobs these days. I would love to work for Blue Mountain Capital but I don't. I am the only one in the team who thinks F# could be useful and had to defend using Maybe monad in C#! The only strong use case I have found so far for F# is building DSLs. Even then I would personally prefer an external DSL built with ANTLR or other proper language work-bench.

PS: that F# ReSharper project is actually dead, last update was months ago. I don't understand why Microsoft won't pay JetBrains to add support. I don't understand why Microsoft won't make a Roslyn for F#. No, instead poor F# team guys have to talk to community to build some basic OOS IDE.

Re:An analysis of the C#/.NET platform by profquail on Saturday November 02, 2013 @06:11PM (#6661050)
Do you use WPF for your GUI programming? GUI isn't one of F#'s strengths -- it doesn't have all of the fancy codegen tools C# does -- but Dmitry Morozov has built some excellent tools for working with WPF in F#: https://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series/wi...

Database-oriented programming in F# is pretty good from F# 3.0 onwards, thanks to a few minor language improvements and the major addition of Type Providers. F# 3.0 ships with a type provider which interops with the standard classes in System.Data.SqlClient and another which interops with Entity Framework. See: http://msdn.microsoft.com/en-us/library/vstudio/hh361035.asp...

Dmitry (whose WPF framework I mentioned) has also written another type provider which provides strongly-typed access to all kinds of stuff (e.g., stored procedures) if you happen to use SQL Server as your database: https://github.com/dmitry-a-morozov/FSharp.Data.SqlCommandTy...

C# and it's related tools are very solid and have much momentum and marketing muscle behind them, so it's understandable that some developers (e.g., your co-workers) might feel uncomfortable learning something new. I've found the best way to convince people is to start writing little bits and pieces of your work, like small tools or minor libraries, in F#; when it turns out they have few, if any, bugs that usually does a good job of convincing people F# is worth taking another look at.

Re:An analysis of the C#/.NET platform by MichaelGG on Saturday November 02, 2013 @06:17PM (#6661072)
On the contrary: Even for these boring apps, using F# means you'll have a lot less code. C# only really wins if you're using the GUI designers.

I converted a C# application to F# manually, preserving the C# style. I needed 1/20th the number of type annotations. I've done ASP.NET MVC apps using F# and find it far lighter-weight to write controllers.

And the neat thing is that while using F#, even as a lightweight C#, you'll start using better abstractions because they're so easy.

If you can, write some projects in F#. I've found the best way to convert people is just to enjoy how little code's required to get things done, which makes them jealous and they'll switch.

Re:An analysis of the C#/.NET platform by nbevans on Saturday November 02, 2013 @04:05PM (#6660534)
What makes you think F# is unapproachable? Is it because Scala still uses braces whereas F# uses whitespace?

It's odd because Scala and F# are very similar in what they bring to the table.

Losing ReSharper is an arse yes. I've heard that F# vNext will have lots of VS improvements which may also cover some common refactorings.

Re:An analysis of the C#/.NET platform by _random_ on Saturday November 02, 2013 @04:29PM (#6660648)
I actually like how meaningful white-space forces formatting. I want more inference in C#. What I don't like is that language "feels" too "big" for me to approach. Things like "The DefaultValue attribute is required on explicit fields in class types that have a primary constructor" make me think WTF, why use OCaml with "patches" instead of starting from scratch? Don't get me wrong, I will learn F# the day it will be paid properly by the market (London). But today it doesn't give me enough to abandon C#. PS: Microsoft says F# is not meant to replace C# and I don't do scientific calculations or big data.
Re:An analysis of the C#/.NET platform by profquail on Saturday November 02, 2013 @04:49PM (#6660745)
What's your definition of "paid properly" by the market?

Average C# developer salary in the UK, £40,000: http://www.itjobswatch.co.uk/jobs/uk/csharp.do

Average F# developer salary in the UK, £62,500: http://www.itjobswatch.co.uk/jobs/uk/fsharp.do

Re:An analysis of the C#/.NET platform by MichaelGG on Saturday November 02, 2013 @05:28PM (#6660889)
I'd be surprised if F#, all-in-all, has more complexity than C#. For instance, C# has crazy duck-typing rules, but they only apply when using certain keywords (like new Whatever{} or foreach). Or all of C#'s type-coercion stuff, like C. Floats, integers, even strings - let's implicitly convert them galore!

F# has a fairly coherent model, which makes most of the design principles deducible. For instance, that quote about DefaultValue. You're using a keyword to introduce a field without initialization. Since F# avoids uninitialized fields, so you don't end up with nulls, it forces you to be explicit here, noting that you're requesting the compiler to allow an uninitialized field, which is not something you often want.

Microsoft's marketing is shit as far as F# goes. They've invested a lot in C#, and it's embarrassing for some people to admit that MSR came up with a far superior language. So instead they mumble about how F# is great... if you're like a rocket scientist or quant or like, really super-duper smart. The implication being that C#/VB are the only practical languages for normal get-stuff-done programmers. In truth, the only real advantage C# has is the tooling. There are drag-n-drop designers, and codegen tools that F# doesn't have. Some libraries make implicit assumptions about C# compiler implementation details. But that's hardly a language problem, and something MS could fix if they cared to put resources on it.

As a side note, the F# team has some of the same people responsible for actually designing and getting proper generics into the CLR. Without that team, the CLR wouldn't have proper generics, but probably eventually would have gotten a lame model like Java's.

Re:An analysis of the C#/.NET platform by balakk on Sunday November 03, 2013 @12:28AM (#6662229)
The biggest problem F# faces(or faced) is it looks very foreign to a journeyman c#/java/c++ developer. Significant whitespace and lack of curly braces does not look quite odd now, with the proliferation of Python, Ruby etc. Prior to 2005 or thereabouts, it was a huge challenge.

Part of it is a community problem as well - the leading lights of the Alt .NET community pretty much cold-shouldered F#. Don Syme & team waged a lonely battle to bring mindshare. Till f# 2.0 shipped, I can't remember more than 2 or 3 significant developers who were actively developing F#. Things are looking up now though.

Re:An analysis of the C#/.NET platform by _random_ on Saturday November 02, 2013 @05:04PM (#6660797)
@profquail: First of all those links are meaningless given the scarcity of F# positions. You just can't compare them statistically. Second of all if you look closely at actual positions then it turns out they are not F#-centric at all, more like "Scala, F#, Erlang, Haskell knowledge is a plus". I mean people who use F# were hired not because they knew F# well but for other skills - e.g. deep knowledge of finance, distributed computing etc. Why not focus on learning that instead? Nobody pays 100k for F# alone. I might be wrong but I just don't see it as a skill that sets you apart that much. People are more interested in HTML5 :(.
Re:An analysis of the C#/.NET platform by profquail on Saturday November 02, 2013 @06:30PM (#6661126)
With languages like C#, Java, Python, C++, etc., job postings often ask for experience with that specific language. Sometimes you'll see postings which allow developers to jump back and forth between C# and Java, but that's about it.

With functional languages, the specific language is much less important, because the languages share many features, and the real key is that you understand how to design and structure functional programs. Along with the fact that functional languages -- even the popular ones -- have much smaller developer bases than your mainstream imperative languages, many job postings for functional programmers list multiple languages just as you described.

And you're right, no one's going to pay you 100k just for knowing F#. That's true for any language at any salary point though. What companies are looking for are those other skills; F# developers generally command higher salaries because they're often highly skilled senior developers, not because of their language preferences.

Re:An analysis of the C#/.NET platform by tonyedgecombe on Sunday November 03, 2013 @02:23AM (#6662490)
F# developers generally command higher salaries because they're often working in the financial sector.
Re:An analysis of the C#/.NET platform by profquail on Sunday November 03, 2013 @12:50PM (#6664166)
Many F# developers work in the financial sector (myself included). Working in the financial sector isn't some magic ticket to a higher salary though, i.e., given an engineer who makes $X in some other industry, they're not automatically going to make 2 * $X just because they switch to finance. The reason salaries are higher in finance is because it's really worth the investment for financial companies to spend extra money to hire the most highly-skilled engineers (and other staff) they can find. Some other industries (e.g., aerospace) have similar requirements, so salaries are higher than normal there as well.