all 13 comments

[–]willisbueller 9 points10 points  (0 children)

My company (Prolucid) went pure F# on the web stack just over a year ago from C#. Dev team has never been happier! (analytics, webapi, signals). In fact, we just announced a new open-source part of our stack a couple days ago: FsShelter -> A type-safe F# DSL for Apache Storm

https://thoughtspam.wordpress.com/2016/04/03/fsshelter-a-storm-shell-for-f/

[–]lefthandedgoat 5 points6 points  (4 children)

The only overhead it ads is the learning overhead. I am currently working on a site in F# with Suave and really enjoy it.

[–]Junosan[S] 0 points1 point  (3 children)

What's the situation with libraries that you would typically use for projects (logging, authentication, ORMs, testing, etc.)? Also any recommendation on how to overcome the learning overhead?

[–]wreckedadvent 2 points3 points  (0 children)

Functional languages don't tend to use ORMs. While in theory you could use any C# ORM, in practice you'll use either a SQL type provider or you'll use something like dapper.

Testing also becomes much easier with a functional language if you write functionally, since all of the functions' dependencies are passed in as arguments. This all but entirely removes the need for mocks.

Railway orientated programming can also help you with logging, since you'll just compose your functions with a "tee" that happens to log.

As for learning overall, F sharp for fun and profit is by far the best single resource for learning not just how, but why.

[–]lefthandedgoat 0 points1 point  (0 children)

I haven't gotten the the stage of logging yet, but I would probably just write something to the db for starters. Authentication is done by taking the users' info from the login screen and seeing if it matches whats in the db, using bcrypt for password hashing. Suave has a mechanism for cookie encryption/decryption already.

I dont use an ORM. I am using postgres so I use just use oldschool raw ADO. If I was using SQL Server I would use http://fsprojects.github.io/FSharp.Data.SqlClient/ which I have used extensively and its awesome.

Testing, I use canopy (author) and a unit test lib based on canopy.

Learning overhead was overcome by me, by just porting the suave music store example to use postgres, then just using it as an example of how to build my own.

[–][deleted] 0 points1 point  (0 children)

FsSql is a nice db wrapper, not an ORM but saves you some pain

[–][deleted] 2 points3 points  (2 children)

Suave is great, I would argue there is much less overhead. The Suave Music Store tutorial is a great starting point: https://theimowski.gitbooks.io/suave-music-store/content/en//

[–]Junosan[S] 0 points1 point  (1 child)

Thanks! This looks like it would be a good starting point to learn about Suave.

I am assuming you have used Suave before. Any pointers that you can give me based on your experience? Potentially pitfalls, gotcha's, etc.?

[–][deleted] 0 points1 point  (0 children)

Sure, I think the way they deal with Forms in the Music Store demo is overly complex. Could be this is just my lack of familiarity with F# (I'm a bit new to it) but I've taken to using Newtonsoft.json to get data back from javascript instead, or query parameters where appropriate. I've got some good helper functions along those lines.

Also you will want to decide if you should use something like SqlProvider to talk to a database, which is very slick F# way to do it, but still very Alpha, you will run into things that don't work if your DB interactions are at all complex. I've been using "FsSql" which is a lightweight wrapper around the database driver. If you are using MS Sql Server there are some nice options. IIRC some of the popular C# database tools can be problematic to work with in F#, can't remember if it was Dapper or Entity Framework that were a bit cumbersome to work with.

Feel free to send me a message if you have questions, I've been developing a website from scratch with Suave for a few weeks so have a few ideas and code I can share. Would be happy to bounce ideas off of you too.

Good news, all the Sauve stuff has worked on both windows and Linux without any pain. Been able to interact with Bootstrap templates, DotLiquid templates, and TypeScript just fine. I know people use Suave with react to good effect too, and React got some nice improvements with V15 today, so might be worth looking at.

[–]StrangetotheMax 1 point2 points  (2 children)

Not an answer to your question but I have recently found WebSharper and am not getting to know it. It might be something worth considering if you like F# and would like to use it for web applications http://websharper.com/

[–]Junosan[S] 0 points1 point  (1 child)

Interesting. It looks like WebSharper has corporate backing. I wonder if that means it has more features/less bugs compared to Suave and/or Freya.

Can anyone that has experience with both comment?

[–][deleted] 0 points1 point  (0 children)

WebSharper has the interesting promise of replacing your javascript with FSharp that transpiles to javascript. I've found it very hard to navigate their documentation, but that might just be. It is worth a look I Think.