F# end to end
colinbul.wordpress.com
colinbul.wordpress.com
What this post leaves out is some of the tooling you lose when you move to F#. For what I assume are political reasons, F# keeps being marketed as a niche "scientific" product, when in reality, pretty much any C# code is better off being written in F#, even if you aren't writing idiomatic F#. I did one small test where I rewrote a C# program in non-idiomatic F#, and it required 1/20th the type annotations. C#'s just verbose - why use it?
Even WebSharper requires a "C# web site" to actually get Visual Studio to kick up IIS and make things run. There's no real C# code, but so much in the .NET/VS environment assumes C# (or VB).
In fact the worst times I've had with F# were due to other libraries depending on how the C# compiler is implemented, and failing when reflection/expression trees didn't look exactly the same. Fortunately the major use case (LINQ) seems to have been addressed quite solidly with F# 3.0.
There are a few exceptions, but in general, F# can emit anything C# can.
In fact, with F#'s "inline" ability, you have more flexibility than you do in C# - the CLR does vastly better when handed a big IL function, versus expecting it to get inlining right. The F# compiler does more advanced optimizations, too.
F#'s compiler is OK - it's doing a lot more work. But it's not instantaneous like C#.
What about incremental compilation, is this done at all or does the F# interpreter recompile everything at runtime?
With C#, it was common to always have some project somewhere that was just a playground to run a few lines of code to test out a library, make sure I got a format string correct, etc. The F# REPL in VS eliminates that. If the F# team had more resources, and could make it fully integrated, it'd be unbelievable.
F# doesn't have an interpreter, it's compiled. The REPL is taking your lines and compiling modules and whatnot on the fly, then loading and running them pretty much as normal. So when you build, you get a binary, and you're all set - no runtime overhead.
Meanwhile, C# is supposed to have a REPL, Mono has an implementation, but it seems like C# is sort of abandoned and now the primary folks are working on yet another "almost-JavaScript-to-JavaScript" compiler.
I had a look around the web, and I couldn't find any sample open source F# applications that one can take apart.
So the CLR generics team build F# (an Haskell like language) and the Java generic team build Scala (an Haskell like language).
Hmm...
Can anyone recommend a good resource for learning F# for the .NET developer? I don't need an intro to functional programming (I have a pretty functional style in python and I've messed around with Haskell) but just a well paced intro to the syntax and standard library.
http://www.amazon.com/Expert-F-3-0-Apress/dp/1430246502/
I've started functional programming by reading the book about F# by Tomas Petricek. It was really good because it target learning functional programming to someone who have a solid OO background.
http://www.amazon.com/Real-World-Functional-Programming-Toma...
http://www.amazon.com/Programming-F-3-0-Chris-Smith/dp/14493...
With a background in FP, I can go through the book at a walking pace. It starts off with the basics, though, so it might not get into the nitty-gritty details that would interest you if you're already familiar with .NET and FP.
I'm a C# dev that thinks in terms of F#/ML but I've long recognized that VB is actually a more expressive language than C#, especially if you want to write OOP in a functional style. For instance, VB has better IDE support for expressing sum types, doesn't require type annotations for lambada expressions, and has more Linq (query comprehension) operators.
Edit: I'm wrong about the "better support for sum types", I was thinking of Completion List feature but it doesn't quite give you a proper sum type (though it comes close).
I've found C# to feel more concise, clean, and have less annoying hard to predict syntax. If .. End If, While .. End While, but For .. Next? I'd expect End For. The attempt to make it look more like words just made it more annoying to me. VB.NET's syntax feels too verbose. C#'s feels more like a good spot where it's very similar to C++ and Java, but not alien.
f# has lot's of pythonish elements anyway. and the clr bindings are better documented
It could be a very very good thing for MS in the next decade if they invest in it properly (which they seem to be doing).
Interesting times.
It seems like it should be a good fit for the stuff we normally do (log processing/munging), but I don't know how well it'll work outside of Windows.
It's quite well supported as everything related to F# developed by Microsoft is open-sourced (compiler, libraries, PowerPack).
Moreover Mono fully supports F#, as the compiler is sometimes bundled in some releases.
Also, F# is really a pretty sweet language (as for an heavy Haskell user with a little C# background). French love inside.
Can you make any suggestions as to places to read up on this stuff? The language seems so well put together!
If you don't need .Net, OCaml is practically the same language and has lots of vim/emacs support.
https://github.com/mono/monodevelop https://github.com/xamarin/fsharpbinding
BTW, F# also has emacs support, and from what I hear vim support is on the way:
I sorta doubt that the emacs/vim support is anything near what there is for OCaml, but knowing Xamarin it will get there... eventually. But really, I don't see a big reason to pick F# over OCaml unless you're already doing .Net or something.
you need a fork of the fsharpbindings project https://github.com/xamarin/fsharpbinding
have you tried using fsharpx from nuget? monodevelop has nuget support as of now. https://github.com/squidge/monodevelop-nuget-addin/tree/xs-n...
I also just built fsharpx.core and fsharpx.http with monodevelop(right now) and it built fine for me.
http://monodevelop.com/Download
it looks a little prettier, but besides that nothing has really caught my attention. it also seems to throw exceptions more frequently(throwing exceptions, not crashing)
In general, Mono (with or without F#) just works. I do all the development on Windows and VS, and then copy the binaries over to deploy. Downside is that stack traces don't read the pdbs so I don't get line number information.
F# Interactive has had some readline and other weird errors on Mono/Linux.
i don't like websharper. what is wrong with people wanting to write their clientside in f#? anyway that's why i was looking at how the iis stack works, so i can write my own framework.
there is an - in my opinion - pretty nice f# mvc template (not that i'm a big fan of mvc) available here: http://visualstudiogallery.msdn.microsoft.com/3d2bf938-fc9e-...
it's also ironic that when Donna Malayeri talks about F# the first thing she talks about is how verbose c# is compared to f# http://channel9.msdn.com/Blogs/Charles/C9-Lectures-Donna-Mal...
http://www.amazon.com/review/R3VEMJVVPFSUNF/ref=cm_cr_pr_per...