C ++ functional programming (1)

Source: Internet
Author: User

Original article: http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/

Author: John Carmack

-Pan Hong

-March January 2013

-Email: popyy@netease.com

-Weibo.com/panhong101

You may have heard that "functional" programming can bring many advantages to software development, and many even regard it as a "silver bullet" in software development ". However, if you look at functional programming entries in Wikipedia, you will find a lot of academic things, such as lambda expressions and formal systems. It seems that these functions are not directly related to the help of functional programming for software development.

Experience tells me that many problems arising from software development are due to the fact that programmers do not know all the execution statuses of the program. In multi-threaded development, such problems and their consequences are even more serious, which is enough to make developers feel the project crisis. Functional Programming makes the code execution status clearer, makes it easier to deduce the program execution status, and makes the thread not competing in the ideal environment.

Although I think it is valuable to learn functional programming, it allows you to immediately put down the C ++ compiler, and then put it into the arms of lisp, Haskell, or other messy languages, I think this is irresponsible. For Language designers who have been suffering for a long time, many external factors offset the advantages of the language itself. The game development field is even worse: Except for the code library maintenance and human resources problems that every company needs to solve, game Development also solves many problems such as cross-platform, tool chain, authentication gateway, license technology, and high performance requirements.

If your work allows you to use a non-mainstream language for development, I am happy for you and remind you: be prepared to meet the pressure on the progress. For developers who cannot select any language at work, functional programming will benefit you no matter what language you are using. You should use it when it brings convenience to development, and think about whether it should be used when it cannot provide convenience. Once you finally select it, you can start to learn lambda, monad, currying, and infinitely concentrated compound latency Valuation Functions.
And all other functional-oriented programming aspects.

C ++ does not advocate functional programming, but also provides related methods to support it. This allows you to use functional programming while still using powerful underlying functions to achieve your needs. For example, you can use the SIMD instruction set to process the data layout of memory ing files, or any other functions you need to implement.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.