9 ms·
F# is a joy to use. After a certain time, many C# developers find themselves writing in a functional style. F# makes this the default, but lets you continue usi
by adgasf 7y ago
F# is a joy to use. After a certain time, many C# developers find themselves writing in a functional style. F# makes this the default, but lets you continue using all of your existing code.
Better yet, Linux and macOS support via .Net Core is excellent. F# on .Net Core is now a powerful alternative to Node.js.
- kemiller2002 7y agoThe thing I find most interesting about a lot of C# developers I've worked with, trained, etc. is their understanding of "Object Oriented" programming. I have the same discussion over and over again. "Have you looked at F# even to just to see how it works?" "I won't ever use it. I'm an OO programmer, and it suits me just fine!" "Do you use LINQ, and understand you can pass functions into methods etc.?" "Yeah, it makes things so much easier. I don't understand why people wouldn't use it." "That's really more like functional programming" "...." Edit:formatting
- bunderbunder 7y agoIt's almost to the point where the deciding factors in choosing between (C#-style) OOP and (F#-style) FP are: - Do you want your data types in one line or 20? - Pattern matching, or large concretions of if-statements? - Race conditions: Quality problem, or fun puzzle?
- mfatica 7y agoC# has most of the same pattern matching functionality at this point
- McWobbleston 7y agoThere's no compiler warning for incomplete matches, and without discriminated unions it's pretty verbose to write pattern-match friendly types C# has support for most F# features, they're just often awkward to use
- macca321 7y agoYou can get a pretty reasonable facsimile using some libraries I made: Discriminated unions: https://github.com/mcintyre321/OneOf https://github.com/mcintyre321/OneOf and One line value objects: https://github.com/mcintyre321/ValueOf https://github.com/mcintyre321/ValueOf
- McWobbleston 7y agoI'm constantly impressed by ways people manage to extend C# like this. I'll have to try this out :)
- coldacid 7y agoI haven't had a need for ValueOf yet, but OneOf has saved my ass now more times than I can count. Thank you so very much for it!
- seanmcdirmid 7y agoThere are C# programmers like that I suppose. There are also many C# programmers who buy into multi paradigmism, they fee no ideological conflict between using OO or FP as needed. C# supports FP well enough, and gets better every release (eg pattern matching). It’s difficult to compete with C#, especially when F# is feeding features into it.
- dvlsg 7y agoHopefully F# feeds the ability to have functions at the root of a module into C#. It's a small thing, but needing to put pure functions on static classes gets old after a while. I know local functions are a recent ish addition to C#. Hoping they keep going down that road.
- seanmcdirmid 7y agoC# has a set of design constraints that can be annoying, but they make the language consistent and extremely resilient. It isn't up to the whimsies of the designers either, Anders and company went one way with C# and a completely different way with TypeScript (given its need to fit in with Javascript). They can be annoying, I guess, but once you are used to it you don't really notice they are missing. It is annoying if you have to switch languages often, I'm pretty sure I would need a few weeks to get re-acclimated if I had to go back to C# from using TypeScript for so long.
- onemoresoop 7y agoNode has its place, i wouldn’t call F# an alternative to it. The node community is absolutely fantastic. F# is also an amazingly powerful language and im happy using it on the back end
- smt88 7y agoWhat is Node's place?
- RhodesianHunter 7y agoThe first stepping stone the front-end folks take into server side programming. :D
- sdegutis 7y agoWhat would you choose instead if you needed to write a simple web server?
- McWobbleston 7y agoF# with Giraffe is super simple to get up and running and it fits into the rest or the ASP.NET Core ecosystem
- smt88 7y agoSimple web servers are already written for me. If I'm serving static files, I'll just use a CLI tool or S3. If I'm making a simple API, I've already moved into territory where I'd prefer to use C# or something like that. The ecosystem is better and you can write it to avoid runtime gotchas. Big languages/stacks can still write tiny programs.
- sdegutis 7y agoConsidering we're in an F# thread, it makes sense that both alternatives to Node.js mentioned were part of the Microsoft stack (C# and F#). This furthers my conclusion that people just prefer the tools they're already familiar with, for better or worse.
- louthy 7y ago> After a certain time, many C# developers find themselves writing in a functional style If you can't move to F# or find its tooling abysmal and slow then I have a library [1] that makes the inertia flow positively in the functional direction in C# https://github.com/louthy/language-ext/ https://github.com/louthy/language-ext/
- winkelwagen 7y agoAfter learning f# I had to go back to c#. You library made it bearable. Also the reader.md and some of your more hidden articles are amazing. Thank you, and the other contributors so much, amazing work. My current strategy is to hook my colleges in with languag ext until they move to f# themselves.
- Dayshine 7y agoHah, the internet is such a small place. I thought that library looked familiar, and realised I was looking at it earlier today when I set up some F# job filters on stackoverflow (you're the only F# job on there that doesn't involve moving to London).
- Scramblejams 7y agoWould love to use F# with Unity, but the typical high allocation rates that come with the functional language territory scare me. Looked at your library, it's very interesting. I saw your docs note about the allocation efficiency of Map, would like to hear more. Could you characterize the library's general allocation story?
- louthy 7y agoI've done a short write-up about this: https://github.com/louthy/language-ext/wiki/Performance https://github.com/louthy/language-ext/wiki/Performance
- Scramblejams 7y agoTerrific info, thanks! Looking forward to using it.
- jeswin 7y agoC# for the most part does a decent job with Functional Programming, but it still leans very heavily towards statements instead of expressions. Even the newly introduced pattern patching (a common FP idiom) ended being a switch statement - perplexing decision because expressions are so central to good FP code. And if you were in imperative land, you didn't really need pattern matching so much in the first place; most developers will be fine writing if conditions. I hope they fix these warts. It can soon be a good alternative to Go for real native applications.
- svick 7y agoC# 8.0 will have a switch expression: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#switch-expressions https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csh....
- adgasf 7y agoAs C# gradually becomes F#, I have to wonder, why not just use F#?
- runevault 7y agoYou aren't wrong, but a lot of people are only comfortable in one language/style of language (so either just say Java/C#/c++ or maybe all Algol derived languages). Growing beyond that can be scary until you've done it a couple times if you wait until later in your career to start trying things like say Lisp or Haskell.
- louthy 7y agoAh, the same old refrain [1] [1] https://github.com/louthy/language-ext/wiki/%22Why-don't-you-just-use-F%23%3F%22 https://github.com/louthy/language-ext/wiki/%22Why-don't-you...
- dfgdghdf 7y agoNice article, thanks for sharing. I'm sure there are people out there debating F# vs C# for a new project, and might not realize how many future C# features are already in F# though.