Live data from Hacker News

Get Started with F# as a C# developer

blogs.msdn.microsoft.com

51–60 of 60 posts

Re: Get Started with F# as a C# developer

#51
post #50
post #37

I need to know why to use F#, not how. C# is a business programming language. F# doesn't appear to be obviously useful in that regard.

I would argue that F# is a better business programming language for a lot of reasons. First, the type system is great when it comes to modeling the problem and communicating that model with non-technical project managers because writing good data models often means you write clear code that's idiosyncratic to the language. My experience is non-technical people understand clear data models and pipelines and those are…

>> the language has been streamlined to encourage a good OOP style by default. Design Patterns are simpler (Factory, Builder, Decorator, Adaptor, etc). Dependency Injection is very natural and implementing fluent APIs is a lot simpler.

Can you expand on this? I'm interested in how these things are easier in F# than in C#.

Re: Get Started with F# as a C# developer

#52

I'll take MS's commitment to F# seriously when they stop treating it like a 2nd class citizen. .NET Core 1.0 has been out for over a year, .NET Core 2.0 is in preview and there is ZERO support for F# with .NET Core in Visual Studio 2017. Yes you can use VSCode, but VSCode is no Visual Studio - it's a text editor on steroids, not a proper IDE that most C# developers have come to expect.

> I'll take MS's commitment to F# seriously when they stop treating it like a 2nd class citizen.

If you're waiting for Microsoft to give exactly equal resources to both C# and F#, you'll be waiting forever. Just like you'll be waiting for equal resources given to Visual Basic, TypeScript, PowerShell, VBA...

Equal splits never happen in a competitive situation. 60/40 splits are much more common, but here in this case, we have many first-party languages, so you'd expect a more complicated split, just as we see now.

> .NET Core 2.0 is in preview and there is ZERO support for F# with .NET Core in Visual Studio 2017

That's coming in the next update. (https://blogs.msdn.microsoft.com/visualstudio/2017/05/10/upd...) You've been able to run F# in .NET Core in preview form going back to the 1.1 series.

My opinion is that .NET Core is the real bag of hurt here, not F#. Stop sticking your hand in that blender. Use Mono and open source F# until .NET Core stops changing the world on each release.

> VSCode is no Visual Studio

And neither one is Vim.

Are we really going to have another editor war? :)

Re: Get Started with F# as a C# developer

#53
post #43

Earlier quoted context omitted.

F# the 'eco-system' feels like it's going backwards at the moment. As in physics, it's all relative. .NET has been moving so quickly lately that the F# team (from my outside-looking-in view) does not have the resources to keep up. You can see that by how stretched thin they are on GitHub issues. I'd imagine things will eventually stabilize once .NET Core settles in, but that'll be a few years. But you are right, the…

If you want to get things done in .NET Core, use C#. If you want to learn functional programming then sure, use F# and the full .NET Framework...but good luck finding help when you need it because compared to the number of people Elixir, Scala, etc - hardly anyone is using F#. I started learning F#, but ultimately I decided I'd rather learn either Scala or Elixir because they are more "mainstream" functional programm…

> If you want to get things done in .NET Core, use C#.

And if you want to get things done in F#, don't use .NET Core. :) Good thing .NET Core is merely the .NET du jour, not the only .NET.

> If anyone doubts this, compare the number of F# repos to Elixir/Scala on Github.

Challenge accepted. It turns out that GitHub's advanced search page can answer questions like this directly:

Projects written in F#: 4,246 (https://github.com/search?utf8=%E2%9C%93&q=language%3AF%23&t...)

