Introduction to Go Programming Language

Slide Note
Embed
Share

Go (also known as Golang) is a compiled, concurrent, statically typed, and garbage-collected language developed at Google by Rob Pike in 2012. It combines efficiency with good abstractions, making it ideal for system development. Many companies have adopted Go for its ease of use, speed, and efficient multitasking capabilities. To get started with Go programming, you can explore the official resources provided by the Go community.


Uploaded on Sep 01, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. A Short Intro to Go CS 240

  2. Whats this Weird Language Ive Never Heard of? Go is a compiled, concurrent, statically typed, garbage-collected language developed at Google - Rob Pike, 2012 Rob Pike is the Jeff Dean of distributed systems. Here s the article the quote is from: https://talks.golang.org/2012/splash.article

  3. Whats this Weird Language Ive Never Heard of? compiled concurrent statically typed garbage-collected Like C, C++ Like Erlang Like C, C++, Java Like Java and Python

  4. Why Not Use Python, Java, C++, etc? Built for Systems. Go preserves efficiency but has good abstractions. Easy multi threading and IO communication. Develop quickly Do many things efficiently and at the same time

  5. Seems Google Specific. Who Else Actually Uses it? Official Self Reported List of Companies that use Go: https://github.com/golang/go/wiki/GoUsers

  6. Why did they Choose Go? We built everything in Python because it was easy, but now it s slow. So we switched to Go. - Most companies using Go

  7. But How do I Use Go? Start here: https://tour.golang.org/list Didn t install Go? Use the web IDE: https://play.golang.org/ Other Resources: Go for Pythonists https://talks.golang.org/2013/go4python.slide#1 Go for Distributed Systems https://talks.golang.org/2013/distsys.slide#1 Official Go Talks https://github.com/golang/go/wiki/GoTalks

  8. But How do I Use Go? DEMO: go tour

  9. Build Software for Any System go build file.go Compile an executable for your machine env GOOS=windows GOARCH=amd64 go build file.go Compile an executable for Windows with 64 bit processor

  10. Format your Code COMMAND gofmt file.go WHAT IT DOES Format the file.go properly DEMO: gofmt

  11. Wait, I Have Questions! Go s official Frequently Asked Questions (FAQ) https://golang.org/doc/faq

  12. MapReduce CS 240

  13. Map Reduce Wikipedia: MapReduce is a programming model and an associated implementation for processing and generating big data sets with a parallel, distributed algorithm on a cluster. In other words, a general and scalable solution to deal with big data computation on multiple machines.

  14. Abstract Map Reduce map(key, value) -> list(<k , v >) Apply function to (key, value) pair Outputs set of intermediate pairs Split and distribute data reduce(key, list<value>) -> <k , v > Applies aggregation function to values Outputs result Aggregate and compute results

  15. Word Count The Hello World of Map Reduce Bus 2 Bus 1 Bus 3 Bus 1 Car 1 Train 1 Bus Car Train Car 1 Car 1 Car 2 Bus 3 Car 2 Train 2 Plane 2 Bus Car Train Train Plane Car Bus Bus Plane Train 1 Plane 1 Car 1 Train Plane Car Train 1 Train 1 Train 2 Bus 2 Plane 1 Bus Bus Plane Plane 2 Plane 1 Plane 1 Intermediate Splitting Mapping Splitting Combining Reducing doReduce doReduce() () doMap doMap() ()

  16. A Motivating Problem for Map Reduce Find me the closest Starbucks to KAUST. Actually, I ll give you a place and something to look for, and you find me the closest one. Here s a 1 TB text file good luck GPS Coordinates [22.3, [22.2, [35.7, ... Site Name Tim Hortons KAUST Library Starbucks ... 39.1] 39.1] 139.7] In KAUST In Tokyo, Japan

  17. A Motivating Problem for Map Reduce GPS Coordinates [22.3, [22.2, [35.7, ... Site Name Tim Hortons KAUST Library Starbucks ... 39.1] 39.1] 139.7] 0 1 2 3 4 0 (0,0) (0,1) (0,2) (0,3) (0,4) 1 (1,0) (1,1) (1,2) (1,3) (1,4) Reduce to single files Map to grids 2 (2,0) (2,1) (2,2) (2,3) (2,4) (3,0) (3,1) (3,2) (3,3) (3,4) 3

  18. Split the File and Map Each Chunk Independently (1/2) Mapping Nodes Mapper GPS CoordinatesSite Name [22.3, 39.1] [22.2, 39.1] [35.7, 139.7] Starbucks ... [42.0, 69.0] [22.2, 39.2] ... ... ... ... Tim Hortons KAUST Library ... Chanak Train Stop Burger King ... ... ... ... Mapper

  19. Split the File and Map Each Chunk Independently (2/2) KEY <grid>: VALUE <locations and name> ... Mapping Nodes (1,2): [22.3, 39.1] Tim Hortons (1,2): [22.2, 39.1] KAUST Library (1,2): ... (2,4): [35.7, 139.7] Starbucks (2,4): ... Mapper GPS Coordinates Site Name [22.3, 39.1] [22.2, 39.1] [35.7, 139.7] Starbucks ... [42.0, 69.0] [22.2, 39.2] ... ... ... ... Tim Hortons KAUST Library ... Chanak Train Burger King ... ... ... ... (1,3): [42.0, 69.0] Chanak Train (1,3): ... (1,2): [22.2, 39.2] Burger King (1,2): ... Mapper (KEY) can appear in multiple mappers

  20. Collect the Mapper Results and Reduce to Single Files (1/2) Reducing Nodes (1,2): [22.3, 39.1] Tim Hortons (1,2): [22.2, 39.1] KAUST Library (1,2): ... (2,4): [35.7, 139.7] Starbucks (2,4): ... Reducer (1,2) (1,3): [42.0, 69.0] Chanak Train (1,3): ... (1,2): [22.2, 39.2] Burger King (1,2): ... Reducer (1,3), (2,4)

  21. Collect the Mapper Results and Reduce to Single Files (2/2) KEY <grid>: [ VALUES <locations and names>, ...] Reducing Nodes (1,2): [ [22.3, 39.1] Tim Hortons, [22.2, 39.1] KAUST Library, [22.2, 39.2] Burger King ...] ] (1,2): [22.3, 39.1] Tim Hortons (1,2): [22.2, 39.1] KAUST Library (1,2): ... (2,4): [35.7, 139.7] Starbucks (2,4): ... Reducer (1,2) (2,4): [ [35.7, 139.7] Starbucks, ...] (1,3): [42.0, 69.0] Chanak Train (1,3): ... (1,2): [22.2, 39.2] Burger King (1,2): ... Reducer (1,3), (2,4) (1,3): [ [42.0, 69.0] Chanak Train Stop, ...],

  22. Word Count The Hello World of Map Reduce Reducer nodes Mapper nodes Bus 2 Bus 1 Bus 3 Bus 1 Car 1 Train 1 Bus Car Train Car 1 Car 1 Car 2 Bus 3 Car 2 Train 2 Plane 2 Bus Car Train Train Plane Car Bus Bus Plane Train 1 Plane 1 Car 1 Train Plane Car Train 1 Train 1 Train 2 Bus 2 Plane 1 Bus Bus Plane Plane 2 Plane 1 Plane 1 Task is automatically distributed across five different nodes Intermediate Splitting Mapping Splitting Combining Reducing

  23. Hadoop: An open-source implementation Apache Hadoop is the most popular open-source implementation of MapReduce Runs on top of a distributed filesystem (HDFS) Try their MapReduce tutorial: https://hadoop.apache.org/docs/r1.2.1/mapred_tutorial.html

  24. How Hadoop Does it Mapping Nodes Reducing Nodes Mapper Reducer Mapper Reducer

  25. Some Advice for the Assignments Write modular code Use comments (even to yourself) Don t forget go fmt (graded) The clearer your code is, the more we can help with bugs

More Related Content