나는 왜 PHP보다 Python을 좋아하는가? 깔끔한 문법이 일단 매력이지만 그게 다가 아니다.
기능 비교 (( http://en.wikipedia.org/wiki/First-class_function, http://en.wikipedia.org/wiki/List_comprehension, http://en.wikipedia.org/wiki/Mixin ))
일단은 언어의 강력함에서 큰 차이를 보인다. 생산성에 신경쓰는 언어들이라면 당연히 지원해 줄 법한 기능들에 대해 PHP는 너무나도 무심하다.
PHP | Perl | Ruby | Python | ||
---|---|---|---|---|---|
Higher-order functions | Arguments | Yes | Yes | Yes | Yes |
Results | Yes | Yes | Yes | Yes | |
Non-local variables | Nested functions | No (( Nested functions are created at global scope once the outer function is executed. )) | 6 | Yes | Yes |
Anonymous functions | 5.3 | Yes | Yes | Yes | |
Closures | 5.3 (( Anonymous functions could be created using create_function but could not refer to variable in the outer scope. )) | Yes | Yes | Yes | |
Partial application | No | 6 | 1.9 (( Explicit currying with Proc#curry )) | 2.5 (( Explicit partial application with functools.partial )) | |
List comprehension | No | No | No | Yes | |
Mixin | No | 6 | Yes | Yes |
Anonymous functions와 Closures를 PHP 5.3에서 지원하기는 하지만 그 기능을 웹애플리케이션을 개발할 때 사용하기엔 PHP 5.3이 너무 최근(2009년)에 나왔다. 내 애플리케이션의 요구사항을 PHP 5.3 이상으로 하는 것은 시기상조다.
성능 비교
아래의 링크를 보면 모든 테스트케이스에서 python이 php보다 훨씬 좋은 성능을 보인다. pypy나 psyco를 사용한다면 상대가 안되는 수준이 될 듯.
- 여러 언어 성능 비교: http://shootout.alioth.debian.org/
- python, php, perl 성능 비교: http://www.skitoy.com/p/performance-of-python-php-and-perl/160
- java, c++, ruby, python, groovy, php 성능 비교: http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/
- php, ruby, tcl, perl, python, mzscheme, gcj, gcc 성능 비교: http://scutigena.sourceforge.net/
성능비교 링크들이 비교적 매우 오래된 내용을 담는 것들이군요.
좋아요좋아요
@지나가다
얼마나 오래된 것인가를 판단하지는 않았고, 구글링해서 상위에 나오는 몇몇 벤치마킹 결과를 링크했습니다. 2003년 자료도 있고 2011년에 릴리즈된 python 3.2로 벤치마킹한 자료도 있습니다.
좋아요좋아요