Lisp 与 F# 有何关系?学习 Lisp 对升级 F# 有用吗?

发布于 2024-07-25 04:56:22 字数 452 浏览 4 评论 0原文

情况是这样的:我主要编写 C# 程序,并且在其中编写了我不想丢失的类型。 同时我想学习函数式编程。 显而易见的答案当然是 F#。

但除了 C# 之外,我使用 emacs 作为编辑器,而且我真的很想学习 Lisp。 (学习你知道的编辑器/IDE 的语言,这就是为什么我知道一点 VB 来在其中编写我的 VS 宏)而且它不仅仅是 emacs,Lisp 是我真正想学习的东西。

至于 F#,我可以将它与 C# 混合使用,不会出现任何互操作问题,拥有出色的 GUI (WPF) 和许多其他 .NET 功能。 但它当然没有 Lisp 那么成熟。

如果我是现实的,我知道如果我想将函数式语言带入我的职业生活,它必须是 F#。 由于学习两种完整的语言似乎有点多,我希望 Lisp 能成为学习函数式编程的好方法,如果我稍后开始学习 F#,那会很容易......

这是真的吗? 或者这两种语言根本没有可比性?

This is the situation : I mostly program C# and have written types in it I don't want to lose. At the same time I would like to learn functional programming. The obvious answer of course is F#.

But for everything apart from C# I use emacs as an editor, and I really would like to learn Lisp too. (Learn your editors/IDE's language you know, that's why I know a bit VB to write my VS-macro's in it) And it's not just emacs, Lisp is something I really want to learn.

As for F#, I could mingle it with C# without any interop problem, have a great GUI (WPF) and a lot of other .NET goodies. But it is, of course, not as mature as Lisp.

If I am realistic I know if I want to smuggle a functional language into my professional life it has to be F#. Since learning two whole languages seems a bit much, I was hoping that Lisp would be a great way to learn functional programming, and if I start out F# later, It would be very easy....

Is this true? Or are the two languages not comparable at all?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

ぶ宁プ宁ぶ 2024-08-01 04:56:23

它们都是函数式语言,但在语法上它们有很大不同。 这意味着许多概念将是相似的,并且您(作为程序开发人员)将必须做同样的费力才能使用其中任何一个,但它们是非常不同的语言。

F# 是 ML 的派生词(ML 及其所有派生词被认为是是一种不纯的函数式语言),而 Lisp 更旧,被认为是“纯粹的”函数式语言。

函数式语言的纯粹性是一个令人着迷的话题,我建议您阅读 语言Purity 以及 Dirty 和 Clean 函数,以更好地理解这个概念:

很多人都在谈论“纯粹”
函数式语言,其中“纯粹”
似乎是“好”的同义词。
一般有两个特点
与 a 的定义相关
纯函数式语言:

  1. 函数不能有副作用
  2. 使用任何给定参数调用的函数将始终返回相同的结果
    值。

They are both functional languages but syntactically they are very different. That means that a lot of the concepts will be similar and you (as a procedural developer) will have to do the same mind-bending to use either but they are very different languages.

F# is a derivative of ML (which is considered, with all its derivatives, to be an impure functional language) whereas Lisp is older and is considered to be a "pure" functional language.

The purity of a functional language is a fascinating topic and I would recommend that you read Language Purity and Dirty and Clean Functions to better understand the concept:

Many people talk about "pure"
functional languages, where "pure"
seems to be a synonym for "good".
There are two traits commonly
associated with the definition of a
pure functional language:

  1. functions can not have side-effects
  2. a function called with any given arguments will always return the same
    value.
转身以后 2024-08-01 04:56:23

我只是 F# 的新手,但我在 F# 之前学习了 Lisp,并且相信它对于在 .NET 框架和各种编程语言中了解 F# 的上下文非常有帮助。

我衷心建议您至少观看前几个视频:

http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/

这些在第一个小时内教您 Lisp 的基础知识。 该系列以这些知识为基础,并灌输由此产生的令人兴奋的原则。

I am only new to F#, but I studied Lisp before F# and believe it was very helpful in contextualising F# within both the .NET framework and the gamut of programming languages.

I'd heartily recommend watching at least the first few videos here:

http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/

These teach you the basics of Lisp within the first hour. The series builds upon that knowledge and instils the exciting principles that fall out from there.

扛刀软妹 2024-08-01 04:56:23

F# 和Scheme 的语义非常相似,但强类型除外。

还有,Scheme这么小,还不学呢!

The semantics of F# and Scheme are very similar with the noted exception of strong typing.

Also, Scheme is so small, not to learn it!

初熏 2024-08-01 04:56:23

