功能语言(Erlang,F#,Haskell,Scala)

时间:2022-06-01 16:57:26

1) Are functional languages suited for web applications development?

1)功能语言是否适合Web应用程序开发?

2) Are functional languages suited for business/ERP/CRM type of applications?

2)功能语言是否适合商业/ ERP / CRM类型的应用程序?

10 个解决方案

#1


Functional languages of the kind you describe are general purpose programming languages, they're used for all manner of things, including web apps and business apps. (I use Haskell).

您描述的那种函数式语言是通用编程语言,它们用于各种事物,包括Web应用程序和业务应用程序。 (我使用Haskell)。

As gabor implies, ultimately it comes down to libraries. Scala has a web framework: lift. Haskell has happstack, as well as 2100 4400 (in 2010 2012) libraries on Hackage for all manner of thiings.

正如gabor所暗示的那样,最终归结为图书馆。 Scala有一个Web框架:lift。哈斯克尔(Haskell)以及2100,400(2010年至2012年)的Hackage图书馆都有各种各样的风格。

It really isn't so much a question of the language, as the toolchain, when considering particular specialized domains.

在考虑特定的专业领域时,它实际上不是一个语言问题,而是工具链。

#2


Functional languages are good for anything you would like to use them for.

函数式语言适用于您希望使用它们的任何内容。

However, developing applications these days are not as simple as using a programming language. The advantage of Java, C#, etc. is that they come with large libraries and other environment niceties that are absolutely required when you build business software. Most functional languages do not have that great support (as yet?).

但是,如今开发应用程序并不像使用编程语言那么简单。 Java,C#等的优势在于它们带有大型库和其他环境细节,这些都是构建业务软件时绝对需要的。大多数函数式语言都没有那么大的支持(到目前为止?)。

F# might be promising since it's in the .NET environment and can take advantage of the tools available there (correct me if I'm wrong).

F#可能很有前途,因为它在.NET环境中并且可以利用那里可用的工具(如果我错了,请纠正我)。

This article describes how Lisp, an early functional language, was used to create a web based application successfully.

本文描述了如何使用早期函数式语言Lisp成功创建基于Web的应用程序。

#3


Functional languages are well suited for web application development, Scala in particular.

功能语言非常适合Web应用程序开发,特别是Scala。

Have a look at the Lift framework for more information.

有关更多信息,请查看Lift框架。

#4


2) Are functional languages suited for business/ERP/CRM type of applications?

2)功能语言是否适合商业/ ERP / CRM类型的应用程序?

To address the second point about business/ERP/CRM apps: personally I wouldn't implement these in a "pure" functional language like Haskell, or a dynamic functional language like Clojure. On the other hand, I am currently implementing an ERP in Scala, which of course is hybrid OOP/FP and statically compiled.

为了解决关于业务/ ERP / CRM应用程序的第二点:我个人不会用像Haskell这样的“纯”函数语言或者像Clojure这样的动态函数语言来实现它们。另一方面,我目前正在Scala中实施ERP,当然是混合OOP / FP和静态编译。

The reason I say this is that a business app like an ERP is fundamentally record-oriented: there is a data schema expressing the different record types and the app logic is then designed almost wholly around CRUDing those records and applying custom business workflows to them. And fundamentally, I don't believe that these sorts of data-centric business apps are a great fit for the functional model.

我之所以这么说是因为像ERP这样的商业应用程序基本上是面向记录的:有一个表示不同记录类型的数据模式,然后应用程序逻辑几乎完全围绕CRUD这些记录并将自定义业务工作流应用于它们。从根本上说,我不相信这些以数据为中心的业务应用程序非常适合功能模型。

