Haskell 与现实世界中的过程式编程

发布于 2024-07-25 01:04:26 字数 1433 浏览 9 评论 0原文

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

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

发布评论

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

评论(13

冰葑 2024-08-01 01:04:27

有些人喜欢用 Haskell 编程。 如果你可以选择你的环境,并且享受是一个考虑因素,那么也许你应该跳进去。

许多程序员没有能力选择他们的工具,享受不是他们选择的因素。 他们中的许多人在工作场所使用 C/Java/等作为“核心项目源”,但随后也选择或需要使用 Python 来执行“脚本”,例如带有 SCons 的构建脚本、生成 Java/等的其他脚本代码、测试系统、概念验证等。而在其他地方,Python 也被用在“核心项目”中。

8年后,“向你走来”的将是Haskell,而不是Python。 但你可以早点来。

Some people enjoy programming in Haskell. If you can choose your environment, and enjoyment is a consideration, then maybe you should hop in.

Many programmers are not in position to choose their tools and enjoyment is not a factor for their choices. Many of them get to use C/Java/etc at their workplace for the "core project source", but then also choose or need to use Python for "scripts" such as build-scripts with SCons, other scripts that generate Java/etc code, testing systems, proofs-of-concepts, etc.. And in other places Python is also used in the "core project".

In 8 years, it will be Haskell, not Python, which will be "coming to you". But you can come to it sooner.

我偏爱纯白色 2024-08-01 01:04:27

您可以将函数式编程的使用与实用的语言结合起来。

所有现代脚本语言(例如 JavaScript 或 Lua)都允许使用函数范式。

You can combine the use of functional programming and be pragmatic about the language.

All modern scripting languages s.a. JavaScript or Lua allow use of the functional paradigm.

诺曦 2024-08-01 01:04:27

功能性概念正在变得越来越强大。 请注意围绕 Ruby 的一系列活动和兴趣。 我最近还注意到,人们对 JavaScript 的兴趣超出了单纯的浏览器脚本语言的范畴。 尽管投入的时间可能不会在今年或明年得到回报,但你现在就可以投入到游戏中,从而取得领先。

这取决于您的总体游戏计划。 您是把编程作为目的本身还是达到目的的手段? 如果是前者,请疯狂使用 Haskell。 如果是后者,请坚持使用主流的“可就业”语言。 等待哈斯克尔起飞,然后猛扑。

The functional concept is coming on strong. Note the flurry of activity and interest around Ruby. I've also noticed a bit more interest in JavaScript beyond a mere browser scripting language lately. You can get ahead of the game by diving in now, though the time invested might not pay off this year or next.

It depends on your general game plan. Are you into programming as an end in itself or as a means to an end? If it's the former, go nuts with Haskell. If the latter, stick with mainstream, "employable" languages. Wait for Haskell to take off and then pounce.

如何视而不见 2024-08-01 01:04:27

为什么是过程式而不是面向对象,除了 C 之外,多年来没有看到过程式被使用。

从商业角度来说。 我会选择 Java 或 C#。 它们的薪水都很高,而且技能可以与其他志同道合的语言(例如 python、Ruby 和 JavaScript)互换,这并不重要。

Haskell 值得花费时间和精力,尽管它非常学术化,一些银行使用它,尽管欧洲和英国的许多银行正在将代码库转移到 F#。

从商业角度来看,我认为 FOP 不会飞速发展。 但这些技术确实出现在主流语言中。 特别是对于多核芯片设计并使代码在其上并行运行。

Why procedural and not Object Oriented, not seen procedural being used for many years apart from C.

Commercially speaking. I would go with Java or C#. Doesn't really matter which they both pay well and the skills are interchangeable with other like minded languages such as python, Ruby and JavaScript.

Haskell is worth the time and effort, although it is very academic, some banks use it, although many in Europe and the UK are moving the code base over to F#.

I don't think FOP will be moving at great speeds commercially speaking. But the techniques are definitely making an appearance in the main stay languages. Especially with Multi-Core chip designs and making code run parallel on them.

沙与沫 2024-08-01 01:04:26

Haskell 并不像人们想象的那样难学。 Haskell 为你打开了一个你从来不知道存在的新世界。 它与学习任何其他语言一样有价值。 您可能找不到需要您进行 Haskell 编程的工作,但这真的意味着语言没有价值吗?

Haskell 会教你很多新东西,它会告诉你如何用你/使用/使用的语言更好地编程。 您可以在业余时间用它来做您自己的个人项目。

如果您将“现实世界”定义为“现金生成器”,那么 Haskell 在“现实世界”中并没有真正使用太多。 因此,如果这是您的目标,那么您可能必须重新考虑目标:p

另外,我不太喜欢所选“如何学习 haskell”答案的那部分。 掌握任何语言都需要数月甚至数年的时间,而不仅仅是 Haskell。 看你怎么定义“大师”了。 我可以非常高效地使用 Haskell,而且我只学习了一个月,而且我什至学得很慢。

Haskell isn't as hard as people like to make out to learn. Haskell opens up a new world that you never knew existed for you. It's as valuable to learn as any other language. You might not find a job requiring you to do Haskell programming, but does that really mean a language isn't valuable?

Haskell will teach you a lot of new stuff, and it will show you how to program even better in the languages you /do/ work with. You can do your own personal projects in your spare time with it.

Haskell isn't really used much in the "real world" if you define "real world" as "cash generator". So if that is your objective, then you might have to rethink objectives :p

Also, I don't really like that part of chosen "how to learn haskell" answer. It takes months to years to master any language, not just Haskell. Depending on how you define "master". I can use Haskell to a pretty good degree of efficiency and I've only been learning it for a month, and I've been taking it slow even.

东风软 2024-08-01 01:04:26

如果不出意外的话,当你不得不重新使用那些仍在工作场所使用的过程语言时,学习 Haskell 带来的思维方式的改变将会对你有所帮助。

函数范式开始进入各种主流应用程序和语言 - 甚至 C++ 也将在 C++0x 中添加一个(残缺的)lambda。

您可能还想了解一些混合语言,例如 Scala 或 OCaml。 Twitter 正在使用 Scala,Jane's Street 的金融交易平台正在使用 OCaml。

If nothing else, the change in mindset that learning Haskell provides will help you when you have to go back to using those procedural languages that still are used in the workplace.

The functional paradigm is beginning to make it's way into various mainstream applications and languages - Even C++ is going to be adding a (crippled) lambda in C++0x.

You may also want to look at some of the hybrid languages like Scala or OCaml. Scala is being used at Twitter, and OCaml is being used at Jane's Street in a financial trading platform.

你是暖光i 2024-08-01 01:04:26

我学习 Haskell 是因为它是迄今为止我在 Scala、Clojure、OCaml 和 Scheme 中尝试过的最好的函数式语言,但我并没有认真地期望将它用于工作。

事实证明,它非常适合那些对于团队来说太小并且在 Java 中太耗时的零散工作。 到目前为止,我已经将它用于临时数据迁移,即将 CSV 导出为另一种格式、批量转换 XML(HXT 比 XSLT 更简洁、更强大)、从互联网上抓取屏幕以及软件项目评估(包括建模)冒险使用概率单子并使用回溯生成最佳甘特图。 这些都是需要做的实际工作,我什至懒得尝试用 Java 来做,因为这将是一个多天的工作。

我现在使用它而不是 Excel 来处理任何模糊的数学问题,因为在文本编辑器中在 haskell 源中创建值列表比将它们输入到 Excel 中要花费更多的精力。 一旦进入 Haskell,我就可以做各种 Excel 做不到的事情,比如回溯、概率分布等。 如果我需要一个图表,那么我会将这些值以 CSV(2 行代码)的形式输出,并将它们加载到 Excel 中。

唯一的缺点是需要几个月的时间才能熟练,但恕我直言,值得付出努力。

I learned Haskell because it was by far the best functional language that I tried out of Scala, Clojure, OCaml and Scheme but I didn't seriously expect to use it for work.

As it turns out, it is perfect for those sorts of odd jobs that are too small for a team and would be just too time consuming in Java. So far, I've used it for ad-hoc data migrations i.e. mangling CSV exports into another format, batch conversions of XML (HXT is more concise and more powerful than XSLT), screen-scraping off the internet and software project estimating including modelling risk using the probability monad and producing optimum gantt charts using backtracking. This is all real work that needed doing, that I wouldn't have even bothered to try and do in Java as it would be a multi-day undertaking.

I now use it instead of Excel for anything vaguely mathematical as it is little more effort to create a list of values in haskell source in a text editor than it is to type them into Excel. Once in haskell, I can then do all sorts of magic like backtracking, probability distributions etc. that Excel can't do. If I need a graph then I spit the values out as CSV (2 lines of code) and load them into Excel.

The only downside is that it does take several months to get proficient, but worth the effort IMHO.

画骨成沙 2024-08-01 01:04:26

您可能不应该期望在任何地方使用 Haskell 的频率都像在专业环境中使用 C 家族语言一样频繁。 如果问题是学习 Haskell 和函数式编程范式对你是否有价值,那么答案是肯定的。 您可以将您对编程的丰富理解应用到您的所有工作中。

You probably shouldn't expect to use Haskell anywhere nearly as often as a C family language in professional settings. If the question is whether it will be valuable for you to study Haskell and functional programming paradigms, the answer is yes. You can apply your enriched understanding of programming to all of your work.

忆沫 2024-08-01 01:04:26

与过程语言相反,学习 Haskell 和函数式编程范式对我来说有价值吗?

如果拥有扩展的技能是有价值的,那么:是的。

您可能会发现的一项优势是:并行和并发编程。 过去的过程语言往往没有明确的副作用概念,因此很难正确地用它们编写并行程序。 函数式语言(特别是像 Haskell 这样限制副作用的语言)对于高效的并行编程有很多话要说。

掌握这项技能不会有什么坏处。

As opposed to procedural languages, will it be valuable for me to study Haskell and functional programming paradigms?

If having an expanded skill set is valuable, then: yes.

One advantage you might pick up: parallel and concurrent programming. Procedural languages of the past tend to have no clear notion of side effects, as a result writing parallel programs in them is difficult to do correctly. Functional languages (in particular, ones that limit side effects like Haskell) have a lot more to say about productive parallel programming.

Having that skill up your sleeve can't hurt.

凑诗 2024-08-01 01:04:26

与过程语言相反,学习 Haskell 和函数式编程范式对我来说有价值吗?

除非你想痛苦。 Luke Plant 在为什么学习 Haskell/Python 会让你成为更差的程序员中说道:

所以,学习 Python 和 Haskell 让我士气低落,同时也鼓舞了我
让我写出奇怪且难以理解的代码......

(这不完全是一个笑话。)

As opposed to procedural languages, will it be valuable for me to study Haskell and functional programming paradigms?

Not unless you want to be miserable. Luke Plant says, in Why learning Haskell/Python makes you a worse programmer:

So, learning Python and Haskell has demoralised me and encouraged
me to write code that is bizarre and difficult to understand...

(This is not entirely a joke.)

丢了幸福的猪 2024-08-01 01:04:26

我可以看到,如果函数式编程很容易被非函数式代码使用,那么它在生产环境中可能是一个优势。 我想,当 MS 提出 F# 时,他们也能看到这一点。

由于它们都编译为 IL,因此您可以处理需要函数式方法的问题,并在过程代码中非常轻松地使用这些解决方案。

通过这种方式,功能代码可以轻松地在生产环境中找到自己的方式一次一点

因此,由于 MS 的用户群那么大,我的猜测是,如果 F# 不会在在不久的将来,Haskell 也不会。

I can see that functional programming can be a plus in a production environment if it's very easy to use by non functional code. MS could see that too when they came up with F# I guess.

Since they both compile to IL, you can handle problems that ask for a functional approach functional and use those solutions very easily in your procedural code.

In that way functional code can easily find its way in a production environment a bit at a time

Therefore, and since the userbase of MS is that big, my guess is that if F# will not catch on in the very near future, that Haskell won't either.

挽心 2024-08-01 01:04:26

我认为这是值得的。 它将帮助您理解问题是如何解决的,而不仅仅是计算机如何工作。

也许一个特殊的问题是 Haskell 本身 - 作为一种纯粹的函数式语言,它有点“硬核”,另一方面可能甚至使事情变得复杂。

相反,函数式编程可能以非常实用的方式非常有用 - 因此,许多 OO/命令式语言现在都包含函数式元素(Linq、匿名函数、只读值、函数指针/委托、类型推断):您可以专注于什么应该这样做,这允许您用更少的代码表达更多内容(甚至更不容易出错)。

Scala 或 F# 等非纯函数式语言(标准函数式语言)可以轻松集成到现有 Java 或 .NET 项目中,因此您可以在需要时结合这两种范例的优点。 有关函数式语言的典型优点,请参阅

I think it's worth the struggle. It will help you to understand how problems are solved and not only how a computer works.

Maybe one particular problem is Haskell itself - As a purely functional language, it's kinda "hardcore" which may on the other hand even complicate things.

Functional programming instead may be extremely useful in a very pragmatic manner - Many OO/imperative languages have now included functional elements for this reason (Linq, anonymous functions, readonly values, function pointers/delegates, type-inference): You can concentrate on what should be done which allows you to express more in less code (that is even less error-prone).

Non-purely functional languages (standard functional languages) like Scala or F# can be integrated easily into existing Java or .NET-projects, so you can combine the benefits of both paradigms where they are needed. For typical advantages of functional languages, see this thread. Just think of extremely powerful parsing (Monadic parser combinators / Parsec) or concurrent programming that is possible with functional languages and you'll see how useful they are.

GRAY°灰色天空 2024-08-01 01:04:26

无论您目前使用哪种语言,拓宽视野都可以帮助您成为一名更好的程序员。 例如,在编写了 Lisp 宏之后,您将永远不会以相同的方式看待编程。 当您开始用 Haskell 术语进行思考后,您会发现自己正在编写函数并希望使用不太高级的语言来实现闭包。

从 C# 中的优点来看,例如 lambda、类型推断、闭包等>,学习 Haskell 将使您在主流语言的未来前沿中占据一席之地。

Broadening your horizons helps you be a better programmer no matter what language you happen to be using at the moment. You'll never look at programming the same way after you've written Lisp macros, for instance. After you begin to think in Haskell terms, you'll find yourself composing functions and wishing for closures in less advanced languages.

Judging from goodies in C# such as lambdas, type inference, closures, and so on, learning Haskell will give you a leg up on tomorrow's cutting edge in mainstream languages.

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