作为一种编程语言,Lisp 本身就非常特殊,但它与 F# 完全不同,只是它们都支持函数式编程。 从 Lisp 继承到 F# 的语言结构并不多。 如果你想学习 lisp 就去学吧。 函数式编程的思想不会被继承,只是语法不会被继承。 Lisp 确实很老了,50 年代末了。 许多语言都受到它的影响,并且有相当多的方言。

如果您只是在寻找一种在 F# 之前学习的纯函数式语言,我建议您使用 Haskell。
Haskell 深受 ML 的影响,并且是 F# 的良好过渡语言,因为 F# 是 ML 的衍生语言。 您可以查看 Haskell 代码并在 F# 代码中看到类似的模式。

As a programming language Lisp is pretty special in it's own right however it's not similar to F# at all except that they both support functional programming. Not many language constructs carry over from Lisp to F#. If you want to learn lisp go for it. The idea of functional programming will carry over just not the syntax. Lisp is really old, late 50s. Many languages have been influenced by it and there are quite a few dialects.

If your just looking for a pure functional language to learn before F# i'd suggest Haskell.
Haskell was heavily influenced by ML and is a good transition language to F# since F# is a derivative of ML. You can look at Haskell code and see similar patterns in F# code.

给我一枪 2024-08-01 04:56:22

Lisp 是一个语言和实现的大家族。 例如,Scheme 是一种 Lisp 方言,可能有一百多个实现(其中大约十个比较流行)。 Common Lisp 是另一种方言,目前维护着大约 10 个实现。 Scheme 和 Common Lisp 都有实现尝试实现的书面标准。

F# 既是一种语言,又是一种实现。来自 Microsoft。 它主要源自 OCAML,属于 ML 语言家族。

Lisp 是一种非常早期支持函数式编程的语言(20 世纪 60 年代的 Lisp 1.5)。 许多早期的函数式编程实验都是用 Lisp 完成的。 20 世纪 70 年代,Lisp 社区掀起了一场追寻函数式编程根源的运动,其结果就是 Scheme。 然后,特别是在上世纪 80 年代和 90 年代,出现了新的函数式语言(ML、Miranda、FP、SML、Haskell、Clean 等),它们与通常的 Lisp 方言有很大不同。 仍然有一些遗产,但主要是朝着不同的方向发展(静态类型、类型推断、模块系统、批处理语言、代数数据类型、惰性求值、纯度等)。 Scheme 社区仍然与 FP 社区有很多联系。 但仅此而已。

有一些基本的 FP 思想可以独立于特定的 FP 语言来学习,但通常 F# 与大多数 Lisp 方言有很大不同。 F# 支持 .net 生态系统的另一个功能(特别是因为它是 Microsoft 创建的)并未得到 Lisp 方言的很好支持。

我也不认为了解 Emacs Lisp 等受限制的 Lisp 方言对学习 F# 会有多大好处。

Lisp is a large family of languages and implementations. Scheme for example is a Lisp dialect with probably more than one hundred implementations (about ten of them mildly popular). Common Lisp is another dialect with about ten currently maintained implementations. Scheme and Common Lisp both have written standards that implementations try to implement.

F# is both a language and implementation. From Microsoft. It was mostly derived from OCAML and belongs to the family of ML languages.

Lisp was a very early language supporting functional programming (Lisp 1.5 in the 60s). Lots of the early experiments with functional programming was done in Lisp. In the 70s in the Lisp community there was a movement to the roots of functional programming and the result was Scheme. Then especially in the 80s and 90s of the last century new functional languages appeared (ML, Miranda, FP, SML, Haskell, Clean, ...) that were/are quite different from the usual Lisp dialects. There is still some heritage, but mostly they developed in different directions (static typing, type inference, module systems, batch languages, algebraic data types, lazy evaluation, purity, and more). The Scheme community still has lots of contacts to the FP community. But that's mostly it.

There are some basic FP ideas that can be learned independent from a particular FP language, but generally F# is very different from most Lisp dialects. The other feature, that F# supports the .net ecosystem (especially since it is a Microsoft creation) is not that well supported by Lisp dialects.

I would also not expect much benefit from knowing a restricted Lisp dialect like Emacs Lisp for learning F#.

丘比特射中我 2024-08-01 04:56:22

我认为通过 Common Lisp 和 F# 学到的知识只有一点点“重叠”。 我认为大致的共性是

  • 使用“cons-lists”作为常见的基本数据类型进行编程,有时编写递归(尤其是尾递归)函数而不是循环
  • 常见高阶函数的一些基本用法(例如“map” - 应用a列表中的每个值的函数)

除了一些非常核心的函数式编程内容之外,我认为 Common Lisp 和 F# 之间的距离就像两种主流“函数式”(非 Haskell)语言一样遥远。 Common Lisp 是动态的; F# 是静态类型的。 句法形式完全不同。 运行时间完全不同。 图书馆有很大不同。 对象系统完全不同。