People can talk about the OOP-relational mismatch all they like but ultimately both OOP and databases are record-oriented: an OOP language with a good ORM lets you map those different data models into your code and then attach the code to handle each of the models. And having this statically typed (ideally with a strongly-typed ORM like Scala's squeryl) massively reduces the chances of a runtime error or e.g. a change to one of the data models not being properly applied through the code.

人们可以谈论他们喜欢的OOP关系不匹配,但最终OOP和数据库都是面向记录的:具有良好ORM的OOP语言允许您将这些不同的数据模型映射到您的代码中,然后附加代码来处理每个楷模。并且具有静态类型(理想地具有类似Scala的squeryl的强类型ORM)大大减少了运行时错误的可能性,例如,对通过代码未正确应用的其中一个数据模型的更改。

Don't get me wrong - I'm a big fan of FP (I'm doing more and more of my systems programming in Haskell), but for me the record-oriented approach of OOP makes more sense than the function-oriented approach of FP for wrangling the data objects of a business ERP or similar. (Scala is a nice exception to the rule because you get to use the OOP paradigm with quality ORMs for the record manipulation, but also the FP goodness for your general app programming.)

不要误会我的意思 - 我是FP的忠实粉丝(我在Haskell中做了越来越多的系统编程),但对我来说,面向记录的OOP方法比面向函数的方法更有意义。 FP用于处理业务ERP或类似的数据对象。 (Scala是规则的一个很好的例外,因为你可以使用OOP范例和质量ORM来进行记录操作,还可以使用FP优于你的常规应用程序编程。)

#5


  1. Yes, Nitrogen is a good example of a functional web framework. It scales also.
  2. 是的,氮是功能性网络框架的一个很好的例子。它也可以扩展。

http://nitrogenproject.com/

#6


Yaws is a fantastic web server for Erlang.

Yaws是Erlang的精彩网络服务器。

#7


While I wouldn't say that any particular functional languages are tailored for doing web-development, I also wouldn't say that you can't do web development with a functional language. I think that depends entirely on what web frameworks may be available for the language you choose and whether or not there are any web servers that will support the language.

虽然我不会说任何特定的功能语言是为网络开发量身定做的,但我也不会说你不能用功能语言进行网页开发。我认为这完全取决于您选择的语言可用的Web框架以及是否有任何支持该语言的Web服务器。

For instance, I'm sure that you can use F# along with ASP.Net on IIS to do web development. I doubt there's support for F# in the templating engine, but you can definitely write business logic in F#.

例如,我确信您可以在IIS上使用F#和ASP.Net进行Web开发。我怀疑在模板引擎中是否支持F#,但你绝对可以在F#中编写业务逻辑。

Similarly, there's mod_haskell for Apache, which should make it relatively easy to have dynamic output with haskell. Although, I've never personally used it. At the same time, if there's a mod_(erlang or scala) for Apache, it would be similarly easy for those languages.

类似地,Apache有mod_haskell,这使得使用haskell进行动态输出相对容易。虽然,我从来没有亲自使用它。同时,如果Apache有一个mod_(erlang或scala),那么这些语言也同样容易。

Ultimately, I think that the stateless nature of functional languages should make it well suited for a stateless, MVC style web framework. However, I think it really comes down to what tools and frameworks are available to make your life easier when working with these languages. For example, Ruby wasn't really popular for web development until rails got popular, and I didn't really like doing anything webby with Python until I found django.

最终,我认为函数式语言的无状态特性应该使它非常适合无状态的MVC风格的Web框架。但是,我认为这实际上取决于哪些工具和框架可以使您在使用这些语言时更轻松。例如,在rails开始流行之前,Ruby并不是很受网络开发的欢迎,在我找到django之前,我并不喜欢用Python做任何webby。

#8


Functional languages provides new kinds of abstractions which can be used for web development. Continuation based web servers are for example popular among functional languages. The PLT Scheme web server supports this kind of web application development. You can read more about continuations and their use in web development on wikipedia

功能语言提供了可用于Web开发的新型抽象。基于连续的web服务器例如在功能语言中很流行。 PLT Scheme Web服务器支持这种Web应用程序开发。您可以在*上阅读有关延续及其在Web开发中的使用的更多信息

#9


Most functional languages, namely the ones you included, are considered general purpose languages. For web development, I would deeply consider using Clojure, or Scala. They both have very good web frameworks, and they both run on the JVM. I can totally recommend Clojure and Scala, but not so much for the others.

大多数函数式语言,即您包含的语言,都被认为是通用语言。对于Web开发,我会深深考虑使用Clojure或Scala。它们都有非常好的Web框架,它们都运行在JVM上。我完全可以推荐Clojure和Scala,但对其他人来说并不是那么多。

Haskell has a web framework, but I have never used it.

Haskell有一个Web框架,但我从未使用它。

Business applications? Sure, why not. Functional languages are great for just about anything.

商业应用?当然,为什么不呢。功能语言几乎适合任何事情。

#10


One of the biggest advantages claimed by proponents of functional languages is that they make it easier to write programs that can execute in parallel. But web applications typically don't have problems with parallelism. Typically, the web server/application server maintains a pool of threads, and each user request is assigned to a different thread, which can run on a different physical processor. So, you can take advantage of multiple processors without too much trouble. The trick is that web apps are characterized by large numbers of small requests, and threads and imperative languages work well there. Where imperative languages start to break down is when you have a small number of computationally expensive requests.

功能语言支持者声称的最大优势之一是它们可以更容易地编写可以并行执行的程序。但是Web应用程序通常没有并行性问题。通常,Web服务器/应用程序服务器维护一个线程池,并且每个用户请求被分配给不同的线程,该线程可以在不同的物理处理器上运行。因此,您可以毫不费力地利用多个处理器。诀窍在于,Web应用程序的特点是大量的小请求,而线程和命令式语言在那里运行良好。命令式语言开始崩溃的地方是你有少量计算成本高昂的请求。

Another big advantage of functional languages is that since functions have no side effects, testing is easier. You test each function in isolation across a few of its inputs, and you know the system will work. But, there's a catch. If your operation involves input or output, you use a monad rather than a function, and you lose this testability benefit for that portion of your code.

函数式语言的另一大优势是,由于函数没有副作用,因此测试更容易。您可以在几个输入中单独测试每个函数,并且您知道系统可以正常工作。但是,有一个问题。如果您的操作涉及输入或输出,则使用monad而不是函数,并且您将失去代码中该部分的可测试性优势。

But, typically web applications involve reading information from a request, making requests to a database, reading the response from the database, and formatting a response. That's lots and lots of IO, or monads, and very little opportunity for functions.

但是,通常Web应用程序涉及从请求中读取信息,向数据库发出请求,从数据库读取响应以及格式化响应。这是很多很多的IO,或monad,而且功能很少。

Given these characteristics of web applications, what benefits do functional languages bring to web application programming?

鉴于Web应用程序的这些特性,函数式语言为Web应用程序编程带来了哪些好处?

#1


Functional languages of the kind you describe are general purpose programming languages, they're used for all manner of things, including web apps and business apps. (I use Haskell).

您描述的那种函数式语言是通用编程语言,它们用于各种事物,包括Web应用程序和业务应用程序。 (我使用Haskell)。

As gabor implies, ultimately it comes down to libraries. Scala has a web framework: lift. Haskell has happstack, as well as 2100 4400 (in 2010 2012) libraries on Hackage for all manner of thiings.

正如gabor所暗示的那样,最终归结为图书馆。 Scala有一个Web框架:lift。哈斯克尔(Haskell)以及2100,400(2010年至2012年)的Hackage图书馆都有各种各样的风格。

It really isn't so much a question of the language, as the toolchain, when considering particular specialized domains.

在考虑特定的专业领域时,它实际上不是一个语言问题,而是工具链。

#2


Functional languages are good for anything you would like to use them for.

函数式语言适用于您希望使用它们的任何内容。

However, developing applications these days are not as simple as using a programming language. The advantage of Java, C#, etc. is that they come with large libraries and other environment niceties that are absolutely required when you build business software. Most functional languages do not have that great support (as yet?).

但是,如今开发应用程序并不像使用编程语言那么简单。 Java,C#等的优势在于它们带有大型库和其他环境细节,这些都是构建业务软件时绝对需要的。大多数函数式语言都没有那么大的支持(到目前为止?)。

F# might be promising since it's in the .NET environment and can take advantage of the tools available there (correct me if I'm wrong).

F#可能很有前途,因为它在.NET环境中并且可以利用那里可用的工具(如果我错了,请纠正我)。

This article describes how Lisp, an early functional language, was used to create a web based application successfully.

本文描述了如何使用早期函数式语言Lisp成功创建基于Web的应用程序。

#3


Functional languages are well suited for web application development, Scala in particular.

功能语言非常适合Web应用程序开发,特别是Scala。

Have a look at the Lift framework for more information.

有关更多信息,请查看Lift框架。

#4


2) Are functional languages suited for business/ERP/CRM type of applications?

2)功能语言是否适合商业/ ERP / CRM类型的应用程序?

