Reputation: 1171
Is it possible to use an F# project as an assembly in a C# project?
If yes; as F# is faster than C# for calculation stuffs (isn't it?), if the calculation part of the code is in F# and the main project is in C#, does it make the application faster?
Upvotes: 2
Views: 1106
Reputation: 4573
Yes, F# is a .NET language and will provide a compliant dll
F# is not faster. F# provides a better way of expressing certain types of problems. It therefore reduces amounts of bugs and increases productivity. F# also greatly encourages a programming model that is stateless, more scalable and gives a clear separation of data and functions.
Upvotes: 2
Reputation: 26174
Yes, you can and it makes sense. I personally use that approach in my projects. But the fact that you express a calculation in F# instead of C# doesn't mean that your code will run faster or slower. Of course, if you are familiar with functional programming you'll write faster your calculation code and in a more concise and elegant way, which will also allow you to test, maintain and reason about your code easily.
Upvotes: 1
Reputation: 172220
Yes, it's possible to use an F# project as an assembly in a C# project.
No, F# is not per se faster than C#. Both are compiled into the same type of Intermediate Language and run by the same .net Framework. You might be able to use some specific feature of F# to write a fast algorithm more elegantly than you would in C#, but that depends highly on the algorithm.
Upvotes: 9