Simple language: Golang; A CSP-style concurrency model

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. Python has been developed for several years, and I like its simplicity. Recently looking at Golang, feeling and python very much like, grammar concise, standard type acquaintance, the standard library is the same rich. Quote a text (http://blog.csdn.net/myan/article/details/2028545):
The so-called "magic Language", the main representative works are C + +, Perl, JavaScript and Ruby. These languages have rich features, clever skills and unexpected wonders, always have to explore the artifice, can always find an incredible "yet another way". In turn, "simple language" advocating clear direct, enough on the line, the requirements from the code easy to understand, rather stupid, tired, write a little bit of code, against unexpected skills, against the mysterious. C, PHP, Python and Lua are the masterpieces of the language.

Looks like Golang, too."Simple Language"。
has been using the Python micro-threading (co-process, fiber) development model, to gevent and stackless have a certain understanding. Because Python has a Gil, the actual development of the use of thread is rarely used, then the channel used in stackless some do not understand. Why is it necessary to use channel to communicate in multiple micro-threading? The micro-threading itself is not actually executed concurrently and can be used to communicate in a shared memory manner. So when using Python to develop a project, in order to take advantage of multicore, the project's architecture is generally: micro-threading + multi-process mode. The development of micro-threading using shared memory is indeed relatively simple and convenient.
Recently, when studying Golang, I saw a lot of Golang materials mention CSP ( The principle of "sharing memory through communication, rather than communicating through shared memory")。 Initially did not understand very much, read this information (http://concur.rspace.googlecode.com/hg/talk/concur.html) after Epiphany. In this paper, we demonstrate the concurrency model implemented by CSP and common memory mode with simple and clear diagrams, and the goroutine in Golang can be executed under multiple real threads, thus achieving the purpose of truly utilizing multicore. Although there are some things you might feel about CSP, there are a lot of details to consider if you want to use it in a real project.

Related Article

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.