Live data from Hacker News

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

news.ycombinator.com

1–10 of 38 posts

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

#1
The reason I'm asking is that F# appeals a lot to me (more so than Scala, the language that seems the closest competitor) but I have not found success stories from companies running their C# or F# web apps on Mono/Linux.

As a separate but related question I would like to ask what tools you'd recommend for developing in F# on Linux or OS X.

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

#2
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 Nancy/Fanciful/WebAPI) teamed with javascript front-end. Also well worth checking out Livescript, syntax is very similar to F# but dynamically typed.

See also: A relevant blog article I posted: http://thecodedecanter.wordpress.com/2013/06/22/hosting-webs...

My consultancy (just in case): http://www.perfectshuffle.co.uk

Always up for a chat if you have some ideas :) Shoot me an email through website above or PM me.

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

#3
I'd be curious as to what exactly you mean by "success stories". If you mean something along the lines of "is it easy to develop, has a robust environment, and doesn't present any hard problems" then I think there's a lot of companies out there. If you mean something like "will it help your company produce something people want"? Then you're asking the wrong question. Tech very rarely determines product-market fit, at least not to the degree that we developers think it does.

I've been using F#/Mono for my small apps for some time now. For an example, my personal news aggregation site, http://newspaper23.com, is running all the time, going out and finding headlines and presenting them to me in plain text. Been meaning to add a text stripper to the mix so I don't have to see any ads or participate in any sticky website nonsense at all; just haven't had time to code it yet.

The nice thing for me, especially for this app, is that I can use F# in a purely functional manner to create little unix-like programs that do a little bit of work at a time. Then I string them together with chron and, instead of the old client-server web model, I have something more resembling a data pipeline. I can monitor flow across the pipeline, distribute parts of it to other machines (scale out) if necessary, and so on. All without having to re-code anything. The entire thing serves up a static web page, which can also be tweaked: served in-place, over a CDN, emailed to a user, etc. Did I mention the "no recoding" part?

As a former .NET guy, I'm happy enough with F#/mono that I can't imagine going back to full-bore .NET no matter what the problem domain. The toolset is way too heavy, the culture is awash in folks marketing to developers instead of helping them build stuff people want, and so on. It was a great ride, but F#/mono is where I get off.

Having said that, I still use the VS IDE to develop, since you can develop in windows and then FTP the code over. That's pretty cool. I've tried and used MonoDevelop. I guess it's okay. I've also done a bit with just straight-out command-line compiling. After all, it's not like you need a huge codebase full of hundreds of files. Or if you do, you're doing something wrong :) An 8 or 10-file F# program is a monster -- and probably means you're trying to do too much at once.

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

#5
Mark Seemann made a nice tutorial on Pluralsight, which shows how to build an F# web app.

The demo isn't using Mono, but I thought it's still relevant if you want to get a feel for what an F# web app might look like.

http://pluralsight.com/training/courses/TableOfContents?cour...

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

#6
One big thing to watch out for is GC differences. Now that Mono has sgen the gap between it and MS's CLR isn't so huge, but you will definitely want to do some memory and CPU profiling direct on the webserver to spot any issues.

In my case when rolling out the JSIL compiler (mostly C#, but using some F# applications as test cases etc) certain BCL containers had dramatically different GC pressure profiles, and GCs would trigger at different rates and with different costs. F# tends to generate a lot of GC pressure so you want to be proactive about this.

Side-by-side, though, sgen works pretty well. I've used it extensively and it does the job.

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

#7

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 folks who are maintaining FastCgi on Mono but the email I sent last week bounced. When you use evhttp though, (at least with C#) there's not a huge performance difference than when using it in Windows.

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

#8
At Tachyus (tachyus.com), we are using 100% F# to build the back end of our platform. Getting from zero to our first product deployment in three months, we've proven that F# is a great language for real world web projects -- especially when iteration speed and application correctness are both indispensable. Visual Studio and Windows Azure have actually been a huge part of the leverage we've gotten from choosing F#, as we can build, debug, deploy, and manage deployments directly from the IDE. With an Azure trial account created, you can literally get your first F# site up in minutes.

Unfortunately, I can't answer your question about Mono just yet. We are exploring the practicality of Mono (for mobile development in F#), and while I am optimistic, I can't speak to the reliability of the platform. So my answer (a complete cop-out) is to try out Visual Studio unless you are completely tethered to Linux/Mac.

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

#9

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…

Thanks, this is really useful!
Post reply on HN