模式混合在同一个解决方案,F#和C# [英] Patterns to mix F# and C# in the same solution

查看:204
本文介绍了模式混合在同一个解决方案,F#和C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学的是几个函数式语言,多为大专院校的目的。然而,当我有项目的客户机 - 服务器应用程序,我总是开始采用领域驱动设计,严格的空中接力。

I studied few functional languages, mostly for academical purposes. Nevertheless, when I have to project a client-server application I always start adopting a Domain Driven Design, strictly oop.

写在.net框架一个复杂的解决方案,可以使用比一个范例多语言,有时甚至更多得好处。混合使用C或C ++和Lua或Python是一种常见的做法,有时嵌入序言也非常有趣。 我从来没有试图混合OOP和功能的典范。

A complex solution written in a .Net framework could get advantages using more than a language and sometimes more than a paradigm. Mixing C or C++ with LUA or Python is a common practice, sometimes embedding prolog can be very interesting. I never tried to mix OOP and functional paradigm.

F#是一个较新的功能和面向对象的语言,我认为这是它在技术上很容易混在同一个解决方案C#与F#库。但我不知道,如果它使任何意义。我使用Linq来满足我的许多功能要求

F# is a newer functional and object oriented language, I see that's it's technically very easy to mix C# with F# libraries in the same solution. But I wonder if it makes any sense: I use Linq to satisfy many of my functional requirements.

当如何,你认为这是一个好主意,同时使用两种语言一起? 我不知道是否存在一组模式,尝试了。

When and how, do you think it's a good idea to mix these two languages together? I wonder if exists a set of patterns that tries that.

你实际使用在C#中的解决方案F#?

Do you actually use F# in a C# solution?

推荐答案

有一定的地方,传统的功能技术使得有很大的意义,并导致code,既更小,更简洁。一个典型的例子是文本分析和树处理,这两个经常一起出现,当你实现一个DSL。 F#的功能,如匿名的迭代器,可扩展的模式匹配,并定义自定义缀运营商作为组合程序真的帮助了很多在这里的能力。同时,在C#的一面,LINQ是一个良好的开端,但它不会带你一路有。

There are certain places where traditional functional techniques make a lot of sense, and lead to code that is both smaller and more concise. A classic example is text parsing and tree processing, both often appearing together when you're implementing a DSL. F# features like anonymous iterators, extensible pattern matching, and ability to define custom infix operators to serve as combinators really helps a lot here. Meanwhile, on the C# side, LINQ is a good start, but it doesn't take you all the way there.

我建议你看看 FParsec ,看到自己是如何更好地适应是先进的文本处理/解析比任何库,你可以在C#中可能写的。

I suggest you have a look at FParsec, and see for yourself how much better suited it is to advanced text processing / parsing than any library you could possibly write in C#.

这篇关于模式混合在同一个解决方案,F#和C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