Python与Perl的简单比较.ppt

上传人:小飞机 文档编号:6516447 上传时间:2023-11-08 格式:PPT 页数:13 大小:313KB
返回 下载 相关 举报
Python与Perl的简单比较.ppt_第1页
第1页 / 共13页
Python与Perl的简单比较.ppt_第2页
第2页 / 共13页
Python与Perl的简单比较.ppt_第3页
第3页 / 共13页
Python与Perl的简单比较.ppt_第4页
第4页 / 共13页
Python与Perl的简单比较.ppt_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《Python与Perl的简单比较.ppt》由会员分享,可在线阅读,更多相关《Python与Perl的简单比较.ppt(13页珍藏版)》请在三一办公上搜索。

1、廖海仁,Python与Perl的简单比较,语言简介,Perl,Python,由C/sed/awk/shell演化而来适合文本处理、系统管理,不适合操作系统开发、多线程编程,从ABC语言继承而来,主要受Modula-3影响,结合Unix shell与C的习惯面向对象、解释性、胶水语言,优 点,Perl,Python,强大的正则表达式匹配功能复杂灵活的数据结构Unicode支持(相对AWK/C)自然语言(也是缺点)智能语言(也是缺点),简单、易学高层语言可移植性面向对象规范的代码(可读性强)图形功能(GUI)数值计算功能(NumPy),缺 点,Perl,Python,自然语言,代码晦涩难懂智能语言

2、,可能产生臆断,编程陷阱多不是很优美,很多方法做事,有时让编程者无所适从动态类型语言,不是很可靠,性能问题不适合多线程、底层编程、GUI编程易学难精,强行缩进运行速度不够快(比较编译型语言)动态语言、解释型语言,调试困难(Perl不完全是解释型的),创始人,Larry Wall(Perl)Larry Wall,Guido van Rossum(Python),Languist(语言学家)PerlMany ways to accompany the same task Constructs interact in context-sentitive and sometimes quite sub

3、tle ways mush like natural language,Mathematician(数学家)Python:High degree of uniformityOrthogonal design,设计理念,Design Principle of Perl,Zen of Python(Tim Peters),Theres More Than One Way To Do ItEasy things should be easy,and hard things should be possible,Beautiful is better than ugly.Explicit is bet

4、ter than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases arent special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly si

5、lenced.In the face of ambiguity,refuse the temptation to guess.There should be one-and preferably only one-obvious way to do it.Although that way may not be obvious at first unless youre Dutch.Now is better than never.Although never is often better than*right*now.If the implementation is hard to exp

6、lain,its a bad idea.If the implementation is easy to explain,it may be a good idea.Namespaces are one honking great idea-lets do more of those!,Fundamental principles of human language(I),Expressiveness is more important than learnabilityIts quite OK to speak in“baby talk”if you happen to be a babyA

7、 language can be useful even before you have learned the whole languageThere are often several good ways to say roughly the same thingEvery linguistic utterance gets meaning from many contexts at onceEffiicent communication requires a certain amount of linguistic complexitySemantic networks do not g

8、ennerally map well into orthogonal spacesShortcuts abound;common expressions should be shorter than uncommon expressions,Fundamental principles of human language(II),Not everything can be easy to express;its OK if some things are hard but possibleLanguages are naturally punctuated by pauses,intonati

9、on,stress,pacing,etc.Healthy culture is more important than specific technology to a languages successIts OK to speak with an accent as long as you can make yourself understoodFor any living language,evolution is not preventable over the long termIts particularly important for written documents to b

10、e evaluated in historical context.,Perl or Python?,Perl拥护者,Python拥护者,正则匹配的近乎完美语言,You can do everything in Python that you can in Perl,but you can read your code after you do it简单易学,Perl 6 Vs Python 3,Perl 6,Python 3,Resign of the whole language,Not a total rewrite or a total resign,though a break wi

11、th backward compatibility,Data Structures,Perl,Python,Scalars ArraysHashes(Perl treat everything as mutable),NumbersStringsListsDictionaries/SetsTuples(Immutable Lists),关于Python的两个问题,数值与字符串(对应Perl 之Scalar)参数传递方式(like Java,按值传递对象引用)实例:def changer(a,b):a=2 b0=spam b=3,4 X=1 L=1,2 changer(X,L)X,L,Python印象,Java:异常机制/OOP/参数传递C+:多重继承,运算符重载Perl:Arrays,Lists,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号