Which functional programming language is suitable as a precursor to learning C++ template metaprogramming?
-
Related question: This and the related questions are different approaches that can be taken in the path of learning C++ template metaprogramming. Focus: This question posits that it may be easier if one has previous exposure to one other functional programming language, and then asks which language it would be. Clarification: these questions do not ask about basic use of C++ templates. These questions aim to prepare a C++ library developer to make use of the compile-time facilities in C++ template metaprogramming for the purpose of synthesizing (weaving) optimized code, where a high level of confidence of correctness can be attained. Background information: Recently I developed a C++ metaprogramming library that synthesizes bit permutation functions (executable code) given the hypercube permutation specification (in BPC notation - see http://programming.sirrida.de/bit_perm.html ). However, the resulting code base is inelegant, in part because the intended application project decides against including Boost MPL into the build. Only a handful of MPL functions would be needed, but I would have to write my own. Having no functional-programming background, I find this to be even harder to do, compared to the writing of the first draft of this permutation library. Concrete examples encountered in the background: A sequence of types, supporting up to 8 arguments. A fold metafunction for a binary operation (int, int -> int) for up to 8 arguments. The integers may be either integers, or http://en.cppreference.com/w/cpp/types/integral_constant A metafunction for inverting an array permutation. See my other question about:
-
Answer:
I'm currently taking Functional Programming Principles in Scala on Coursera, the professor is the designer of Scala. I am new to Functional Programming(FP) and find it very alien to my former understanding of programming. As I followed the classes, the thought pattern in FP reminds me of C++ metaprogramming quite often despite the fact that I don't know the intimate relationship between them until reading the question. Taking this class(and the book by the same author) helped me a lot think in FP paradigm.
Jian Peng at Quora Visit the source
Other answers
Lisp + HTML?
Dima Korolev
Xslt gave me a lot of insight into the subject
Lance Diduck
Indeed, C++ Template metaprogramming is basically a functional language, albeit a very obfuscated one. does an excellent job comparing C++ and Haskell, often finding brilliant ways to apply Haskell concepts to simplify difficult C++ problems, some prime candidates being non-obvious uses of template metaprogramming (like Boost proto's implementation). For an example see his http://bartoszmilewski.com/2011/07/11/monads-in-c/ blog post. Bartosz shows the similarity between Haskell and C++ TMP in the following video: http://vimeo.com/7211030. All great and exciting stuff. Thanks Bartosz for your contributions!
Gregory Popovitch
Related Q & A:
- How to make the transition to functional programming?Best solution by Programmers
- What is a "modern" programming language?Best solution by Quora
- Which is the best programming language?Best solution by Yahoo! Answers
- How to become a good programmer in C language?Best solution by Quora
- Is java or visual basic a machine level, low level, high level or binary level programming language?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.