To address the second point about business/ERP/CRM apps: personally I wouldn't implement these in a "pure" functional language like Haskell, or a dynamic functional language like Clojure. On the other hand, I am currently implementing an ERP in Scala, which of course is hybrid OOP/FP and statically compiled.

为了解决关于业务/ ERP / CRM应用程序的第二点:我个人不会用像Haskell这样的“纯”函数语言或者像Clojure这样的动态函数语言来实现它们。另一方面,我目前正在Scala中实施ERP,当然是混合OOP / FP和静态编译。

The reason I say this is that a business app like an ERP is fundamentally record-oriented: there is a data schema expressing the different record types and the app logic is then designed almost wholly around CRUDing those records and applying custom business workflows to them. And fundamentally, I don't believe that these sorts of data-centric business apps are a great fit for the functional model.

我之所以这么说是因为像ERP这样的商业应用程序基本上是面向记录的:有一个表示不同记录类型的数据模式,然后应用程序逻辑几乎完全围绕CRUD这些记录并将自定义业务工作流应用于它们。从根本上说,我不相信这些以数据为中心的业务应用程序非常适合功能模型。

People can talk about the OOP-relational mismatch all they like but ultimately both OOP and databases are record-oriented: an OOP language with a good ORM lets you map those different data models into your code and then attach the code to handle each of the models. And having this statically typed (ideally with a strongly-typed ORM like Scala's squeryl) massively reduces the chances of a runtime error or e.g. a change to one of the data models not being properly applied through the code.

人们可以谈论他们喜欢的OOP关系不匹配,但最终OOP和数据库都是面向记录的:具有良好ORM的OOP语言允许您将这些不同的数据模型映射到您的代码中,然后附加代码来处理每个楷模。并且具有静态类型(理想地具有类似Scala的squeryl的强类型ORM)大大减少了运行时错误的可能性,例如,对通过代码未正确应用的其中一个数据模型的更改。

Don't get me wrong - I'm a big fan of FP (I'm doing more and more of my systems programming in Haskell), but for me the record-oriented approach of OOP makes more sense than the function-oriented approach of FP for wrangling the data objects of a business ERP or similar. (Scala is a nice exception to the rule because you get to use the OOP paradigm with quality ORMs for the record manipulation, but also the FP goodness for your general app programming.)

不要误会我的意思 - 我是FP的忠实粉丝(我在Haskell中做了越来越多的系统编程),但对我来说,面向记录的OOP方法比面向函数的方法更有意义。 FP用于处理业务ERP或类似的数据对象。 (Scala是规则的一个很好的例外,因为你可以使用OOP范例和质量ORM来进行记录操作,还可以使用FP优于你的常规应用程序编程。)

#5


  1. Yes, Nitrogen is a good example of a functional web framework. It scales also.
  2. 是的,氮是功能性网络框架的一个很好的例子。它也可以扩展。

http://nitrogenproject.com/

#6


Yaws is a fantastic web server for Erlang.

Yaws是Erlang的精彩网络服务器。

#7


While I wouldn't say that any particular functional languages are tailored for doing web-development, I also wouldn't say that you can't do web development with a functional language. I think that depends entirely on what web frameworks may be available for the language you choose and whether or not there are any web servers that will support the language.

虽然我不会说任何特定的功能语言是为网络开发量身定做的,但我也不会说你不能用功能语言进行网页开发。我认为这完全取决于您选择的语言可用的Web框架以及是否有任何支持该语言的Web服务器。

For instance, I'm sure that you can use F# along with ASP.Net on IIS to do web development. I doubt there's support for F# in the templating engine, but you can definitely write business logic in F#.

例如,我确信您可以在IIS上使用F#和ASP.Net进行Web开发。我怀疑在模板引擎中是否支持F#,但你绝对可以在F#中编写业务逻辑。

Similarly, there's mod_haskell for Apache, which should make it relatively easy to have dynamic output with haskell. Although, I've never personally used it. At the same time, if there's a mod_(erlang or scala) for Apache, it would be similarly easy for those languages.

类似地,Apache有mod_haskell,这使得使用haskell进行动态输出相对容易。虽然,我从来没有亲自使用它。同时,如果Apache有一个mod_(erlang或scala),那么这些语言也同样容易。

Ultimately, I think that the stateless nature of functional languages should make it well suited for a stateless, MVC style web framework. However, I think it really comes down to what tools and frameworks are available to make your life easier when working with these languages. For example, Ruby wasn't really popular for web development until rails got popular, and I didn't really like doing anything webby with Python until I found django.

最终,我认为函数式语言的无状态特性应该使它非常适合无状态的MVC风格的Web框架。但是,我认为这实际上取决于哪些工具和框架可以使您在使用这些语言时更轻松。例如,在rails开始流行之前,Ruby并不是很受网络开发的欢迎,在我找到django之前,我并不喜欢用Python做任何webby。

#8


Functional languages provides new kinds of abstractions which can be used for web development. Continuation based web servers are for example popular among functional languages. The PLT Scheme web server supports this kind of web application development. You can read more about continuations and their use in web development on wikipedia

功能语言提供了可用于Web开发的新型抽象。基于连续的web服务器例如在功能语言中很流行。 PLT Scheme Web服务器支持这种Web应用程序开发。您可以在*上阅读有关延续及其在Web开发中的使用的更多信息

#9


Most functional languages, namely the ones you included, are considered general purpose languages. For web development, I would deeply consider using Clojure, or Scala. They both have very good web frameworks, and they both run on the JVM. I can totally recommend Clojure and Scala, but not so much for the others.

大多数函数式语言,即您包含的语言,都被认为是通用语言。对于Web开发,我会深深考虑使用Clojure或Scala。它们都有非常好的Web框架,它们都运行在JVM上。我完全可以推荐Clojure和Scala,但对其他人来说并不是那么多。

Haskell has a web framework, but I have never used it.

Haskell有一个Web框架,但我从未使用它。

Business applications? Sure, why not. Functional languages are great for just about anything.

商业应用?当然,为什么不呢。功能语言几乎适合任何事情。

#10


One of the biggest advantages claimed by proponents of functional languages is that they make it easier to write programs that can execute in parallel. But web applications typically don't have problems with parallelism. Typically, the web server/application server maintains a pool of threads, and each user request is assigned to a different thread, which can run on a different physical processor. So, you can take advantage of multiple processors without too much trouble. The trick is that web apps are characterized by large numbers of small requests, and threads and imperative languages work well there. Where imperative languages start to break down is when you have a small number of computationally expensive requests.

功能语言支持者声称的最大优势之一是它们可以更容易地编写可以并行执行的程序。但是Web应用程序通常没有并行性问题。通常,Web服务器/应用程序服务器维护一个线程池,并且每个用户请求被分配给不同的线程,该线程可以在不同的物理处理器上运行。因此,您可以毫不费力地利用多个处理器。诀窍在于,Web应用程序的特点是大量的小请求,而线程和命令式语言在那里运行良好。命令式语言开始崩溃的地方是你有少量计算成本高昂的请求。

Another big advantage of functional languages is that since functions have no side effects, testing is easier. You test each function in isolation across a few of its inputs, and you know the system will work. But, there's a catch. If your operation involves input or output, you use a monad rather than a function, and you lose this testability benefit for that portion of your code.

函数式语言的另一大优势是,由于函数没有副作用,因此测试更容易。您可以在几个输入中单独测试每个函数,并且您知道系统可以正常工作。但是,有一个问题。如果您的操作涉及输入或输出,则使用monad而不是函数,并且您将失去代码中该部分的可测试性优势。

But, typically web applications involve reading information from a request, making requests to a database, reading the response from the database, and formatting a response. That's lots and lots of IO, or monads, and very little opportunity for functions.

但是,通常Web应用程序涉及从请求中读取信息,向数据库发出请求,从数据库读取响应以及格式化响应。这是很多很多的IO,或monad,而且功能很少。

Given these characteristics of web applications, what benefits do functional languages bring to web application programming?

鉴于Web应用程序的这些特性,函数式语言为Web应用程序编程带来了哪些好处?