5 ms·
Working mostly with .NET, I'm really trying to get a grip on F# these days. I have no ambitions on becoming as fluent as I am with C#, knowing pretty much all t
by trezor 16y ago
Working mostly with .NET, I'm really trying to get a grip on F# these days. I have no ambitions on becoming as fluent as I am with C#, knowing pretty much all the ins and outs of the language, but just good enough to fool around with it and getting stuff done(tm).
You wouldn't happen to know any good recommendations for books/online resources to get up to speed quickly? How did you get into the language to the point that it's now your happy language?
- profquail 16y agoI found this to be a pretty good resource when starting out with F#: http://www.ctocorner.com/fsharp/book/ http://www.ctocorner.com/fsharp/book/ Also check out the F# guide on Wikibooks: https://secure.wikimedia.org/wikibooks/en/wiki/F_Sharp_Programming https://secure.wikimedia.org/wikibooks/en/wiki/F_Sharp_Progr...
- trezor 16y agoI found the ctocorner stuff pretty straight and to the point. Thanks for the links :)
- fleitz 16y agoLike every language I learned to program in I had a project and then decided to use that language with that project. I have to admit the first project was killer, it took me a long time to even get the code compiling. But once I had finished and looked at the lack of code I was sold that this was the way to go. There is a really cool tutorial on writing the game of life in 32 lines of F# or writing the game of life that executes on the GPU using a similarly small amount of code. http://tomasp.net/blog/accelerator-life-game.aspx http://tomasp.net/blog/accelerator-life-game.aspx Start with a small project and learn the language, once you have a quite specific 'How do I do X?' question there are plenty of examples. I've never been the type person who could pick up a language from a book. If you're doing ASP.NET google for F# + MVC + NHAML. There is a great tutorial for getting an ASP.NET project going in F#. I'd say the primary thing that you need to learn for F# is how to convert loops to recursive functions and vice-versa. Also, look into the pipe operator, and figure out how to abuse the hell out of Seq.reduce and Seq.scan. If you like LINQ and lambda's in C# you'll probably like F#, I'd say that's what really got me interested, I ended up loving LINQ and lambdas and wanted to know more about this whole F# deal. Using the pipe operator makes the whole thing look much more pretty IMHO. [0..10] |> List.map (fun x -> x*x) |> List.reduce (fun a b -> a + b) vs. Enumerable.Range(0,10) .Select(x => x*x) .Aggregate((a,b) => a+b)
- gcampbell 16y agoMinor refactoring note, since F# seems to bring that out in me: you could change the last bit to "List.reduce (+)". Or you could do the whole thing as "[0..10] |> List.sumBy (fun x -> x*x)"
- trezor 16y agoThanks for the response. The game of life sample was pretty awesome, and the way HW acceleration was added just made it neater. And yes, I like LInQ quite a bit. I love how it lets you write your code a lot more declarative and in the process allows you to speed up your code by avoiding creating new collections while defining your transform. Now I've added a F# Interactive tab to my console2 session and I guess I'll see if I manage to get into F# properly this time around :)