Projects written in Elixir: 4,667 (https://github.com/search?utf8=%E2%9C%93&q=language%3AElixir...)

That's less than 10% higher. Plus, I'd guess there is a bias against closed-source projects in that result, owing to the nature of .NET.

Scala is indeed a lot higher at 38,424 projects, though I wonder how many of the complaints about F# from C# users apply apply equally to Scala. (e.g. Poor GUI builder support, no native compiler, etc.)

F#'s language representation on GitHub is also nearly equal to that of OCaml, a much older language.

I'd say that's a pretty good showing for a new-ish language. Not everything's going to pop to the top like Swift, which IMHO is a "people in Hell want ice water" reaction to Objectionable C.

Re: Get Started with F# as a C# developer

#54
post #53

Earlier quoted context omitted.

If you want to get things done in .NET Core, use C#. If you want to learn functional programming then sure, use F# and the full .NET Framework...but good luck finding help when you need it because compared to the number of people Elixir, Scala, etc - hardly anyone is using F#. I started learning F#, but ultimately I decided I'd rather learn either Scala or Elixir because they are more "mainstream" functional programm…

> If you want to get things done in .NET Core, use C#. And if you want to get things done in F#, don't use .NET Core. :) Good thing .NET Core is merely the .NET du jour, not the only .NET. > If anyone doubts this, compare the number of F# repos to Elixir/Scala on Github. Challenge accepted. It turns out that GitHub's advanced search page can answer questions like this directly: Projects written in F#: 4,246 ( https:/…

> And if you want to get things done in F#, don't use .NET Core. :)

Yep - stick with the version of .NET that MS is desperately trying to deprecate - remember recently when they tried to get away with not supporting ASP.NET Core 2.0 on the full framework?

> Good thing .NET Core is merely the .NET du jour, not the only .NET.

Yep, who would want to use the cross-platform, modern implementation of .NET?

> That's less than 10% higher.

Except that F# has been around twice as long as Elixir (2005 vs 2011.)

F# is the minor league team that C# farms features from. Nothing more in microsoft’s eyes.

Re: Get Started with F# as a C# developer

#55
post #48
post #38

Earlier quoted context omitted.

Giraffe is a fantastic little project that is a thin layer on top of ASP.NET Core. Works out of the box with the provided template, test locally, deploy to Azure, etc. https://github.com/dustinmoris/Giraffe

Thanks but I'm looking for something simple like returning plain text in 200 HTTP response using only built-in API. Completely minimal example. Using framework for me now would be like learning JavaScript by writing SPA in React.

FSSnip usually has those things. If you're talking that minimal I would just look up existing C# docs and translate them over to F#... ASP.NET Core is very lightweight w/ Kestrel though.

[1] http://fssnip.net/7OR/title/Simple-HTTP-Server [2] http://fssnip.net/search/http%20server

Re: Get Started with F# as a C# developer

#56

I'll take MS's commitment to F# seriously when they stop treating it like a 2nd class citizen. .NET Core 1.0 has been out for over a year, .NET Core 2.0 is in preview and there is ZERO support for F# with .NET Core in Visual Studio 2017. Yes you can use VSCode, but VSCode is no Visual Studio - it's a text editor on steroids, not a proper IDE that most C# developers have come to expect.

It will be a big screw-up if MS introduces such a fabulous language and then doesn't support it adequately, because now that I have seen the light, if their support becomes too scant I will drop .NET/core like a hot potato and will find some other comparable language in whatever other framework and environment I need to transition to.

Re: Get Started with F# as a C# developer

#57
post #5

Asynchronous programming with F# is pretty cool. It has layered powerful syntax and language constructs on top of .NET's threads and tasks, AND it gives you convenient access to the same async API that you use in C#.

I'm a C# dev and recently tried out F#. Async and async workflows/computation expressions were actually one of the things I struggled most with in F#. Can you suggest any good resources for learning more?

Re: Get Started with F# as a C# developer

#58
post #55
post #48

Earlier quoted context omitted.

Thanks but I'm looking for something simple like returning plain text in 200 HTTP response using only built-in API. Completely minimal example. Using framework for me now would be like learning JavaScript by writing SPA in React.

FSSnip usually has those things. If you're talking that minimal I would just look up existing C# docs and translate them over to F#... ASP.NET Core is very lightweight w/ Kestrel though. [1] http://fssnip.net/7OR/title/Simple-HTTP-Server [2] http://fssnip.net/search/http%20server

Wow, that's exactly what I wanted. Thank you very much! Fssnip looks great.

Re: Get Started with F# as a C# developer

#59
post #5

Asynchronous programming with F# is pretty cool. It has layered powerful syntax and language constructs on top of .NET's threads and tasks, AND it gives you convenient access to the same async API that you use in C#.

performance is not good though, if you are trying to use it to leverage multiple cores.

Is this because of GC? I just came across this statement on the Hopac site:

> Before you begin using Hopac, make sure that you have configured your F# interactive and your application to use server garbage collection. By default, .Net uses single-threaded workstation garbage collection, which makes it impossible for parallel programs to scale.

Re: Get Started with F# as a C# developer

#60
post #36
post #7

Ask HN: I've toyed around with F# and I kinda like it but I've never dug deep enough into it to answer the question: can I use this for 'real life' code as part of an existing C# desktop application for instance, e.g. build some F# into an assembly which is callable from C#? Without tons of hassle? What are good samples of real life application code in F#?

Beware that you won't be able to deploy the code to UWP though.

There is a way to develop for UWP with F# - MS' own React Native support + Fable. Write your app in F# using Fable React Native bindings, transpile to JS and deploy to UWP.
Post reply on HN