Live data from Hacker News

Ask HN: How viable is F# on Mono for real-life web apps?

news.ycombinator.com

11–20 of 38 posts

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#11
Mono's compatibility is quite good across the board, but there aren't a ton of contributors focused on backend stuff. There are gaps in Mono's library stack that are problematic for web applications (e.g. no System.Net.WebSockets last time I checked) but it's not really all that bad.

Microsoft has started making a lot more of the ASP.NET stack open source (EntityFramework, Razor, etc), which I think will help a lot going forward. The real problem is that the ASP.NET happy path is somewhat coupled with IIS and (to a lesser extent) with MS SQL Server. It can be hard to get portability out of the box in some cases, but it depends a lot on what you are trying to do.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#13

It's viable. Mono is very good these days. It's pretty rare that you find .NET libraries that are incompatible. I still use Visual Studio as an IDE but deploying to Linux is straightforward. Your options are (realistically): Websharper - full web stack, transparent RPC. Hard to interop with native JS libraries like angular though. Funscript - F# to JS compiler, more minimalist approach. F# server side (REST api in Na…

If you're using Mono for web hosting then don't use Mono's FastCGI implementation. It's incredibly slow from what I've seen. Instead, use something like evhttp-sharp which has a wrapper for Nancy. Just to give you an idea look at nancy using evhttp ("nancy-libevent2" in the benchmark) vs FastCgi ("nancy" in the benchmark) at http://www.techempower.com/benchmarks/#section=data-r8&hw=i7... I've tried to contact the fol…

Awesome, I wasn't aware of evhttp-sharp. On first glance it seems not to provide any Owin middleware compatibility, but it should be easy to do a small server factory that plays with Microsoft.Owin.Hosting and get that out of the box. I've also found https://github.com/Bobris/Nowin a while ago - very fast on Windows, but I can't get it to work on Mono 3.4 on linux, locks on the first request.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#14
I played with Xamarin Studio + F# + OS X about a year or two ago. Right away I noticed that F# is a second class citizen in Xamarin. Weird bugs, weird warnings, unfinished parts, hard to find help online and in IRC channel. And since it's a smaller language, there are 1/100th the number of tutorials/resources at much lower quality. Anyone who wanted to run my app on Linux or Mac had to deal with Mono 2 vs Mono 3. Despite spending a lot of time, I never figured out how to compile a windows binary on Mac or a Mac binary on Visual Studio (or how to have a project folder that works both in Xamarin and Visual studio without both git problems and linking problems). Starting a C# project is a pleasant experience, starting a F# required searching for add-ons and manual configuring (both in Xam and VS). I couldn't even run the iOS sample app without paying hundreds of dollars for the full version because the iOS libraries made the binary (of the one page sample app) to big for the trial version. Response in IRC was "yeah, we know. Oh well".

A real shame. I'd love to dedicate myself to an open source functional language with a GUI toolkit that runs all platforms, desktop and mobile.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#15
post #12

are there features that F# has that scala is missing (aside from reified generics)? Because there are at least a few critical features scala has that F# is missing that influenced my decision on preferred language.

The type inference is much better in F#, the syntax is much terser, discriminated unions are much cleaner than case classes.

Also .NET/Mono benefit from a VM with much better performance characteristics (tail calls, value types).

Scala has its own set of benefits too (incredibly powerful type system, Scalaz, bigger community).

F# is primarily a functional language with some OOP bits tacked on. Scala is the opposite.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#16

I played with Xamarin Studio + F# + OS X about a year or two ago. Right away I noticed that F# is a second class citizen in Xamarin. Weird bugs, weird warnings, unfinished parts, hard to find help online and in IRC channel. And since it's a smaller language, there are 1/100th the number of tutorials/resources at much lower quality. Anyone who wanted to run my app on Linux or Mac had to deal with Mono 2 vs Mono 3. Des…

I think unfortunately this is true. But it's a chicken and egg problem. F# won't get more attention unless more people use it.

JVM developers seem to be much more open-minded than .NET developers for whatever reason. As someone who thinks F# is a much nicer language than Scala (the best JVM statically-typed, functional language) it's quite frustrating.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#17
post #12

