Hacker News new | ask | show | jobs
by Parazitull 2465 days ago
If you're interested in .net and the clr, you could replace c# with f#.

It's the most practical functional language that I've tried. Great for domain modeling and it can used in C# projects.

I also think that c# is too verbose so what I normally do: asp.net core mvc for routing, templating, authentication / authorization, data access etc and then reference an f# project that contains the domain logic. The best of both worlds.

1 comments

As a complete newbie to .net, I’ve tinkered around with f# for a web app and quickly got frustrated. I like the sound of your approach. Do you have any links / resources for the best way to get started with your approach?
Don't try to start with a web app. I'd recommend looking into Fable (the F# to js compiler). Write f# and run it in the browser, I found it to be a better and faster feedback loop when compared to a .net project.

Play around with the f# language (don't touch the js inter-op) until you can figure out if you actually like f#. Take it slow, it's not just a new language, it's a different paradigm. If you get frustrated, take a break for a few days, watch some f# videos and let the knowledge settle. You'll eventually start having evrika moments.

Look into other functional languages. Maybe you'll like others more. Accumulate knowledge and experience until you start thinking "I could do this a lot simpler in f# (or other lang)".

Then, if you want to use f# in a c# project you just need to learn how to reference a project in another project.

If you want some resources: https://fsharpforfunandprofit.com/video/ some of these videos can get you "hyped up" for functional languages

https://www.youtube.com/watch?v=4YO4XmtPFQw

https://www.youtube.com/watch?v=EPfpO_6uFAA

the entire https://fsharpforfunandprofit.com/ site is a good resource to learn everything from the basics to the wizard level stuff.

As an editor you can use Visual Studio but I'd recommend Visual Studio Code with the Ionide extension.

If your writing a web app I've heard good things about Giraffe (https://github.com/giraffe-fsharp/Giraffe). It seems to even have a project template via the "dotnet" command to get a quick web app running. With F# I personally find Rider or VsCode better IDE's than VS as well. The workflow in F# is more like my experience with scripting languages than something heavy like Java/C#; you don't lose much by going to a more lightweight IDE and a lot can be done via CLI commands and text editing in .NET Core.