Difference between revisions of "GPU621/Go Parallel"
(→Go (Language) Parallel Programming) |
|||
Line 54: | Line 54: | ||
− | === Concurrency === | + | === Concurrency and Parallelism === |
+ | Go was designed for concurrency. “Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once.” [https://blog.golang.org/waza-talk] - Rob Pike (One of the programmers of Go). Concurrency is '''NOT''' parallel programming. | ||
− | === | + | Quoting [https://docs.oracle.com/cd/E19455-01/806-5257/6je9h032b/index.html Sun's ''Multithreaded Programming Guide''] on the Oracle Documentation website - |
+ | |||
+ | '''Parallelism''' is defined as: | ||
+ | |||
+ | Parallelism - A condition that arises when at least two threads are executing simultaneously. | ||
+ | |||
+ | While '''Concurrency''' is defined as: | ||
+ | |||
+ | Concurrency - A condition that exists when at least two threads are making progress. A more generalized form of parallelism that can include time-slicing as a form of virtual parallelism. | ||
+ | |||
+ | ==== But what about Go? ==== | ||
+ | |||
+ | As stated above, Concurrency is '''NOT''' parallel programming. But working with both is very easy to do in Go. | ||
+ | |||
+ | A big thing to note about Go is the 'goroutines' which is what allow programmers to run functions or methods concurrently. | ||
+ | |||
+ | go function_name(parameters) | ||
+ | |||
+ | Using the key term 'go' allows the program to run concurrently, '''BUT''' in order for your program to run in parallel you can use the key term 'GOMAXPROCS' | ||
+ | |||
+ | func GOMAXPROCS(n int) int | ||
+ | |||
+ | 'GOMAXPROCS' allows the programmer to specify the '''MAX''' amount of CPU's that will be executing code simultaneously. By default, GOMAXPROCS is set to the number of cores available. | ||
+ | |||
+ | |||
+ | If you're more interested in the differences between Concurrency and Parallelism we found a great explanation here: https://stackoverflow.com/a/24684037/8644993 | ||
== Differences == | == Differences == | ||
Line 68: | Line 94: | ||
== Relevance == | == Relevance == | ||
− | === Present === | + | === Present and Future === |
+ | |||
+ | Presently C++ is a language that is so intertwined with programming it would be hard for any language to surpass it in terms of relevance. Many systems/programs depend on C++ for core functionality and because the technology world moves/evolves so quickly it is hard for programmers to transfer systems over to a new language without encountering major issues. | ||
+ | |||
+ | ==== But what do the people say? ==== | ||
+ | But that doesn't mean that Go isn't used today, on Tiobes Programming Language Index [https://www.tiobe.com/tiobe-index/] C++ is currently in fourth place, Go is 13th. The difference? C++ hasn't made any movement from 4th place for an entire year, while Go last year of November 2019 was at the 20th place, It has gone up 7 places in just 1 year. | ||
− | === | + | Stack Overflow has also released their 2020 Developer Survey[https://insights.stackoverflow.com/survey/2020] and the results show that currently for the most loved languages, Go is in 5th place and C++ is 18th. In terms of popularity C++ is 10th place while Go is 12th. |
+ | |||
+ | And obviously major companies have already begun incorporating Go into their projects such as Google, YouTube, Uber, Intel, and Heroku. | ||
+ | |||
+ | ==== What's the future like? ==== | ||
+ | The future looks bright for Go and it's gaining traction quick. Since it's a language that was literally meant to be a replacement for these older languages like C++ it definitely has the edge when incorporating new technologies that are introduced because of hardware advancements (Such has multi-core CPU's). | ||
== Pros and Cons == | == Pros and Cons == | ||
− | === Pros | + | === Pros === |
+ | 1. Tons of support | ||
− | === Cons | + | 2. Ease of use |
+ | |||
+ | 3. Major companies support it (Google) | ||
+ | |||
+ | 4. Better security integrations | ||
+ | |||
+ | === Cons === | ||
+ | 1. Lack of versatility | ||
+ | |||
+ | 2. Young language | ||
+ | |||
+ | 3. Lacks speed compared to C++ (But is much faster than other high-level languages) | ||
+ | |||
+ | 4. Smaller Community | ||
+ | |||
+ | |||
+ | More about the pros and cons can be found at: https://www.geeksforgeeks.org/go-vs-c-plus-plus/ | ||
== Why should you Go Parallel? == | == Why should you Go Parallel? == | ||
+ | |||
+ | While currently C++ is generally a better language to learn parallel programming concepts from, and is also more used within the programming industry. Go is gaining popularity quickly and with the creation of Go meant to improve upon C++ weaknesses the future of Go is looking very good. Parallel programming in Go is extremely easy and has built in support for it (No need to go through any installation https://ict.senecacollege.ca/~gpu621/pages/content/suppo.html). In addition Go is a fun language to learn and could seriously be used over many of the other high-level programming languages. | ||
+ | |||
+ | |||
+ | A major thing to remember is that during Go's creation, multi-core CPU's were currently being made and popularized. This is very advantageous over C++ since in 1979 multi-core CPU's were unheard of and the first multi-core CPU was introduced in 2001. | ||
= Group Members = | = Group Members = | ||
Line 89: | Line 147: | ||
Update 2: Friday, Nov 13, 2020 - Created description for Go Language | Update 2: Friday, Nov 13, 2020 - Created description for Go Language | ||
+ | |||
+ | Update 3: Sunday, Nov 15, 2020 - Created Installation Instructions | ||
+ | |||
+ | Update 4: Sunday, Nov 15, 2020 - Created Pros and Cons | ||
+ | |||
+ | Update 5: Tuesday, Nov 17, 2020 - Created 'Why you should Go Parallel' | ||
+ | |||
+ | Update 6: Thursday, Nov 19th, 2020 - Added all parts of project onto project website | ||
+ | |||
+ | Update 7: Thursday, Nov 19th, 2020 - Added Pictures to Installation Instructions | ||
= References = | = References = | ||
− | https://golang.org/doc/faq | + | https://golang.org/doc/faq |
https://software.intel.com/content/www/us/en/develop/blogs/go-parallel.html | https://software.intel.com/content/www/us/en/develop/blogs/go-parallel.html | ||
https://talks.golang.org/2012/splash.article | https://talks.golang.org/2012/splash.article | ||
+ | |||
+ | https://golang.org/pkg/runtime/#GOMAXPROCS | ||
+ | |||
+ | https://docs.oracle.com/cd/E19455-01/806-5257/6je9h032b/index.html | ||
+ | |||
+ | https://stackoverflow.com/a/24684037/8644993 | ||
+ | |||
+ | https://www.tiobe.com/tiobe-index/ | ||
+ | |||
+ | https://brainhub.eu/blog/biggest-companies-using-golang/ | ||
+ | |||
+ | https://insights.stackoverflow.com/survey/2020 | ||
+ | |||
+ | https://github.com/golang/go/wiki/GoUsers | ||
+ | |||
+ | https://www.geeksforgeeks.org/go-vs-c-plus-plus/ | ||
+ | |||
+ | https://careerkarma.com/blog/go-vs-c-plus-plus/ | ||
+ | |||
+ | http://www.cplusplus.com/info/history/ |
Revision as of 21:15, 19 November 2020
GPU621/DPS921 | Participants | Groups and Projects | Resources | Glossary
Contents
Go (Language) Parallel Programming
Description
Our team wants to demonstrate the usefulness of the Go programming language while applying Parallel programming principles. Demonstrations of the difference in time, syntax, and ease of use will be included within the document. The topic of whether using a newly created language like Go compared to an older language like C++ will make a difference in terms of future popularity will also be a key point in our report. Success for this project means displaying the differences between the two languages and educating other students about the possibility to use different languages to do parallel programming
What is Go?
As explained in the Go official website "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software"[1]. Created on a whiteboard in 2007 which later became open source in 2009. Go is the collaboration of many different programmers that were tired of the choices that they had to make between languages. Either they chose efficient compilation, efficient execution, or ease of programming; no mainstream languages had all three of these characteristics. Thus Go was created, a language that would combine all three of these characteristics into one. A main point brought up in Go's Creations was "It must be modern. C, C++, and to some extent Java are quite old, designed before the advent of multicore machines, networking, and web application development. There are features of the modern world that are better met by newer approaches, such as built-in concurrency"[2] which means that at its core, Go supports multicore parallel programming.
Installation
Installing Go is simple! Follow these simple steps or go to the official install documentation
1. Download Go
Find your operating system at https://golang.org/dl/ and download the Go Language
2. Install Go
Open the file and follow the prompts
3. You're done!
Go is now downloaded and installed on your machine, to test if the installation worked properly, go into your command prompt and enter 'go version'
Concurrency and Parallelism
Go was designed for concurrency. “Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once.” [3] - Rob Pike (One of the programmers of Go). Concurrency is NOT parallel programming.
Quoting Sun's Multithreaded Programming Guide on the Oracle Documentation website -
Parallelism is defined as:
Parallelism - A condition that arises when at least two threads are executing simultaneously.
While Concurrency is defined as:
Concurrency - A condition that exists when at least two threads are making progress. A more generalized form of parallelism that can include time-slicing as a form of virtual parallelism.
But what about Go?
As stated above, Concurrency is NOT parallel programming. But working with both is very easy to do in Go.
A big thing to note about Go is the 'goroutines' which is what allow programmers to run functions or methods concurrently.
go function_name(parameters)
Using the key term 'go' allows the program to run concurrently, BUT in order for your program to run in parallel you can use the key term 'GOMAXPROCS'
func GOMAXPROCS(n int) int
'GOMAXPROCS' allows the programmer to specify the MAX amount of CPU's that will be executing code simultaneously. By default, GOMAXPROCS is set to the number of cores available.
If you're more interested in the differences between Concurrency and Parallelism we found a great explanation here: https://stackoverflow.com/a/24684037/8644993
Differences
Code Differences
Time Differences
Ease of Use
Relevance
Present and Future
Presently C++ is a language that is so intertwined with programming it would be hard for any language to surpass it in terms of relevance. Many systems/programs depend on C++ for core functionality and because the technology world moves/evolves so quickly it is hard for programmers to transfer systems over to a new language without encountering major issues.
But what do the people say?
But that doesn't mean that Go isn't used today, on Tiobes Programming Language Index [4] C++ is currently in fourth place, Go is 13th. The difference? C++ hasn't made any movement from 4th place for an entire year, while Go last year of November 2019 was at the 20th place, It has gone up 7 places in just 1 year.
Stack Overflow has also released their 2020 Developer Survey[5] and the results show that currently for the most loved languages, Go is in 5th place and C++ is 18th. In terms of popularity C++ is 10th place while Go is 12th.
And obviously major companies have already begun incorporating Go into their projects such as Google, YouTube, Uber, Intel, and Heroku.
What's the future like?
The future looks bright for Go and it's gaining traction quick. Since it's a language that was literally meant to be a replacement for these older languages like C++ it definitely has the edge when incorporating new technologies that are introduced because of hardware advancements (Such has multi-core CPU's).
Pros and Cons
Pros
1. Tons of support
2. Ease of use
3. Major companies support it (Google)
4. Better security integrations
Cons
1. Lack of versatility
2. Young language
3. Lacks speed compared to C++ (But is much faster than other high-level languages)
4. Smaller Community
More about the pros and cons can be found at: https://www.geeksforgeeks.org/go-vs-c-plus-plus/
Why should you Go Parallel?
While currently C++ is generally a better language to learn parallel programming concepts from, and is also more used within the programming industry. Go is gaining popularity quickly and with the creation of Go meant to improve upon C++ weaknesses the future of Go is looking very good. Parallel programming in Go is extremely easy and has built in support for it (No need to go through any installation https://ict.senecacollege.ca/~gpu621/pages/content/suppo.html). In addition Go is a fun language to learn and could seriously be used over many of the other high-level programming languages.
A major thing to remember is that during Go's creation, multi-core CPU's were currently being made and popularized. This is very advantageous over C++ since in 1979 multi-core CPU's were unheard of and the first multi-core CPU was introduced in 2001.
Group Members
1. Michael Brackett
2. Devansh Shah
Progress
Update 1: Sunday, Nov 8, 2020 - Created description for project.
Update 2: Friday, Nov 13, 2020 - Created description for Go Language
Update 3: Sunday, Nov 15, 2020 - Created Installation Instructions
Update 4: Sunday, Nov 15, 2020 - Created Pros and Cons
Update 5: Tuesday, Nov 17, 2020 - Created 'Why you should Go Parallel'
Update 6: Thursday, Nov 19th, 2020 - Added all parts of project onto project website
Update 7: Thursday, Nov 19th, 2020 - Added Pictures to Installation Instructions
References
https://software.intel.com/content/www/us/en/develop/blogs/go-parallel.html
https://talks.golang.org/2012/splash.article
https://golang.org/pkg/runtime/#GOMAXPROCS
https://docs.oracle.com/cd/E19455-01/806-5257/6je9h032b/index.html
https://stackoverflow.com/a/24684037/8644993
https://www.tiobe.com/tiobe-index/
https://brainhub.eu/blog/biggest-companies-using-golang/
https://insights.stackoverflow.com/survey/2020
https://github.com/golang/go/wiki/GoUsers
https://www.geeksforgeeks.org/go-vs-c-plus-plus/