简体   繁体   English

个人Silverlight项目的F#或C#?

[英]F# or C# for personal Silverlight project?

I'm about to start working on a rich-internet-application project for a student organization at my university. 我即将开始为我所在大学的学生组织开展一个富互联网应用项目。 I will be the only programmer, and what technologies to use is totally up to me. 我将是唯一的程序员,使用什么技术完全取决于我。 I've already decided on going with Silverlight, but I'm not sure whether to use C# or F#. 我已经决定使用Silverlight,但我不确定是使用C#还是F#。 Here are some of the things I'm keeping in mind: 以下是我要记住的一些事情:

C#: C#:

  • I already know it and have used it extensively with Silverlight at work. 我已经知道了,并且在工作中广泛使用了Silverlight。 I have no F# and little general FP experience. 我没有F#和一般的FP经验。
  • Some say the OOP paradigm works better for complex stateful UIs. 有人说OOP范例对于复杂的有状态UI更有效。
  • Maintenance: I'll be in school for three more years, but after that if the app is still in use they may have a better time finding someone else to maintain it if I use a more common language. 维护:我将在学校待上三年,但之后如果该应用程序仍在使用中,如果我使用更常用的语言,他们可能会更好地找到其他人来维护它。
  • C# experience is probably more valuable in the "real world". C#体验在“现实世界”中可能更有价值。

