Google Go Overview

4,005 views
3,892 views

Published on

Go Talk held at Web Technology Talk Stuttgart, August 2010.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,005
On SlideShare
0
From Embeds
0
Number of Embeds
1,503
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide


































































  • Google Go Overview

    1. 1. Google Go Web Technology Talks Meeting - 24.8.2010 Moritz Haarmann
    2. 2. It includes a http-server thats why it‘s a web-technology.
    3. 3. Moritz Haarmann • GTUG/NA Founding Member • Interests: Android, iPhone, Web and Open Technologies • 25y, writing my Bachelor Thesis ( CompScience ), HdM Stuttgart • @derwildemomo
    4. 4. Thinks to talk about
    5. 5. Thinks to talk about Why Google decided to go. ( Speculation )
    6. 6. Thinks to talk about Why Google decided to go. ( Speculation ) Go Basics
    7. 7. Thinks to talk about Why Google decided to go. ( Speculation ) Go Basics Cool Ideas
    8. 8. Thinks to talk about Why Google decided to go. ( Speculation ) Get you Go Basics Cool Ideas going
    9. 9. Why Go?
    10. 10. C is still second-most used but almost 40 years old and notoriously unsafe
    11. 11. Java is not always an option read: System programming
    12. 12. Python etc. also rock Same problem: Though they are cool, they cannot be applied to any problem
    13. 13. 38 years after the invention of C No real Alternative
    14. 14. Go
    15. 15. Go Basics
    16. 16. The Basics
    17. 17. The Basics • Compiled, no Bytecode/Interpreter
    18. 18. The Basics • Compiled, no Bytecode/Interpreter • Static Typing
    19. 19. The Basics • Compiled, no Bytecode/Interpreter • Static Typing • Concurrent, Functional, Imperative Paradigms satisfied
    20. 20. The Basics • Compiled, no Bytecode/Interpreter • Static Typing • Concurrent, Functional, Imperative Paradigms satisfied • Clean design, familiar C-like Syntax
    21. 21. The Basics • Compiled, no Bytecode/Interpreter • Static Typing • Concurrent, Functional, Imperative Paradigms satisfied • Clean design, familiar C-like Syntax • Garbage Collector: its problem is not yours.
    22. 22. Always ask!
    23. 23. Hello World package main import "fmt" func main() { fmt.Println("Hello, World") }
    24. 24. Functions with super-cow-powers.
    25. 25. Simple Function func simpleFunction() { (...) } func caller() { simpleFunction() }
    26. 26. Better Functions
    27. 27. Better Functions func Function(an int) (int) { return an + 1 }
    28. 28. Better Functions func Function(an int) (int) { return an + 1 } func Function(an int) (returnValue int, another int) { returnValue = an + in another = returnValue * 5 return }
    29. 29. Better Functions func Function(an int) (int) { return an + 1 } func Function(an int) (returnValue int, another int) { returnValue = an + in another = returnValue * 5 return } a,_ = Function(1)
    30. 30. Functionals func execFunc(aFunc func()) { aFunc() }
    31. 31. Functionals func execFunc(aFunc func()) { aFunc() var anotherF = func(){ fmt.Println("Thats another function") } execFunc(anotherF) }
    32. 32. Packages in a short
    33. 33. Packages • Form the core organizational unit • one package - one file • entry point: Package main with function main • Function visibility: First letter decides! ( func invisible() vs. func Visible() ) • many packages shipped for common tasks, e.g. http
    34. 34. Package Example package main import "fmt" func main() { fmt.Println("Hello, World") }
    35. 35. a parallel world
    36. 36. Sharing Memory information a a information a information information a information a a information a information information a information a a information a information information a information a a information a information information a information a a information a information information a information a a information a information information a
    37. 37. Sharing by Communicating information a information b information b information b information b information b information b information a information a information a information a information a
    38. 38. Do not communicate by sharing memory; instead, share memory by communicating
    39. 39. Goroutines & Channels
    40. 40. Goroutine func showGo() { go func(){ time.Sleep(20) fmt.Println("parallel.") } }
    41. 41. Channels
    42. 42. Channels • First-Class Value Object
    43. 43. Channels • First-Class Value Object • Typed, e.g. chan int is a channel transporting ints.
    44. 44. Channels • First-Class Value Object • Typed, e.g. chan int is a channel transporting ints. • buffered, that is async, or unbuffered and therefore synchronous channel
    45. 45. Channels • First-Class Value Object • Typed, e.g. chan int is a channel transporting ints. • buffered, that is async, or unbuffered and therefore synchronous channel • Brainfuck ( for now ): channels of channels!
    46. 46. Sorting in background c := make(chan int) go func() { list.Sort() c <- 1 }() doSomethingForAWhile() <-c
    47. 47. WTF?
    48. 48. WTF? • Goroutines and Channels hide the complexity of threads, mutexes and other hard-to-master stuff effectively
    49. 49. WTF? • Goroutines and Channels hide the complexity of threads, mutexes and other hard-to-master stuff effectively • Race conditions, deadlocks etc are impossible.
    50. 50. WTF? • Goroutines and Channels hide the complexity of threads, mutexes and other hard-to-master stuff effectively • Race conditions, deadlocks etc are impossible. • Another underlying thought model
    51. 51. A word on types
    52. 52. A word on types • Known types are known ( int, unsigned )
    53. 53. A word on types • Known types are known ( int, unsigned ) • First-Class UTF-8 Strings
    54. 54. A word on types • Known types are known ( int, unsigned ) • First-Class UTF-8 Strings • Arrays, Maps
    55. 55. A word on types • Known types are known ( int, unsigned ) • First-Class UTF-8 Strings • Arrays, Maps • Custom Types
    56. 56. A word on types • Known types are known ( int, unsigned ) • First-Class UTF-8 Strings • Arrays, Maps • Custom Types • Arrays++: Slices
    57. 57. A word on types • Known types are known ( int, unsigned ) • First-Class UTF-8 Strings • Arrays, Maps • Custom Types • Arrays++: Slices • Pointers but no arithmetic ( guess why )
    58. 58. Slices
    59. 59. Slices • Type- and Boundsafe Array Wrappers, that can be easily generated and passed around
    60. 60. Slices • Type- and Boundsafe Array Wrappers, that can be easily generated and passed around • Reference to underlying data
    61. 61. Slices • Type- and Boundsafe Array Wrappers, that can be easily generated and passed around • Reference to underlying data • Safe, fast and easy to use
    62. 62. Interfaces
    63. 63. Interfaces • Duck Typing-Style
    64. 64. Interfaces • Duck Typing-Style • Quite Useful
    65. 65. A bit OO • Functions operating on a type
    66. 66. ... type Momo struct { a int b int } func (m *Momo) wakeUp { m.shakeAlmostToDeath() } var m = new(Momo) m.wakeUp()
    67. 67. Not discussed today
    68. 68. Not discussed today • A lot
    69. 69. Not discussed today • A lot • Allocation, Memory Handling
    70. 70. Not discussed today • A lot • Allocation, Memory Handling • Built-In gimmicks ( Do.once, init )
    71. 71. Not discussed today • A lot • Allocation, Memory Handling • Built-In gimmicks ( Do.once, init ) • Error Handling
    72. 72. Not discussed today • A lot • Allocation, Memory Handling • Built-In gimmicks ( Do.once, init ) • Error Handling • The bitchy compiler
    73. 73. Not discussed today • A lot • Allocation, Memory Handling • Built-In gimmicks ( Do.once, init ) • Error Handling • The bitchy compiler • Embedding
    74. 74. Questions?
    75. 75. http://tinyurl.com/gotalk2010 und danke!

    ×