Ruby Unconf 2019

Lightning Talk: Go, The Programming Language, Not the Game

Ruby Unconf 2019

00:00:04.970 Hello everyone! I'm really excited to talk about Go, the programming language, not the game.
00:00:11.920 Yesterday, someone expressed interest in learning about different programming languages, and I realized I am quite proficient in Go. Since someone had already done an introduction to Rust, I decided to cover Go as an introductory topic.
00:00:19.760 One of the key highlights of Go is its cute mascot, which was recently changed to a different logo. While the logo has changed, the essence of Go remains. Go is distinct from interpreted languages like Ruby because it compiles to a statically linked binary. This means you can take the binary and run it on the platform it was compiled for without the need to deal with additional libraries. It's straightforward to deploy as it requires no extra dependencies.
00:00:41.839 Moreover, Go is statically typed, which is similar to most compiled languages. You'll need to assign types to every variable and field in your structs, but Go can infer many types. If you create a new variable and assign a value, Go will usually infer the variable's type automatically. Unlike Rust, which does not have a runtime and thus does not perform garbage collection, Go utilizes garbage collection to manage memory. This feature helps eliminate unused memory after a function call.
00:01:09.140 A notable difference compared to object-oriented languages is that Go does not have classes; it relies solely on structs or types that have methods bound to them. Therefore, while we have type inheritance in Go, it operates differently than in traditional object-oriented models. Go boasts a large standard library filled with features similar to Ruby, unlike C, where you often have to import numerous libraries.
00:01:25.519 Go also includes excellent concurrency features and is generally safe in terms of memory management if conventions are followed. I want to showcase a simple 'Hello, World!' API that you can build using the standard library. The HTTP module in Go provides primitives that allow you to easily set up routes. For example, you can define a handler for the root path that prints 'Hello, World!' and serve it on port 80.
00:01:57.210 I also want to emphasize the importance of concurrency when developing fast back-end services. In Go, you can have functions that run in parallel to your main handlers, allowing you to perform tasks such as streaming POST requests and inserting data into the database simultaneously. This feature is incredibly useful for handling multiple records efficiently.
00:02:11.300 Regarding memory safety, it's important to note that while Go does not guarantee memory safety in the same way Rust does, it provides mechanisms to manage it effectively. You may need to use mutexes to ensure thread safety, but by utilizing goroutines and channels, you can pass values between concurrent functions safely, avoiding race conditions.
00:02:38.150 Go has several types available within the compiler, and you can build your custom types on top of these. One last point I want to highlight is the struct feature used in Go. Similar to structs in C, you can add tags to the fields of a struct, which assist with tasks like serialization and deserialization, facilitating interactions with databases. This functionality is akin to Active Record in Ruby, enhancing the usability of Go's standard library.
00:05:02.030 Thank you for listening!