F#: F#:

  • The main reason is I want to learn something new. 主要原因是我想学习新的东西。 Functional programming languages seem pretty cool (I find myself using the FP features of C# very often, and think they're the biggest improvement in C# 3.0). 函数式编程语言似乎很酷(我发现自己经常使用C#的FP功能,并认为它们是C#3.0中最大的改进)。 I think I'd have a lot more fun if I used F#, but am I being unrealistic in thinking the cost in time and effort might not outweigh the benefits? 如果我使用F#,我想我会有更多的乐趣,但我认为时间和精力的成本可能不会超过收益,这是不切实际的吗?

In my opinion, when you are a student, you should be trying to put your fingers in as many pots as possible. 在我看来,当你是一名学生时,你应该尽量把手指放在尽可能多的花盆里。

The more languages you play with, the more understanding you will have of the "best" ways of doing things in a specific language. 您玩的语言越多,您对用特定语言做事的“最佳”方式的理解就越多。

As for "experience" being more valuable in the "real world". 至于“经验”在“现实世界”中更有价值。 Personally I only ever consider true commercial experience when looking at potential candidates. 就个人而言,在寻找潜在候选人时,我只考虑真正的商业经验。 Experience in a language when you're in a job and being paid is extremely different to experience in using a language when learning / studying it. 当你在工作和获得报酬时,使用某种语言的经验与在学习/学习时使用语言的经验是截然不同的。 Things you do whilst studying are about gaining skills and knowledge whereas things you do in a commercial environment give you experience in solving real life problems. 你在学习期间所做的事情是获得技能和知识,而你在商业环境中所做的事情会给你解决现实生活问题的经验。

Bottom line... play with the cool stuff whilst you still can! 底线......尽可能地玩酷炫的东西!

Because you expect to create something useful that will live past your tenure as maintainer, I would suggest writing the majority in C#. 因为你希望创建一些有用的东西,这些东西将作为维护者过去,我建议用C#编写大部分内容。 What you can do to scratch your new-technology-itch, though, is pull out distinct, well-defined components that don't interact directly with the UI and write those in a separate F# assembly. 但是,你可以做些什么来划分你的新技术痒,它可以提供不同的,定义明确的组件,它们不直接与UI交互并在单独的F#程序集中编写。

I've done something similar with a project that I've open sourced in the past. 我做过类似于我过去开源的项目。 My fundamental UI logic (in this case, the V-VM parts of the MV-VM) were in C# because it works so well with WPF technologies. 我的基本UI逻辑(在这种情况下,MV-VM的V-VM部分)是在C#中,因为它与WPF技术一起工作得很好。 Then, certain functionally-oriented components of the Model itself I broke out into a separate assembly and wrote in F# just to get some limited exposure to the language. 然后,模型本身的某些面向功能的组件我爆发成一个单独的程序集,并在F#中写入只是为了获得一些有限的语言接触。

It's not a jump-with-both-feet approach to learning technology, so I probably didn't learn as much as I could have. 这不是一种双脚跳跃的学习技术方法,所以我可能没有尽可能多地学习。 An F#-only project wouldn't have taught me nearly as much about exposing F# functionality to the greater .Net world in a friendly way, either, though. 不过,一个F#-only项目也不会教我几乎同样以友好的方式向更大的.Net世界公开F#功能。

No matter what, the key in a situation like this is for you to have fun and enjoy what you're doing. 无论如何,这种情况下的关键是让你享受乐趣,享受你正在做的事情。 :) :)

You can make F# business logics project (a dll). 您可以制作F#业务逻辑项目(一个DLL)。

And then the user interface in C#. 然后是C#中的用户界面。 And in user interface project you can add a reference to the F#-library. 在用户界面项目中,您可以添加对F#-library的引用。

This is a good solution in general when using Silverlight: The power of F# is (functional) programming but currently C# will have a better tool-support. 在使用Silverlight时,这是一个很好的解决方案:F#的强大功能是(功能)编程,但目前C#将拥有更好的工具支持。

I know it's not in your list, but if you're interested in learning something new, you might consider GWT - You write your client in Java (which ought to be an easy jump from C#), and then the compiler turns the client side into JavaScript. 我知道它不在您的列表中,但如果您对学习新内容感兴趣,可以考虑使用GWT - 您使用Java编写客户端(这应该是从C#轻松跳转),然后编译器转向客户端进入JavaScript。 Should be a bit more cross-platform compatible than Silverlight, and it's an interesting fusion of technologies (CSS, JavaScript, and Java aren't going anywhere in the near future). 应该比Silverlight更具跨平台兼容性,并且它是一种有趣的技术融合(CSS,JavaScript和Java在不久的将来不会出现在任何地方)。

I just gave a talk about programming reactive Silverlight applications in F# at London F# user-group meeting. 我刚刚在伦敦F#用户组会议上讨论了在F#中编写反应式Silverlight应用程序的问题。 The recording of the talk (and samples) are available here , so you can take a look at that. 这里可以记录谈话(和样本) ,所以你可以看一下。

Here are a few points you could consider: 您可以考虑以下几点:

  • I think F# has some very nice features that make programming this kind of applications more elegant than in C# (for example, you can nicely model program as a state machine and encode this direcly in code). 我认为F#有一些非常好的功能,使编程这种应用程序比C#更优雅(例如,你可以很好地将程序建模为状态机并在代码中直接编码)。

  • F# is still relatively new, but I believe that there is a decent chance that finding someone familiar with F# after three years will be much easier than today (and finding younger students who are interested to learn something new should be easier :-)). F#仍然相对较新,但我相信有一个很好的机会,找到三年后熟悉F#的人比今天容易得多(找到有兴趣学习新东西的年轻学生应该更容易:-))。

  • I was surprised that there is already quite a demand for good F# programmers in the London area. 令我感到惊讶的是,伦敦地区已经有很多优秀的F#程序员需求。 This will be probably different in different places, but I think that F# is becoming a "nice-to-have" feature on CV for some jobs. 这在不同的地方可能会有所不同,但我认为F#在一些工作的CV上变成了一个“很好的”功能。

I'm presuming that this will be used in an intranet environment. 我假设这将用于内部网环境。 Otherwise, I'd question whether the choice of Silverlight is really the best due to market penetration. 否则,我会质疑Silverlight的选择是否真的是最好的,因为市场渗透。 The second point I'd raise is that one of the really key skills for most web developers is Javascript. 我要提出的第二点是大多数Web开发人员真正关键的技能之一就是Javascript。 (Nowadays, that would be Javascript with a library like JQuery to manipulate the DOM, simplify AJAX, etc.) unless the application is particularly complex, there might be some merit in considering DHTML+Javascript as a starting point, and only looking at other technologies if it proves too much for that. (现在,这将是Javascript与JQuery一样的库来操纵DOM,简化AJAX等),除非应用程序特别复杂,考虑DHTML + Javascript作为起点可能有一些优点,只看其他技术如果证明太多了。 However, if you're set on going down the Silverlight route, then C# is by far the most likely to be supported. 但是,如果你打算沿着Silverlight路线走下去,那么C#是最有可能得到支持的。 If you're still learning, then it's also the route that has the best documentation. 如果您还在学习,那么它也是拥有最佳文档的路线。 F# has some excellent documentation around, but unfortunately not nearly as much as for C#. F#有一些很好的文档,但不幸的是没有C#的那么多。 You briefly mention the time and cost commitment. 您简要提及时间和成本承诺。 Unless you're quite comfortable with functional programming, F# is liable to take significantly longer, in part due to unfamiliarity and in part due to the amount of reference documentation to help you on your way. 除非您对函数式编程非常熟悉,否则F#可能会花费更长的时间,部分原因是由于不熟悉,部分原因是由于大量的参考文档可以帮助您完成工作。 While it it undoubtedly good to have knowledge of a range of programming languages under your belt, what's more valuable to most employers is a solid understanding of their language of choice - so diversifying too much can miss that. 虽然掌握一系列编程语言的知识无疑是有益的,但对大多数雇主而言,更有价值的是对他们选择的语言的充分理解 - 因此过多的多样化可能会错过这一点。 When looking to learn an unfamiliar programming language starting with something like solving Project Euler problems may present a better way of starting out, rather than diving straight into a major project with a new language. 当想要学习一种不熟悉的编程语言时,从解决项目欧拉问题开始,可能会提出一种更好的方法,而不是直接进入一个使用新语言的重大项目。 If you start in C#, you can always create an F# project that implements functions more suitable for its focus, and reference it from the C# one, to dip your toe in its waters while not automatically committing a lot of additional time to it. 如果你从C#开始,你总是可以创建一个F#项目来实现更适合它的焦点的函数,并从C#中引用它,将你的脚趾浸入其水域,同时不会自动为它提供大量的额外时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM