Your SlideShare is downloading. ×
  • Like
Go(lang) for the Rubyist
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Go(lang) for the Rubyist

  • 4,588 views
Published

Presented at LA Ruby Conf on February 8th, 2014. A high level overview of Go, golang, and how it relates to Ruby. Packages such as Martini, Lineman.js, sqlx, Ginkgo, and more are covered.

Presented at LA Ruby Conf on February 8th, 2014. A high level overview of Go, golang, and how it relates to Ruby. Packages such as Martini, Lineman.js, sqlx, Ginkgo, and more are covered.

Published in Technology , Design
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,588
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
34
Comments
0
Likes
6

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. @markbates
  • 2. @markbates
  • 3. www.metacasts.tv LARUBY2014
  • 4. Erlang Node CoffeeScript Scala Clojure Go Elixir JavaScript
  • 5. #WTF??
  • 6. “Art isn’t created in a vacuum.”
  • 7. neither is! SOFTWARE!
  • 8. pol·y·glot (pŏl′ē-glŏt′)! adj. Speaking, writing, written in, or composed of several languages. n. 1. A person having a speaking, reading, or writing knowledge of several languages. 2. A book, especially a Bible, containing several versions of the same text in different languages. 3. A mixture or confusion of languages.
  • 9. What is Go?
  • 10. pro-tip: golang
  • 11. 40% of the Internet http://www.forbes.com/sites/timworstall/2013/08/17/fascinating-number-google-is-now-40-of-the-internet/
  • 12. compiled
  • 13. statically typed
  • 14. garbage collected
  • 15. cross platform
  • 16. concurrent
  • 17. simple
  • 18. 25 keywords
  • 19. no exceptions
  • 20. Basics
  • 21. package main! ! import "fmt"! ! func main() {! fmt.Println("Hello, World!")! }
  • 22. Concurrency
  • 23. package main! ! func LiftHeavyStuff() {! // do heavy lifting! }! ! func main() {! LiftHeavyStuff()! }
  • 24. package main! ! func LiftHeavyStuff() {! // do heavy lifting! }! ! func main() {! go LiftHeavyStuff()! }
  • 25. package main! ! import "fmt"! ! func main() {! ! ! ! ! ! ! comm := make(chan string)! go func() {! ! // do heavy lifting! ! comm <- "Done heave lifting"! }()! ! ! fmt.Println(<-comm)! }
  • 26. Speed
  • 27. package main! ! import "fmt"! ! func fibonacci() func() int {! ! x := 0! ! y := 1! ! return func() int {! ! ! x, y = y, x+y! ! ! return x! ! }! }! ! func main() {! ! f := fibonacci()! ! for i := 0; i < 10; i++ {! ! ! fmt.Println(f())! ! }! }
  • 28. def fibonacci(n)! return n if n <= 1! fibonacci(n - 1) + fibonacci(n - 2)! end! ! puts fibonacci( 10 )
  • 29. $ go build $ time ./fib real 0m0.005s user 0m0.001s sys 0m0.003s $ time ruby fib.rb real 0m0.038s user 0m0.029s sys 0m0.007s
  • 30. Duck Typing?
  • 31. package main! import "fmt"! type Bar struct {! z string! }! ! ! type Greeter interface {! SayHello()! }! func (b Bar) SayHello() {! fmt.Println("[Bar] Hello!")! }! ! ! func Talk(g Greeter) {! g.SayHello()! }! func main() {! foo := Foo{}! Talk(foo)! bar := Bar{}! Talk(bar)! } ! ! type Foo struct {! x int! }! ! func (f Foo) SayHello() {! fmt.Println("[Foo] Hello!")! }
  • 32. Package Management
  • 33. go get
  • 34. Testing
  • 35. package calculator! ! import "testing"! ! func TestAdd(t *testing.T) {! aresult := Add(1, 2)! if aresult != 3 {! t.Errorf("Expected %d, Actual %d", 3, aresult)! }! }
  • 36. package calculator_test! ! import (! . "calculator"! . "github.com/onsi/ginkgo"! . "github.com/onsi/gomega"! )! ! var _ = Describe("Calculator", func() {! Describe("Add", func() {! It("Adds two numbers together", func() {! Expect(Add(1, 2)).To(Equal(3))! })! })! })
  • 37. Web
  • 38. package main! ! import (! "fmt"! "net/http"! )! ! func handler(w http.ResponseWriter, r *http.Request) {! fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])! }! ! func main() {! http.HandleFunc("/", handler)! http.ListenAndServe(":8080", nil)! }
  • 39. package main! ! import "github.com/codegangsta/martini"! ! func main() {! m := martini.Classic()! m.Get("/", func() string {! return "Hello world!"! })! m.Run()! }
  • 40. Database
  • 41. MySql Sybase ODBC DB2 Postgres MS ADODB SQLite Oracle
  • 42. SQLX - https://github.com/jmoiron/sqlx GORP - https://github.com/coopernurse/gorp JET - https://github.com/eaigner/jet
  • 43. Workers
  • 44. Assets
  • 45. Lineman.js :)
  • 46. When to Use Go
  • 47. cli
  • 48. concurrency #ftw
  • 49. speed
  • 50. light-moderate! learning curve
  • 51. shell out to ruby
  • 52. Resources http://golang.org/ http://golang.org/doc/effective_go.html http://www.metacasts.tv/casts/intro-to-go http://www.metacasts.tv/casts/testing-go http://www.metacasts.tv/casts/sql-and-go
  • 53. @markbates http://www.metacasts.tv