are there features that F# has that scala is missing (aside from reified generics)? Because there are at least a few critical features scala has that F# is missing that influenced my decision on preferred language.

The type inference is much better in F#, the syntax is much terser, discriminated unions are much cleaner than case classes. Also .NET/Mono benefit from a VM with much better performance characteristics (tail calls, value types). Scala has its own set of benefits too (incredibly powerful type system, Scalaz, bigger community). F# is primarily a functional language with some OOP bits tacked on. Scala is the opposite.

> Scala has its own set of benefits too (incredibly powerful type system, Scalaz, bigger community).

What's the general consensus on scalaz nowadays? Some people seem to think that it is evil itself (or rather the style that it promotes). I'm an outsider so I wouldn't know.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#18
post #13

Earlier quoted context omitted.

If you're using Mono for web hosting then don't use Mono's FastCGI implementation. It's incredibly slow from what I've seen. Instead, use something like evhttp-sharp which has a wrapper for Nancy. Just to give you an idea look at nancy using evhttp ("nancy-libevent2" in the benchmark) vs FastCgi ("nancy" in the benchmark) at http://www.techempower.com/benchmarks/#section=data-r8&hw=i7... I've tried to contact the fol…

Awesome, I wasn't aware of evhttp-sharp. On first glance it seems not to provide any Owin middleware compatibility, but it should be easy to do a small server factory that plays with Microsoft.Owin.Hosting and get that out of the box. I've also found https://github.com/Bobris/Nowin a while ago - very fast on Windows, but I can't get it to work on Mono 3.4 on linux, locks on the first request.

If you do make it OWIN compatible or a FastCGI wrapper for libevent that would be awesome. Right now, you need to basically have nginx proxy all the requests to evhttp which probably adds a little bit of overhead over doing it through FastCGI directly.

Edit: Actually from what I've seen, Mono uses epoll/kqueue for async IO which is what libevent uses as well. I think the problem might not be so much that libevent is faster than what Mono can do in plain C# but rather that the FastCGI implementation has some bottlenecks or is not using the most performant APIs available. I haven't had time to profile it though.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#19
TL;DR version: Felix is a very F#'ish language that might pique your interest. Felix is to C++ what F# is to C#

Full disclosure, this has been said of me recently: > AFAICT you mention Felix whenever OCaml comes up, generally saying more or less the exact same thing each time

So you might know about Felix already, if not read on. I dont want to sound repetitive if it is not welcome please let me know if I am overdoing this, so far the reception has been warm in other threads. [Said too soon I guess, downvotes are ok, would appreciate if they come with some feedback as well]

Let me point you towards my comment https://news.ycombinator.com/item?id=7416692 that has more details

Felix's website is running on the web server that comes with its standard library. It is well suited for webapps because of its strong support for efficient asynchronous I/O, futures and coroutines (which I believe has been maintained for 10+ years and used in ATM networking applications). These help in avoiding callback heavy code. Hooks into JS is currently missing, but if you are adventurous, interfacing it with V8 should not be difficult because interfacing with C++ has been Felix's design goal from the very beginning (analogous to how F# and C# are related). In fact if you express enough interest, the language designer, John Skaller, might be up for it himself (You can catch him on LTU or the Felix mailing list). As of now it has two backends, GCC and Clang. John has some interest in a Javascript backend as well in case there is sufficient demand for it. If F# is something that interests you, and the performance of F# on the mono runtime worries you a bit, Felix might be worth poking around, especially if you are an early adopter.

Re: Ask HN: How viable is F# on Mono for real-life web apps?

#20
We have a product that has a C# web app deployed via mono on a linux box commercially shipping for four years. What I found was that with mono 2.10.6 it was fine as long as it was not loaded heavily, but under stress it would have stability issues. The socket layer was rewritten since then however and I've had less issues with 2.10.8/9 but still fails under heavy load. More fixes have gone into mono 3. My sense is that it's getting better but not nearly as battle tested compared to JVM-based network stacks. So if I was coding a large scale web service I'd consider Scala first.
Post reply on HN