无论你以哪种顺序学习它们,我认为在学习其中一个之后,另一个仍然需要学习很多东西(以我上面描述的小重叠为模)。

I think there is only a small 'overlap' for what'd you'd learn via Common Lisp versus F#. The commonality is I think roughly

  • Programming with 'cons-lists' as a common fundamental data type, sometimes writing recursive (especially tail-recursive) functions rather than loops
  • Some basic uses of common higher-order functions (e.g. 'map' - apply a function to every value in a list)

Apart from some of that very core functional-programming stuff, I think Common Lisp and F# are about as far apart from each other as two mainstream 'functional' (non-Haskell) languages can be. Common Lisp is dynamic; F# is statically-typed. The syntactic forms are completely different. The runtimes are completely different. The libraries are very different. The object systems are completely different.

Regardless of which order you learn them, I think after learning one there will still be quite a bit more to learn in the other (modulo the small overlap I described above).

拔了角的鹿 2024-08-01 04:56:22

F# 与 ML 系列语言最相似,例如 SML 和 CAML。 语法和功能与 Lisp 不同。

但我认为从计算机科学的角度来看,学习至少一种函数式语言非常重要。 能够这样思考就很好了。

而且,我想说,在开始 F# 之前学习一种更纯粹的函数式语言将是养成良好函数式编程习惯的一种方法,因为如果你不这样做,你的 F# 代码最终可能会更加面向对象而更少函数式,因为这就是你来自。

F# is most comparable to the ML family of languages, such as SML and CAML. The syntax and features are different from Lisp.

But I think learning at least one functional language is really important from a computer science perspective. Being able to think that way is good.

And, I would say, learning a more purely functional language before starting F# would be a way to pick up good functional programming habits because, if you don't, your F# code might end up being more OO and less functional, because that's where you're coming from.

滥情哥ㄟ 2024-08-01 04:56:22

在我看来,学习函数式编程有两种方法:

  1. 使用更纯粹的函数式语言
    像Scheme(Lisp)或Haskell一样,它会强制
    你要打破程序
    立即调整心态; 或

  2. 使用实用的功能语言
    像 F# 一样,它还提供更多
    熟悉,但功能较少,
    结构可以帮助您轻松进入它。

无论哪种情况,如果您能用该语言做一些有用的事情,您都会从学习体验中获得更多。 听起来您对 Lisp (Emacs) 和 F# (.NET 互操作) 有兴趣,所以我会看一下两者,看看是什么吸引了您的注意力。

最终,理解函数式编程概念(高阶函数、无副作用、尾递归等)比任何一种语言都更有价值。 一旦您学习了这些概念,学习新语言并将这些技术应用于其他语言(例如功能日益强大的 C#)就会容易得多。 沿着这些思路,您可能对现实世界的函数式编程感兴趣。

In my view, there are two approaches to learning functional programming:

  1. Use a more pure functional language
    like Scheme (a Lisp) or Haskell that will force
    you to break out of a procedural
    mindset right away; or

  2. Use a pragmatic functional language
    like F# that also offers more
    familiar, but less functional,
    constructs to help you ease your way into it.

In either case, you'll get more out of the learning experience if you can do something useful with the language. It sounds like you have motivation for Lisp (Emacs) and F# (.NET interop), so I would be take a look at both and see what captures your attention.

Ultimately there's more value in understanding functional programming concepts (higher order functions, no side effects, tail recursion, etc) than any one language. And once you learn those concepts, it will be much easier to pick up new languages and apply the techniques in other languages (like the increasingly functional C#). Along those lines, you might be interested in Functional Programming for the Real World.

撑一把青伞 2024-08-01 04:56:22

需要考虑的两个重要事项是:

  • LISP 是动态类型的,而 F# 是静态类型的。
  • LISP 有内置宏。F# 没有。

尽管它们都被认为是实用的并且具有许多共同的特征,但它们也有不同。 学习 LISP 肯定会让您成为一名更好的 F# 程序员,反之亦然,但您仍然必须了解两者的特殊性才能实用它们。

为了能够与 .NET 互操作,我当然会选择 F#,但为了编程美观,我也会尝试 LISP。

Two important things to consider is:

  • LISP is dynamically typed whereas F# is statically typed.
  • LISP has macro's built in. F# does not.

Although they are both considered functional and share many common features, they are also different. Learning LISP will certainly make you a better F# programmer and vice versa, but still you would have to learn the peculiarities of both to be able to be practical in them.

For being able to interop with .NET I would certainly choose F# but for the sake of programming beauty I would try LISP as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文