In what areas does F# make “absolute no sense in u

2019-01-31 10:27发布

Don Syme in his SPLASH talk says that F# is NOT intended to be a replacement for C# even though it has the general capabilities. He goes on to say that there are areas where F# makes no sense in using, but doesn't expand on the thesis.

  1. Can somebody please tell me what areas should be avoided while using F# ?
  2. You could also mention areas where C# shine.

Related question:

In what areas might the use of F# be more appropriate than C#?

9条回答
forever°为你锁心
2楼-- · 2019-01-31 11:05

This is a tricky question, because it isn't very well qualified. Are you talking about the language in general, or are you talking about the language together with current IDE support? Or are you talking about using F# given the libraries available?

  • Language in general - I don't think there are areas where using F# would be an absolute nonsense. It would be great for systems programming of fully managed OS (e.g. Singularity) and I think that functional programs would be easier to verify formally (which could be a big deal for OS). For low-level embedded systems, you could use meta-programming and langauge-oriented facilities (e.g. to model signal flow in hardware etc.)

  • Language with current IDE - The current F# IDE has some limitations - it doesn't work with WinForms designer (but it works well with Blend and WPF).

  • Language given developer education - It is more difficult to hire F# programmers than to hire C# programmers. If you're creating some application that doesn't have any complicated core (e.g usual "interface for a database") then developing it in C# will be cheaper (If you could hire good F# developers they would likely finish it faster and with less bugs, but it may not be worth the cost).

  • Language given libraries available - If you want to restrict yourself to using F# with just libraries that work well with it then the domain shrink a bit more. For example, LINQ to SQL and ASP.NET MVC can be used with F#, but it isn't perfect. However, for many projects it would make sense to develop your own libraries and then F# becomes great language for that.

查看更多
做自己的国王
3楼-- · 2019-01-31 11:05

You might want to think twice about using it for operating system kernel development or low-level embedded systems :-)

查看更多
手持菜刀,她持情操
4楼-- · 2019-01-31 11:05

Well, at the risk of stating the obvious, F# is first and foremost a functional programming language and OOP programming in F# can be a pain in the neck. So if you're working with a problem that is best expressed with OOP I imagine using C# does make more sense.

Mutually recursive types and explicit implementation of interfaces are the first examples off the top of my head of why OOP in F# can be cumbersome.

An (often cited) example of "problem that is best expressed with OOP" is creating a UI library. You have many widgets, which encapsulate their own state and you want to ask them to do a few things like "draw yourself" polymorphically (is that even a word?)

查看更多
登录 后发表回答