13 ms·
I really wish Mono would gain more traction. C# (3.0 onwards) is one of the nicest programming languages I have worked with (despite its warts). I also heard a
by lucianp 12y ago
I really wish Mono would gain more traction. C# (3.0 onwards) is one of the nicest programming languages I have worked with (despite its warts). I also heard a lot of good things about F#.
- edgyswingset 12y agoF# is a phenomenal language. Not that C# is bad (it's fantastic!), but the more I use F# the more I feel it's a superior language for most tasks. First-class .NET support is the real kicker, since you can do anything from DB interaction to writing MVC controllers. Integration with existing C# projects is seamless too, so it's really just a joy to work with.
- murphm8 12y agoCan you recommend any resources to learn about F#? I'm currently working on a big C# codebase and it would be interesting to see if F# would make some of it cleaner.
- edgyswingset 12y agoAbsolutely. One of the best starting places would be the Why Use F# series: http://fsharpforfunandprofit.com/series/why-use-fsharp.html http://fsharpforfunandprofit.com/series/why-use-fsharp.html It compares and contrasts C# and equivalent F# code for relatively simple, but common-in-the-real-world examples, while introducing some functional constructs. I'd also recommending reading the "Thinking Functionally" series. After that I'd recommend skimming some of the topics on the F# wikibook: http://en.wikibooks.org/wiki/F_Sharp_Programming http://en.wikibooks.org/wiki/F_Sharp_Programming And then I'd begin with rewriting some components in your existing project while continuing reading through that book and other online resources. Me and a coworker also rewrote ~600 line C# module into a working module in F#, along with some interop POC here: https://github.com/cartermp/CSharpToFSharp https://github.com/cartermp/CSharpToFSharp It's the product of a little over 20 hours of development across two people new to the language (and thus has some warts...), so take it as a grain of sand. Uses MS Unit Testing framework for F# (available via NuGet).
- deleted 12y ago[deleted]
- slambam 12y agoI've got a safaribooks online account, and found "Real World Functional Programming with examples in F# and C#" the most useful of the f# books I've read. The author has a blog, http://tomasp.net/ http://tomasp.net/ But I got something out of all of the books.
- pjmlp 12y agoThe book is available for free from Microsoft. http://msdn.microsoft.com/en-us/library/vstudio/hh314518%28v=vs.100%29.aspx http://msdn.microsoft.com/en-us/library/vstudio/hh314518%28v...
- MichaelGG 12y agoF# will almost definitively help any C# code. Even if you use F# as a "better C#" you'll see improvements. Just removing excessive type annotations is a nice step up in clarity. F#'s benefit will come as a bunch of tiny improvements, "programming in the small" as they call it. For instance: let xs = [ while r.Read() do yield r.GetInt 0 ] In C#, it's: var xs = new List<int>(); while (r.Read()) { xs.Add(r.GetInt(0)); } Or: let f x = let x = try int s with _ -> -1 x * 3 In C#, it's uglier. First because try... isn't an expression. Second, because you cannot shadow variables by rebinding them, so you always have to keep "old" vars around and in scope, and cannot reuse handy variable names: int f(string x) { int x1; try { x1 = int.Parse(s); } catch { x1 = -1; } return x1 * 3; } Or: let x = use db = new DB() db.GetX() In C#, you've got to declare x outside a block: SomeType x; using(var db = new DB()) { x = db.GetX() } Which is more annoying than it might seem. How much nicer is it to be able to create a new scope at any point in a function, and return a value out of it cleanly? These are by no means a complete or even important showcase of C#'s lacking. Just a few quick thoughts off the top of my head. In general, every time I'm writing C# code, I keep realising how things would be much more concise if I was in F#.
- CmonDev 12y agoF# is a nice language, but not a very necessary one (especially given the lack of tooling). 1) Simply write a quick extension method (not ideal but not a reason to switch languages): var xs = r.YourExtensionMethod<int>(rr => rr.GetInt(0)).ToList(); 2) Simply use the appropriate built-in method: int f(string x) { int number; /*Will be not necessary in C#6.*/ return Int32.TryParse(value, out number) ? numeber * 3 : -1; } 3) It's a matter of taste. Not a bad feature, but not a killer one either.
- MichaelGG 12y agoNone of them are killer features. Nor is pattern matching, assorted comprehensions, array slicing, binary literals, bytestrings, tuples, active patterns, records, type inference, immutability, shadowing, nested functions, custom operators, typechecked printf, type providers, workflows[1], sum types, agents, etc. etc. But it sure all adds up. Switching for a codebase might not be a wise move for many reasons. But writing new code doesn't have those excuses. Actually workflows are the closest to a "killer" feature but C# took the most popular, async, and hard-coded it in.
- CmonDev 12y agoDon't do it if you are used to good tools like ReSharper. Wait for Roslyn and it's syntax sugar instead.
- Touche 12y agoI disagree; C# is bad by comparison. I cannot think of a single reason to use C# over F#, can you? F# is essentially C# but with better defaults and much more easily extensible.
- DrJokepu 12y agoFor me, writing procedural OO code in F# always felt awkward and inconvenient. This is a problem because most of the .NET runtime was designed with procedural OO code in mind.
- math 12y agoI trialed F# a while back. Something I certainly noticed was not having as much help from the IDE (no resharper). The lambda notation also annoyed me (by comparison to C#). Yeah, I know it's no big deal and I understand the trade-offs being made.. but it still annoyed me. Pattern matching is one of the draw cards - but I see that is coming in C# soon.
- edgyswingset 12y agoDid you give F# Power Tools a go? It gives you a lot of what is missing out of the box. It's still not as great as C# IDE support, but for most things it gets the job done.
- MichaelGG 12y agoWhile this may come across as sour grapes, I find generally I need less IDE help in F#, since I'm not typing as much boilerplate. For instance, almost all type annotations are inferred (20:1 in my own empirical study), so there's a ton of code I simply don't need to type. In general, I find writing in C#, I'm going to need 50-200% more code for "business logic" type code that doesn't particularly benefit from F#. That is, using F# as a better C#. And this is after C# hacked in async - before that, there's no comparison if you need async style code. If C# added pattern matching, tuples, active patterns, type inference, everything-as-an-expression, nesting, more comprehensions, etc. etc., then yes, C# would be competitive. And with all the resources C# gets, the IDE would be far better than F#, sure.
- 12y ago
- Rapzid 12y agoAre you or is anyone aware of how the F# support for monodevelop(Xamarin Studio) and mono is coming along? I've had good experiences making console and service projects in Xamarin(monodevelop) and would like to give F# a go.. But I just don't see chaining myself to the VisualStudio/Windows environment.
- akoeplinger 12y agoF# is supported in Xamarin Studio: http://developer.xamarin.com/guides/cross-platform/fsharp/fsharp_support_overview/ http://developer.xamarin.com/guides/cross-platform/fsharp/fs...
- rbanffy 12y agoMono is perceived as a second-class citizen in the Unix-like space. Java, its main competitor, integrates very seamlessly and has excellent runtime tooling support Mono doesn't rival. Mono may gain some traction in some niches, but the Unix-like ecosystem is exceedingly diverse, without any dominant tool. Mono could double its presence and still be barely detectable. It could displace some of Java, but that would not affect the majority of the space. It's impossible (and foolish) to avoid C# if you develop for Windows, but I haven't written a single line of C# since 2004.
- beagle3 12y agoBeg to differ about Java integrating seamlessly - because Java manages its own memory, long running Java processes often need tweaking or their own VM to play nicely on a Unix machine. That's far from seamless.
- muhmi 12y agoOne nice little tool thats available with mono is the Mono C# shell http://www.mono-project.com/CsharpRepl http://www.mono-project.com/CsharpRepl