我了解 Perl 5。学习 Perl 6 比转向 Python 有什么优势?
来自 Perl 5 背景,迁移到 Perl 6 或 Python 有何优势?
Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
从 Perl 切换到 Python 没有任何优势。 从 Python 切换到 Perl 也没有任何优势。 他们都同样有能力。 根据您所了解的知识和您想要解决的问题来选择您的工具,而不是根据一种工具本质上比另一种更好的观念来选择工具。
唯一真正的优势是,如果您从您不知道的语言切换到您知道的语言,在这种情况下,您的工作效率可能会提高。
There is no advantage to be gained by switching from Perl to Python. There is also no advantage to be gained by switching from Python to Perl. They are both equally capable. Choose your tools based on what you know and the problem you are trying to solve rather than on some sort of notion that one is somehow inherently better than the other.
The only real advantage is if you are switching from a language you don't know to a language you do know, in which case your productivity will likely go up.
Perl 在快速单行方面通常比 Python 更好,尤其是涉及文本/正则表达式
http://novosial.org/perl/one-liner/
Perl is generally better than python for quick one liners, especially involve text/regular expressions
http://novosial.org/perl/one-liner/
Python 没有 Junctions。 事实上,我认为到目前为止只有 Perl 有 Junctions。 :-)
Python does not have Junctions. In fact I think only Perl has Junctions so far. :-)
在我看来,Python 的语法更加干净、简单且一致。 您可以在任何地方都定义相同的嵌套数据结构,无论您打算将它们传递给函数(或从函数返回它们)还是直接使用它们。 我非常喜欢 Perl,但是一旦我学了足够多的 Python 来“掌握”它,我就再也没有回头。
根据我的经验,Python 的随机片段往往比 Perl 的随机片段更具可读性。 差异实际上取决于每种语言的文化,Perl 用户通常欣赏聪明,而 Python 用户通常更喜欢清晰。 这并不是说你不能使用清晰的 Perl 或狡猾的 Python,但这些并不常见。
两者都是很好的语言,可以解决许多相同的问题。 我个人倾向于 Python,如果没有其他原因,它似乎正在获得动力,而 Perl 似乎正在将用户流失到 Python 和 Ruby。
请注意上面大量的狡猾的词语。 老实说,这确实取决于个人喜好。
In my opinion, Python's syntax is much cleaner, simpler, and consistent. You can define nested data structures the same everywhere, whether you plan to pass them to a function (or return them from one) or use them directly. I like Perl a lot, but as soon as I learned enough Python to "get" it, I never turned back.
In my experience, random snippets of Python tend to be more readable than random snippets of Perl. The difference really comes down to the culture around each language, where Perl users often appreciate cleverness while Python users more often prefer clarity. That's not to say you can't have clear Perl or devious Python, but those are much less common.
Both are fine languages and solve many of the same problems. I personally lean toward Python, if for no other reason in that it seems to be gaining momentum while Perl seems to be losing users to Python and Ruby.
Note the abundance of weasel words in the above. Honestly, it's really going to come down to personal preference.
Python 有一个巨大的优势:它的实现,有一个相当稳定的编译器。
Perl 6(于 2019 年更名为 Raku)是一种颇具远见的语言,拥有稳定的编译器和 2015 年发布的测试规范。它有一组非常酷的功能,其中包括:连接、语法(是的,您可以使用 Raku“正则表达式”编写完整的解析器)、字素级别的 unicode 处理和惰性列表。
在您的特定情况下,当您了解 Perl 5 时,您将很快熟悉 Raku(née Perl 6)语法。
有关 Raku 的炫酷功能的更全面列表,请参阅 https://raku.org/ 或 < a href="https://docs.raku.org/language/faq" rel="nofollow noreferrer">常见问题解答。
Python has one huge advantage: it's implemented, there's a rather stable compiler for it.
Perl 6 (renamed Raku in 2019) is a rather visionary language, with a stable compiler and test specification released in 2015. It has a set of very cool features, among them: junctions, grammars (yes, you can write full parsers with Raku "regexes"), unicode handling at the grapheme level, and lazy lists.
In your particular case when you know Perl 5 you'll get familiar with the Raku (née Perl 6) syntax very quickly.
For a more comprehensive list of what cool features Raku has, see https://raku.org/ or alternatively, the FAQ.
Python 的一个主要优点是现在可以以生产就绪的格式提供。
如果您需要与 Java 或 .net clr 密切合作,Python 有 Jython 和 IronPython。
Perl 6 的优点是基于与 Perl (1-5) 相同的原理; 如果您喜欢 Perl,您也会出于同样的原因喜欢 Perl 6。 (有不止一种方法可以做到这一点,等等)
Perl 6 还具有仅部分实现的优点:如果您想破解语言内部或帮助定义标准库,这是开始的好时机Perl 6.
编辑:(2011) 现在仍然是破解 Perl6 内部结构的好时机,但现在有一个更成熟、可用的 Perl6 发行版,Rakudo Star。 如果您今天想使用 Perl6,那是一个不错的选择。
Python has a major advantage of being available in a production-ready format today.
Python has Jython and IronPython, if you need to work closely with Java or the .net clr.
Perl 6 has the advantages of being based on the same principles as Perl (1-5); If you like Perl, you'll like Perl 6 for the same reasons. (There's more than one way to do it, etc.)
Perl 6 also has an advantage of being only partially implemented: If you want to hack on language internals or help to define the standard libraries, this is a great time to get started in Perl 6.
Edit: (2011) It's still a great time to hack on the Perl6 internals, but there is now a much more mature, usable Perl6 distribution, Rakudo Star. If you want to use Perl6 today, that's a great choice.
您还没有说明为什么要放弃 Perl*。 如果我的水晶球今天起作用了,那是因为你不完全懂这种语言,所以它让你感到沮丧。
坚持使用 Perl 并好好学习这门语言。 如果您这样做,那么有一天您将成为一名大师并知道为什么您的问题无关紧要。 启蒙降临于那些寻求它的人。
You have not said why you want to move away from Perl*. If my crystal ball is functioning today then it is because you do not fully know the language and so it frustrates you.
Stick with Perl and study the language well. If you do then one day you will be a guru and know why your question is irrelevant. Enlightment comes to those to seek it.
IMO python 的正则表达式,尤其是。 当您尝试表示像
s/whatever/somethingelse/e
中那样的 perl 的 /e 运算符时,变得非常慢。 因此,如果有疑问,您可能需要继续使用 Perl5 :-)IMO python's regexing, esp. when you try to represent something like perl's /e operator as in
s/whatever/somethingelse/e
, becomes quite slow. So in doubt, you may need to stay with Perl5 :-)