https://fsharpforfunandprofit.com/posts/why-use-fsharp-intro/ [ ] [favi] F# for Fun and Profit Get Started * Explore this site * Why use F#? * Tips for learning F# * Troubleshooting F# * Books * Videos * Search this site Popular posts * Functional design patterns * Thinking Functionally * Designing with Types * Railway Oriented Programming * Thirteen ways of looking at a turtle * Understanding Parser Combinators * Roman Numerals Kata * Property-based testing Recent Posts * Revisiting the six approaches * Dependency Interpretation * Dependency injection using the Reader monad * Dependency injection using parameters * Six approaches to dependency injection * >> Archives More * Follow @ScottWlaschin * About * Terms and Conditions * Typos? Part of the "Why use F#?" series (link) Introduction to the 'Why use F#' series An overview of the benefits of F# 01 Apr 2012 This series of posts will give you a guided tour through the main features of F# and then show you ways that F# can help you in your day-to-day development. Key benefits of F# compared with C# If you are already familiar with C# or Java, you might be wondering why it would be worth learning yet another language. F# has some major benefits which I have grouped under the following themes: * Conciseness. F# is not cluttered up with coding "noise" such as curly brackets, semicolons and so on. You almost never have to specify the type of an object, thanks to a powerful type inference system. And it generally takes less lines of code to solve the same problem. * Convenience. Many common programming tasks are much simpler in F #. This includes things like creating and using complex type definitions, doing list processing, comparison and equality, state machines, and much more. And because functions are first class objects, it is very easy to create powerful and reusable code by creating functions that have other functions as parameters, or that combine existing functions to create new functionality. * Correctness. F# has a very powerful type system which prevents many common errors such as null reference exceptions. And in addition, you can often encode business logic using the type system itself, so that it is actually impossible to write incorrect code, because it is caught at compile time as a type error. * Concurrency. F# has a number of built-in tools and libraries to help with programming systems when more than one thing at a time is happening. Asynchronous programming is directly supported, as is parallelism. F# also has a message queuing system, and excellent support for event handling and reactive programming. And because data structures are immutable by default, sharing state and avoiding locks is much easier. * Completeness. Although F# is a functional language at heart, it does support other styles which are not 100% pure, which makes it much easier to interact with the non-pure world of web sites, databases, other applications, and so on. In particular, F# is designed as a hybrid functional/OO language, so it can do almost everything that C# can do as well. Of course, F# integrates seamlessly with the .NET ecosystem, which gives you access to all the third party .NET libraries and tools. Finally, it is part of Visual Studio, which means you get a good editor with IntelliSense support, a debugger, and many plug-ins for unit tests, source control, and other development tasks. In the rest of this series of posts, I will try to demonstrate each of these F# benefits, using standalone snippets of F# code (and often with C# code for comparison). I'll briefly cover all the major features of F#, including pattern matching, function composition, and concurrent programming. By the time you have finished this series, I hope that you will have been impressed with the power and elegance of F#, and you will be encouraged to use it for your next project! How to read and use the example code All the code snippets in these posts have been designed to be run interactively. I strongly recommend that you evaluate the snippets as you read each post. The source for any large code files will be linked to from the post. This series is not a tutorial, so I will not go too much into why the code works. Don't worry if you cannot understand some of the details; the goal of the series is just to introduce you to F# and whet your appetitite for learning it more deeply. If you have experience in languages such as C# and Java, you have probably found that you can get a pretty good understanding of source code written in other similar languages, even if you aren't familiar with the keywords or the libraries. You might ask "how do I assign a variable?" or "how do I do a loop?", and with these answers be able to do some basic programming quite quickly. This approach will not work for F#, because in its pure form there are no variables, no loops, and no objects. Don't be frustrated - it will eventually make sense! If you want to learn F# in more depth, there are some helpful tips on the "learning F#" page. --------------------------------------------------------------------- * 2. F# syntax in 60 seconds - The "Why use F#?" series 1. Introduction to the 'Why use F#' series 2. F# syntax in 60 seconds 3. Comparing F# with C#: A simple sum 4. Comparing F# with C#: Sorting 5. Comparing F# with C#: Downloading a web page 6. Four Key Concepts 7. Conciseness 8. Type inference 9. Low overhead type definitions 10. Using functions to extract boilerplate code 11. Using functions as building blocks 12. Pattern matching for conciseness 13. Convenience 14. Out-of-the-box behavior for types 15. Functions as interfaces 16. Partial Application 17. Active patterns 18. Correctness 19. Immutability 20. Exhaustive pattern matching 21. Using the type system to ensure correct code 22. Worked example: Designing for correctness 23. Concurrency 24. Asynchronous programming 25. Messages and Agents 26. Functional Reactive Programming 27. Completeness 28. Seamless interoperation with .NET libraries 29. Anything C# can do... 30. Why use F#: Conclusion Written by ScottW. Found a typo or error? Follow me on [Twitter_lo] Twitter. Comments Please enable JavaScript to view the comments powered by Disqus. blog comments powered by Disqus Built with Hugo and