Python 대 Perl 토론에 대해 자세히 알아보기-Python 또는 Perl을 어떻게 배워야합니까?
종종 새로운 프로그래밍 언어가 소개 될 때, 업계의 천재 정신들 사이에서 시작되는 논쟁이 있는데, 그 언어는 이미 뿌리를 펴고있는 언어와 비교됩니다. 일종의 버즈가 IT 산업에서 자주 퍼지고 새로운 것은 GC 시간 등을 포함한 모든 측면에서 기능, 구문 또는 코어 CPU 및 메모리 측면을 기존의 것과 비교하는 경우가 많습니다.
자바와 C #, C ++ 등의 논쟁을 포함하여 과거로부터 그러한 사례의 많은 사례를 포착하고 조사 할 수 있습니다. 상당한 관심을 끌었던 사례 중 하나는 두 언어 사이의 논쟁이었습니다. "짧은 범위, 즉 Python 및 Perl.
Python은 처음에 ABC 언어의 후계자로서 그의 가장 큰 스타 인 Monty Python 시리즈의 이름을 따서 명명 한 저자의 \"취미\"프로그래밍 프로젝트 (유닉스/C 해커를 끌어들일 것임)로 발명되었습니다.
Perl은 보고서 처리를 더 쉽게하기위한 Unix 스크립팅 언어로 거의 2 년 전에있었습니다. C, awk, sed 및 shell 스크립트를 포함한 많은 언어의 조합이었습니다.
주목할 가치가있는 것은 서로 다른 의도로 진화 한 이러한 언어들이 지속적으로 비교되고 있다는 것입니다. 그 이유는 저를 연구하고 그 이유를 알아 내도록 만들었습니다. 그 이유는 다음과 같습니다.
- Both targeted Unix Operating System, one for hackers and others to process reports.
- Both are object-oriented (Python being the more) and interpreted, with one being strongly typed and clear when it comes to coding i.e. Python, and other allowing ugly typing with braces for representing a block i.e. Perl
- Both are opposite in principle when we say, Perl has many ways of doing a single task while python focuses on one and only one way of doing things.
Python 대 Perl – 기능 비교
이 토론에 대해 자세히 살펴보고이 두 언어가 서로 다른 전체적인 측면을 파악해 보겠습니다. 또한 업계에서“Python은 훈련 휠이있는 Perl입니다”또는“Python은 Perl과 비슷하지만 다릅니다”라는 말을 업계에서들을 수있는 많은 진부함에 대한 진실의 근원을 찾아서 정확한 해결책으로 시도하고 결론을 내릴 수 있도록합시다. "이 끝없는 논쟁에.
Python은 코드 가독성과 관련하여 Perl보다 큰 이점이 있습니다. Python의 코드는 수년 후에 코드를 읽을 때에도 Perl의 코드보다 이해하기 훨씬 더 명확합니다.
코드 블록을 나타내는 들여 쓰기와 적절한 구조화를 통해 Python의 코드는 훨씬 깔끔합니다. 반면에 Perl은 정규 표현식과 관련하여 C, 쉘 스크립팅, 심지어 awk 및 sed 필터와 같은 다양한 프로그래밍 언어에서 구문을 차용합니다.
이 외에도 코드 블록을 나타내는 '{'및 '}'
와 각 줄 끝에 ';'
를 불필요하게 추가하면 Perl의 코드는 추악한 스크립팅을 허용하기 때문에 몇 달 또는 몇 년 후에 읽으면 이해해야 할 문제입니다.
Perl 언어는 C 및 sed, awk 등과 같은 기타 UNIX 명령에서 구문을 차용합니다. 이로 인해 타사 모듈을 가져 오지 않고도 강력하고 내장 된 정규식 지원이 가능합니다.
또한 Perl은 내장 함수를 사용하여 OS 작업을 처리 할 수 있습니다. 반면에 Python에는 작업을위한 타사 라이브러리가 있습니다.
Perl의 정규식 연산은 검색 연산뿐만 아니라 문자열에 대한 대체, 대체 및 기타 연산을 쉽게 수행 할 수있는 구문과 같은 'sed'를 가지고 있으며, 사람이 원하는 기능을 알고 기억해야하는 파이썬보다 쉽고 빠르게 수행 할 수 있습니다. 필요.
예 : Perl과 Python의 문자열에서 숫자를 검색하는 프로그램을 생각해보십시오.
Import re str = ‘hello0909there’ result = re.findall(‘\d+’,str) print result
$string = ‘hello0909there’; $string =~ m/(\d+)/; print “$& \n”
Perl의 구문은 타사 모듈 're'를 가져 오는 Python의 구문을 활용하는 sed 명령에서 영감을 받아 매우 쉽고 영감을 받았습니다.
Python이 Perl을 무시하는 한 가지 기능은 고급 OO
프로그래밍입니다. Python은 깔끔하고 일관된 구문으로 광범위한 객체 지향 프로그래밍을 지원하는 반면 Perl의 객체 OOP
는 패키지가 클래스 대신 사용되는 구식입니다.
또한 Perl에서 OO
코드를 작성하면 코드가 훨씬 더 복잡해져 결국 코드를 이해하기 어렵게 만들 수 있습니다. 심지어 Perl의 서브 루틴도 프로그래밍하기가 매우 어렵고 나중에 이해하기 어렵습니다.
반면에 Perl은 다양한 작업을 수행하기 위해 명령 줄에서 사용할 수있는 한 줄에 가장 적합합니다. 또한 Perl 코드는 결국 파이썬보다 적은 코드 줄로 다양한 작업을 수행 할 수 있습니다.
더 적은 LOC로 더 많은 작업을 수행 할 수있는 Perl 기능을 강조하는 두 언어의 단축 코드 예 :
try: with open(“data.csv”) as f: for line in f: print line, except Exception as e: print "Can't open file - %s"%e
open(FILE,”%lt;inp.txt”) or die “Can’t open file”; while(<FILE>) { print “$_”; }
장단점 – Python 대 Perl
이 섹션에서는 Python과 Perl의 장단점에 대해 설명합니다.
- It has a clean and elegant syntax which makes this language a great choice as the first programming language for novices who want to have hands-on on any programming language.
- Has very advanced and inherent
OO
Programming, also thread programming in Python is way better than Perl. - There are many application areas where Python is preferred and even it outperforms Perl. Like: Perl is preferred for CGI scripting but nowadays Python’s Django and web2py like web scripting languages are becoming more popular and have a huge attraction from the industry.
- Has several SWIG wrappers for different programming languages like CPython, IronPython and Jython and development of these has preceded the development of SWIG wrappers for Perl.
- Python code is always well indented and easy to read and understand even if you are reading someone else’s code or even your code after years.
- Python is good for various applications like Big Data, Infra Automation, Machine Learning, NLP, etc, it has huge support of active communities because of being Open Source.
- There are few areas where execution in Python is usually slower than that of Perl including regex and string-based operations.
- Sometimes it is difficult to get the type of variable in Python as in cases of very large code, you have to go till the end to get a type of variable that gets hectic and complex.
- Perl has powerful one-liners and even ensures UNIX piping like syntax which can be used on the command line to perform various tasks, also it is influenced by Unix and its command-line programming so integrates many UNIX influenced commands in its coding.
- Perl is known for its powerful regex and string comparison operations as it is influenced by sed and awk like powerful UNIX tools. In the case of regex and string operations like substitution, matching, replacement, Perl outperforms python which would take a few lines of code to achieve the same. Also many file I/O operations, exception handling is done faster on Perl.
- When it comes to a language for report generation, Perl has always been in fame since its introduction as one of the main reasons for the author to develop language like Perl was for report generation.
- Many application areas where Perl finds its use are Network Programming, System Administration, CGI Scripting (here Python is overcoming Perl with Django and web2py), etc.
- It is easy to identify the type of variable with the symbols that Perl uses before them, like:
‘@’
identifies arrays and‘%’
identifies hashes.
- Perl has a very complex code which makes it difficult to understand for a novice. Subroutines, and even other symbols like:
‘$`’
,‘$&’
etc are hard to understand and program for a less experienced programmer. Also, Perl code when read would be difficult and complex to understand unless you have a quality experience. - OO Programming in Perl is a bit out of date as it has never been known for OO programming and many operations like threading are also less pronounced on Perl.
결론
위에서 볼 수 있듯이 두 언어가 대상 응용 프로그램에 대해 좋은 점에서 볼 수 있듯이 Python은 깔끔하고 이해하기 쉬운 코드로 인해 초보자를위한 첫 번째 선택으로 Perl보다 약간 유리한 반면 Perl은 Python보다 성능이 뛰어납니다. 문자열 조작 작업과 OS와 같은 UNIX 용 고급 원 라이너 및 기타 다양한 작업에 관해서는 잘 알려져 있습니다.
결국, 그것은 모두 당신이 목표로하는 특정 지역에 달려 있습니다. 이 기사에 대한 모든 의견은 환영하며 Python이 승리하거나 Perl에 따라 주제에 대한 의견을 제시하도록 요청합니다.