LWN.net Logo

LLVM 3.0 released

LLVM 3.0 released

Posted Dec 13, 2011 20:17 UTC (Tue) by nybble41 (subscriber, #55106)
In reply to: LLVM 3.0 released by dgm
Parent article: LLVM 3.0 released

Both C and C++ are Turing-complete[1], but AFAIK only C++ has a built-in Turing-complete metaprogramming interface at compile time in the form of templates. That can reasonably be considered an extra measure of power. (Retaining one's sanity while attempting any complex computation with C++ templates is left as an exercise for the reader.)

[1] See also: "Turing tarpit" <http://en.wikipedia.org/wiki/Turing_tarpit>


(Log in to post comments)

LLVM 3.0 released

Posted Dec 13, 2011 21:27 UTC (Tue) by mathstuf (subscriber, #69389) [Link]

> only C++ has a built-in Turing-complete metaprogramming interface at compile time in the form of templates

Haskell has Template Haskell[1][2] (it's an extension, but since GHC is pretty much the only compiler for Haskell, that's pretty much moot).

[1]https://en.wikipedia.org/wiki/Template_Haskell
[2]http://www.haskell.org/haskellwiki/Template_Haskell

LLVM 3.0 released

Posted Dec 13, 2011 21:49 UTC (Tue) by nybble41 (subscriber, #55106) [Link]

Sorry, I didn't mean "only C++" in that sense. I was only considering C and C++. Other languages do have decent metaprogramming facilities as well, some (IMHO) much better than C++ templates. Lisp macros, for example, or Scheme's syntax expanders. D's more flexible template system ranks highly as well, though the syntax isn't quite as consistent and it relies on parsing generated strings, rather than constructing syntax objects directly.

LLVM 3.0 released

Posted Dec 14, 2011 1:14 UTC (Wed) by dgm (subscriber, #49227) [Link]

Very interesting reading. I came to the conclusion that C++ templates could be considered a meta-Turing tarpit.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds