일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 블록체인
- 스칼라 강좌
- 파이썬 데이터분석
- Hyperledger fabric gossip protocol
- 스칼라
- 스칼라 동시성
- Play2 로 웹 개발
- 파이썬
- 엔터프라이즈 블록체인
- play2 강좌
- Actor
- hyperledger fabric
- 주키퍼
- Adapter 패턴
- 이더리움
- 스위프트
- CORDA
- 파이썬 강좌
- 플레이프레임워크
- Akka
- 하이브리드앱
- 하이퍼레저 패브릭
- 안드로이드 웹뷰
- Golang
- play 강좌
- 파이썬 동시성
- akka 강좌
- 파이썬 머신러닝
- Play2
- 그라파나
- Today
- Total
HAMA 블로그
인터프리터 언어는 컴파일 언어보다 느린가? 본문
파이썬은 왜 느릴까? 느린가? (파이썬 종류에 따라서 천차만별임을 염두..)
https://medium.com/@cookatrice/why-python-is-slow-looking-under-the-hood-7126baf936d7
https://hbfs.wordpress.com/2009/11/10/is-python-slow/
왜 항상 자바는 c++ 보다 느릴까? (언제 쓰여진건지 모르겠군요. 항상이란 말이 좀 깨림칙...)
http://sungpi.postach.io/post/wae-hangsang-jabajavaneun-c-boda-neuringa
왜 인터프리트 언어는 컴파일언어보다 느릴까?
http://stackoverflow.com/questions/1694402/why-are-interpreted-languages-slow
http://stackoverflow.com/questions/7991877/why-is-an-interpreter-slower-than-a-compiler-in-practice
C++ VS Python 속도비교
http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/
http://www.matthiaskauer.com/2014/02/a-speed-comparison-of-python-cython-and-c/
스택 오버플로우의 답변 중 하나
All answers seem to miss the real important point here. It's the detail how "interpreted" code is implemented.
Interpreted languages are slower because their method, object and global variable space model is dynamic. This requires many many extra hash-table lookups on each access to a variable or method call. This is where most of the time is spent. It is a painful random memory lookup, which really hurts when you get a L1/L2 cache-miss.
Google's Javascript Core8 is so fast and targeting almost C speed for a simple optimization: they take the object data model as fixed and create internal code to access it like the data structure of a native compiled program. When a new variable or method is added or removed then the whole compiled code is discarded and compiled again.
The technique is well explained in the Deutsch/Schiffman paper "Efficient Implementation of the Smalltalk-80 System".
The question why php, python and ruby aren't doing this is pretty simple to answer: the technique is extremely complicated to implement.
And only Google has the money to pay for JavaScript because a fast browser-based JavaScript interpreter is their fundamental need of their billion dollar business model.
가장 심플한 답변
A compiled language like C is usually compiled directly into machine code. When you run the code, it is executed directly by the CPU.
A fully interpreted language like BASIC or PHP is usually interpreted each time it runs. When you execute your code, the CPU executes the interpreter, and the interpreter reads and executes your source code. (PHP can be classified as fully interpreted, since while it does use opcodes, they are usually thrown away after the execution.)
A bytecode interpreted language like Python, is compiled from source code to bytecode that is executed by a virtual machine. The CPU runs the VM, and the VM executes each bytecode instruction. In Python, the bytecode is compiled the first time code is executed.
In Java, bytecode is compiled ahead of execution. The Java VM also has a special feature called Just-in-time compilation. This means that during execution, it may compile some of the bytecodeto machine code, which it can send to the CPU to execute directly.
In conclusion, with compiled languages, the CPU runs the code directly. In interpreted languages, the CPU usually runs the interpreter or virtual machine. This makes interpreted languages generally slower than compiled languages, due to the overhead of running the VM or interpreter.
NOTE: While we speak of interpreted and compiled languages, what we are really discussing is the usual execution style of a language. PHP can be compiled (using HipHop), and C can be interpreted (using Parrot VM).
'소프트웨어 사색 ' 카테고리의 다른 글
jemalloc 이란? (0) | 2015.09.09 |
---|---|
소프트웨어 개발/코딩용 폰트 끝판왕들~ (0) | 2015.09.08 |
정규표현식 (Regex) 정리 (10) | 2015.07.23 |
주요 오픈소스 라이센스 (0) | 2015.06.26 |
Actor 패턴 ? ActiveObject 패턴 ? with AKKA (0) | 2015.05.15 |