HTTP API

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

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

by Unknown

The video titled "Lightning Talk: Go, The Programming Language, Not the Game" was presented at Ruby Unconf 2019, focusing on providing an introduction to the Go programming language, distinct from the board game. The speaker, proficient in Go, aimed to enlighten attendees about its core features and advantages over other languages like Ruby and Rust. Key points from the talk include:

  • Introduction to Go: The speaker highlights their skill in Go after recognizing interest in programming languages.
  • Compilation and Deployment: Go compiles to a statically linked binary, allowing easy deployment on the compiled platform without additional library dependencies.
  • Static Typing: While Go is statically typed like most compiled languages, it can infer types automatically for variables, making coding more efficient.
  • Garbage Collection: Unlike Rust, Go includes garbage collection to manage memory, cleaning up unused memory after function calls.
  • Structs and Inheritance: Go lacks traditional classes found in object-oriented languages and uses structs instead. It supports type inheritance but approaches it differently compared to classical OOP models.
  • Standard Library: Go has a comprehensive standard library that simplifies tasks, contrasting with languages like C, which require importing multiple libraries.
  • Concurrency: The speaker emphasizes Go's exceptional concurrency features, allowing for parallel function execution. This helps efficiently manage tasks such as database operations during POST requests.
  • Memory Safety Tools: While not providing the same memory safety guarantees as Rust, Go utilizes goroutines and channels to aid safe communication between concurrent functions, thus preventing race conditions.
  • Struct Tags: The functionality of struct tags is highlighted for tasks like serialization with databases, drawing parallels to Active Record in Ruby.

Overall, the speaker urges the audience to explore Go for its straightforwardness in deployment, robust concurrency model, and supportive standard library, making it a strong choice for developing back-end services and applications.

In conclusion, the talk effectively demonstrates Go's capabilities while providing foundational knowledge that can help attendees consider using Go in their programming endeavors.

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!