Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning F# Functional Data Structures and Algorithms

You're reading from   Learning F# Functional Data Structures and Algorithms Get started with F# and explore functional programming paradigm with data structures and algorithms

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher Packt
ISBN-13 9781783558476
Length 206 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Adnan Masood Adnan Masood
Author Profile Icon Adnan Masood
Adnan Masood
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Embrace the Truth FREE CHAPTER 2. Now Lazily Get Over It, Again 3. What's in the Bag Anyway? 4. Are We There Yet? 5. Let's Stack Up 6. See the Forest for the Trees 7. Jumping the Queue 8. Quick Boost with Graph 9. Sets, Maps, and Vectors of Indirections 10. Where to Go Next? Index

Benefits of using F# over C#

And now on to the language wars!

A common inquiry among seasoned C# developers is, "What is the benefit of using F#? Or to word it differently, why do I need to learn a new language when I can perform the same tasks in the language I already know and love?"

A good analogy is LaTeX versus Microsoft Word. You may have used LaTeX for typesetting. For complicated tasks, Word becomes too complex or even unusable. Marko Pinteric explains why you would want to use LaTeX instead of Word with the following graph:

Benefits of using F# over C#

Complexity and learning curve. Using LaTeX on Windows by Marko Pinteric (www.pinteric.com/miktex.html)

The same applies to F#. Functional programming does have a learning curve but it equips you with the tools needed to go further in algorithmic software development. This eventually leads to the argument of general benefits of functional programming over imperative and object oriented languages.

Using functional programming with F#, one can arguably formulate and design solutions in an easier, more effective manner, especially if these problems pertain to the algorithmic domain. As a functional language, F# facilitates keeping the problem closer to their definition in a concise and terse manner. From the testability perspective, the resulting code becomes less error-prone due to its powerful type system, intuitive recursive representation of algorithms, and built-in immutability. Data structure immutability is especially helpful in the case of multi-threaded scenarios. This is, in essence, due to built-in data type immutability.

The specific F# advantages include the following:

  1. Interoperability with the .NET CLR languages.
  2. Ease of asynchronous programming, intuitive use of async {} expressions.
  3. Full Visual Studio .NET IDE integration with compiler and debugger support.
  4. Suitability for writing domain-specific languages and compilers.
  5. Improved performance, scalability, and reduced maintenance cost due to enhanced testability and terseness.
  6. Language extensibility features such as units of measurements, record types, and language-oriented programming support.

Any functional language in general, and F# in particular, is not a silver bullet and shouldn't be treated as one. For UI centric and other applications of highly stateful nature, C# and other imperative .NET languages are a better fit than a functional programming language. Having said that, if you are a quant, who is writing high frequency trading algorithms in F#, or a rewriting to improve an existing VWAP implementation, you will be delighted to know that you can easily expose the F# functionality using your server-side C# WCF libraries. However, since you can have F# and C# together in one .NET solution, it is easy to combine the benefits of both languages and use as needed.

You have been reading a chapter from
Learning F# Functional Data Structures and Algorithms
Published in: Jun 2015
Publisher: Packt
ISBN-13: 9781783558476
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image