如何評價即將正式 release 的 GHC 8.2.1 ?

[ANNOUNCE] GHC 8.2.1 release candidate 1

* A new type-indexed Typeable implementation

* The long awaited Backpack

* Deriving strategies for disambiguating DeriveAnyClass,

GeneralizedNewtypeDeriving, and stock mechanisms

* Overloaded record fields

* Improved compiler performance

* Better code generation through more robust tracking of join points

* Compact regions for more efficient garbage collection and serialization

* Better support for machines with non-uniform memory architectures

* More robust support for levity (e.g. RuntimeRep) polymorphism

* A simple interface for streaming eventlog data from live processes

* Further refinement of DWARF support

感覺都是大新聞啊


1. Backpack 系統從 Edward Z. Yang 的代碼 merge 進 HEAD 以後我就試用過了——簡而言之,Haskell module 也有了 module signature,可以 instantiate,可以像 ML module system 一樣進行抽象。雖然現在的 Haskeller 已經有了許多抽象手段,Backpack 在一些情況下還是能發揮作用的——比如需要同時面向多個 backend 編譯的代碼,目前 ghcjs 做了很多 dirty hack 來讓一些常用 package 能夠編譯通過,而用戶自己開發的 package 也需要一些 Cabal hack/CPP macro 等東西來讓一個 module 同時在不同 backend 上 work 起來,而 backpack 可以提供「同一個 module signature、不同實現」,能夠非常 neat 地解決這個問題。

2. Overloaded record fields 進一步增強了,之前的版本雖然允許 duplicate record field,但是類型簽名上並沒有 overload。很實用。不過考慮到 API 兼容性的話,也許手動實現 classy lens 會更好一些。。

3. join points 優化的工作來自《Compiling without continuations》一文,我沒有細看,據說性能提升許多。/r/haskell 之前就有不少人抱怨 GHC 狂搞新特性,性能每況愈下,看樣子 8.2.1 有望在性能上有突破。

4. Compact region 的工作來自《Efficient Communication and Collection with Compact Normal Forms》一文,實現以後能節省許多 serialize/deserialize 的開銷(直接 memcpy 服不服),對工業 Haskell 代碼非常有幫助

5. type-indexed Typeable 的工作來自《A reflection on types》,是 SPJ 等人給 Philip Wadler 祝壽時寫的,目前新的 Typeable interface 在 base 中的 Type.Reflection 已經可以使用了。有了類型標籤的 TypeRep 的確比原來那個沒有標籤的更加順眼(

總的而言,是個令人期待的 release。


幾乎和 @Canto Ostinato 說的完全相反的是,GHC 開發者 Wiki 上表明,GHC 8.2 不會出現太多新的大功能。講個笑話,Status/GHC-8.2.1 - GHC

We expect GHC 8.2 to be principally a consolidation release, in which we settle down and flesh out existing features, rather than introduce major new features. In particular, we would like to work on performance, especially of the compiler itself.

還是可以看出,GHC 8.2 的編譯速度應該會有比較顯著的改進的。


推薦閱讀:

OCaml在寫編譯器上比Haskell好在哪?為何Rust第一個版本採用了OCaml?
如何評價eta-lang?
對大量使用 immutable data structure 的語言,其 VM 和 GC 會有何特點?
Haskell適合做網站開發嗎?有什麼優缺點?
如何理解Haskell中的"Proxy Argument Trick"?

TAG:Haskell | GHC編程套件 |