
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Somebody claiming to be yi huang wrote:
Why prefer code generation over template Haskell? Isn't them essentially the same thing, and template haskell is performed automatically.
Also, from Reddit (nicolast):
I never understood why someone would want to avoid using language extensions which have been in GHC for at least some time. The only reason I can think of is: compatibility with other compilers. But is anyone ever going to compile/run a yesod-routes based application using something other than GHC?!
First off, yes, Template Haskell is very similar to code generation. There are a few reasons I would like to avoid it. It's a language extension. I try to avoid those in general, in every stanardized language I code in (C89, R5RS, Haskell98) for several reasons. As nicolast said, compatibility with other compilers is a big one. When I get a piece of code from someone who assumed that "what MSVC does" or "what Racket does" is the same as "anyone can run this", it makes it quite difficult to use my favourite implementations of those languages. I don't want to make assumptions about other people's environments, or what will be useful in the future. Maybe someone writes a Haskell interpreter that makes use in some context I haven't even imagined much nicer. Who knows. Additionally, any other static analysis/code processing tools (like, say, hlint) *also* needs to support whatever syntax extensions you're using (semantics exceptions may or may not apply here, dependings on the nature of the tool). Requiring that every tool author support all my favourite extensions limits my tool options, and makes life harder for tool authors (since they cannot just look in one place for the spec and write to that anymore if they need to look up compilers' extensions as well). Will anyone ever compile/run/analyze a yesod-routes based application using something other than GHC/hlint? (Actually, does hlint support TH. It might.) What specifically about yesod-routes makes this less likely? What drew me to Yesod.Routes.Dispatch was its relative purity in terms of extensions/dependencies, etc. Additionally, I find Template Haskell specifically (and some other language extensions, like Overlapping Instances) can make code harder to read (for me) and possibly harder to reason about. A code generator makes a file that I can read for comprehension, edit if I want to, etc. Ok, that's a bit of a long answer to a short question, but it sort of sums up my motivation vis extensions in general and TH in particular. - -- Stephen Paul Weber, @singpolyma See http://singpolyma.net for how I prefer to be contacted edition right joseph -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJQI8TfAAoJENEcKRHOUZze3PcP/2uGVP5YnQl2i1uxUIfuxZ0j HBdsdRDXI6XH/XVKPIS0u9JnBheOzDX0EQEeSlUT8AjN8B7vkv7KLnV78hNO349E q9lTZ/gQmonm7jVVwZmGbpRoLJjeQM0kHXUMAA9XOER8j4POD82lSi8mY6skJyqZ Aa1vspnwnCG2IYRjVaa6p8N2FWsnsgZwhj51oLEEqxiVfqiruuU8/rJBbNfA1h4e beeuUA3gNHZcspsRiTc0vMgHjyrmme9TddBm10ZyDVGnI8rpR9la538vaDWLY6es flU5TMdNj3P6rmnzSRmM3kSO9efNS+KYXL4Ip4w8q3SfElaTQXnWerpMGkwUK69j EiHAUG3NKe023xTsAJaXZ26ptAdYtEtlQo/DxE5N92eKsq5s4a/FwnWlIkv3COX2 c8HpTh2RGmuX2l2MVmkwQA0/2zVFUhODRfOjs9UdX9mjOx1peUJZ0DWUGTTsdZPO j9Rr0d0KAJEldMbzBY3K+UugHv4DXVj3VtcH6/QlmCOQj3oh4CPGjBagyqeJNKLM MbIVkk//TD8ZaiFroskAtK8b5FJeiKRTRS7OcR76Plosul8zKMKyPC9LTQ2ER+Ze yTQOO0lh6pqZK36nLAIcTACHxToJ1Q0kVAK1XGubFQCIbcBlh06DhEqTmB07fMjX 5d0duojN6MrBaADjm3xF =sq7x -----END PGP SIGNATURE-----