Haskell,Lisp和verbosity [英] Haskell, Lisp, and verbosity
问题描述
对于那些在Haskell和一些Lisp风格上有经验的人来说,我很好奇Haskell和Lisp中编写代码的方式令人愉快(使用可怕的术语)。
一些背景:我现在正在学习Haskell,之前曾经使用过Scheme和CL(并且稍微进入了Clojure)。传统上,你可以认为我是动态语言的粉丝,他们提供的简洁和快速。我很快爱上了Lisp宏,因为它给了我另一种方式来避免冗长和样板。
我发现Haskell 难以置信有趣,因为它向我介绍了我不知道存在的编码方式。它肯定有一些方面,似乎他们将有助于实现敏捷性,如易于编写部分功能。然而,我有点担心丢失Lisp宏(我假设我失去了他们;真实被告知我可能还没有学习他们)和静态类型系统。
任何在两个世界上做过大量编码的人都会对经验不同,你喜欢什么以及如果所说的偏好是情境的话评论?
简单的答案:
- 几乎任何你可以做的宏,但是它可能需要更多的思考(但只有第一次,它很有趣,你会是一个更好的程序员)和
- 静态系统是足够通用的,它永远不会阻碍你的方式,有些令人惊讶的是它实际上帮助实现敏捷(如你所说),因为当你的程序编译你可以几乎肯定是正确的,所以这个确定性可让您试用您可能会以其他方式害怕尝试的东西 - 虽然它与Lisp不一样,但是对编程有一种动态感觉。
- almost anything you can do with macros you can do with a higher-order function (and I include monads, arrows, etc.), but it might require more thinking (but only the first time, and it's fun and you'll be a better programmer for it), and
- the static system is sufficiently general that it never gets in your way, and somewhat surprisingly it actually "aids in achieving agility" (as you said) because when your program compiles you can be almost certain that is correct, so this certainty lets you try out things you might be otherwise afraid to try -- there is a "dynamic" feel to programming although it's not the same as with Lisp.
[注意:有一个 Template Haskell < a>,它允许你像Lisp一样编写宏,但严格来说你永远不应该 。]
For those of you experienced in both Haskell and some flavor of Lisp, I'm curious how "pleasant" (to use a horrid term) it is to write code in Haskell vs. Lisp.
Some background: I'm learning Haskell now, having earlier worked with Scheme and CL (and a little foray into Clojure). Traditionally, you could consider me a fan of dynamic languages for the succinctness and rapidity they provide. I quickly fell in love with Lisp macros, as it gave me yet another way to avoid verbosity and boilerplate.
I'm finding Haskell incredibly interesting, as it's introducing me to ways of coding I didn't know existed. It definitely has some aspects that seem like they would aid in achieving agility, like ease of writing partial functions. However, I'm a bit concerned about losing Lisp macros (I assume I lose them; truth be told I may have just not learned about them yet?) and the static typing system.
Would anyone who has done a decent amount of coding in both worlds mind commenting on how the experiences differ, which you prefer, and if said preference is situational?
Short answer:
[Note: There is a "Template Haskell" that lets you write macros just as in Lisp, but strictly speaking you should never need it.]
这篇关于Haskell,Lisp和verbosity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!