4 ms·
Are bigger optimizations to be hard in the design of the higher level languages that are easier for compilers to optimize? As an extreme example, I imagine dyn
by vendiddy 6y ago
Are bigger optimizations to be hard in the design of the higher level languages that are easier for compilers to optimize?
As an extreme example, I imagine dynamic languages are hard to optimize because the compiler can make few assumptions about the code.
(Have little knowledge of compilers so correct me if I'm wrong.)
- samus 6y agoHigher level languages often use complex data structures at runtime that are a maze of pointers and thus suffer from bad cache locality. Such languages benefit the most from language-specific high-level optimizations. Haskell for example uses strictness analysis to eliminate pointless lazy evaluation, and loop fusion to combine calls to `filter`, `map` and friends, thereby avoiding building up intermediary lists. A compiler can do very little for dynamic languages. It could try to apply high-level optimizations, but as you say they are few and between, and hard. A Just-in-time compiler that optimizes hot path at runtime is usually the way to go. Unfortunately, they are quite a bit more complex. Most dynamic languages did not have them for a long time.