ardanlabs.com

Caddy Partnership With Light Code Labs

Ardan Labs (a leader in building Go enterprise software) is excited to announce that we have partnered with Light Code Labs and Matt Holt to bring Caddy into the Ardan Labs family of products and services. Caddy is a lightweight ingress service written in Go that provides automated security features and a plugin environment for extensibility. With the service being free open source (FOSS), small and large Go engineering teams finally have the ability to own and maintain their ingress and load balancing software with ease. We believe the Caddy...

ardanlabs.com

Garbage Collection In Go : Part III - GC Pacing

PreludeThis is the third post in a three part series that will provide an understanding of the mechanics and semantics behind the garbage collector in Go. This post focuses on how the GC paces itself.Index of the three part series:1) Garbage Collection In Go : Part I - Semantics2) Garbage Collection In Go : Part II - GC Traces2) Garbage Collection In Go : Part III - GC PacingIntroductionIn the second post, I showed you the behavior of the garbage collector and how to use the tooling to see the latencies that the collector inflicts on your...

ardanlabs.com

An Open Letter To The Go Team About Try

“Once a language gets complex enough, programming in it is more like carving out a subset from an infinite sea of features, most of which we’ll never learn. Once a language feels infinite, the costs of adding further features to it are no longer apparent”. - Mark MillerThe new try proposal is an addition to the language that introduces a second mechanic to handle errors. It is being introduced in response to data gathered from the 2018 Go Survey and a review of proposals that were submitted during the Go 2 proposal process. The...

ardanlabs.com

Go Compiler nil Pointer Checks

IntroductionI was thinking about how the compiler looks to protect the code we write when it can. Invalid memory access checks are one type of safety check the compiler adds to our code. We might think that this "extra code" is hurting our performance and maybe over billions of iterative operations it is. However, these checks can prevent our code from causing damage to the systems we are running on. The compiler is essentially reporting and finding bugs, making the code we write safer to run.Even with this in mind, Go wants to be...

ardanlabs.com

Error Handling In Go, Part II

IntroductionIn part I of this post, we learned about the error interface and how the standard library provides support for creating error interface values via the errors package. We also learned how to work with error interface values and use them to identify when an error has occured. Finally, we saw how some packages in the standard library export error interface variables to help us identify specific errors.Knowing when to create and use custom error types in Go can sometimes be confusing. In most cases, the traditional error interface...

ardanlabs.com

Object Oriented Programming Mechanics

Go is an object oriented programming language. It may not have inheritance, but in this 20 minute video from the Bangalore meetup, I will show you how object oriented programming practices and techniques can be applied to your Go programs. From an object oriented standpoint, Go does provides the ability to add behavior to your types via methods, allows you to implement polymorphic behavior via interfaces and gives you a way to extend the state and behavior of any existing type via type embedding. Go also provides a form of encapsulation that...

ardanlabs.com

Escape-Analysis Flaws

PreludeIt will be helpful to read this four-part series first on escape analysis and data semantics. Details on how to read an escape analysis report and pprof output have been outlined here.https://www.ardanlabs.com/blog/2017/05/language-mechanics-on-stacks-and-pointers.htmlIntroductionEven after working with Go for 4 years, I am continually amazed by the language. Thanks to the static code analysis the compiler performs, the compiler can apply interesting optimizations to the code it produces. One type of analysis the compiler performs is...

ardanlabs.com

Concurrency Trap #2: Incomplete Work

IntroductionIn my first post on Goroutine Leaks, I mentioned that concurrency is a useful tool but it comes with certain traps that don’t exist in synchronous programs. To continue with this theme, I will introduce a new trap called incomplete work. Incomplete work occurs when a program terminates before outstanding Goroutines (non-main goroutines) complete. Depending on the nature of the Goroutine that is being terminated forcefully, this may be a serious problem.Incomplete WorkTo see a simple example of incomplete work, examine this...

ardanlabs.com

Goroutine Leaks - The Abandoned Receivers

IntroductionGoroutine Leaks are a common cause of memory leaks in Go programs. In my previous post, I presented an introduction to Goroutine leaks and provided one example of a common mistake that many Go developers make. Continuing that work, this post presents another scenario on how Goroutines could be leaked.Leak: The Abandoned ReceiversFor this leak example you will see multiple Goroutines blocked waiting to receive values that will never be sent.The program for this post starts multiple Goroutines to process a batch of records from a...

ardanlabs.com

Creating the Art for Gopher Kart

In the months leading up to GopherCon, my wife Jamilet and I had come up with the idea of creating a “small” browser-based game for the convention using the racing theme. Neither of us had ever worked on a game before and we had no idea what was involved. However, we knew we wanted to design and build something special for the awesome Gopher community.The original idea was to create a game where Gophers raced each other around a track. We looked into how much time that would take and realized working part time meant we wouldn’t finish...

ardanlabs.com

Bounds Check Elimination In Go

IntroductionOne day I was talking to Damian Gryski in Slack about some performance improvements he made to his go-metro package. When I first looked at the changes I was completely confused how this could have any effect on the performance of the code. I felt the code was more readable, but more performant? I didn’t see it.Then Damian started to talk to me about a compiler optimization called Bounds Check Elimination or BCE. The idea behind BCE is to give the compiler hints that index-based memory access is guaranteed to be safe and...

ardanlabs.com

Design Philosophy On Logging

PreludeThis post is part of a series designed to make you think about your own design philosophy on different topics. If you haven’t read the following post yet, please do so first:Develop Your Design PhilosophyIntroductionSystems cannot be developed assuming that human beings will be able to write millions of lines of code without making mistakes, and debugging alone is not an efficient way to develop reliable systems. - Al Aho (inventor of AWK)When a developer reaches for a debugger out of habit, the debugger begins to cause more harm than...

ardanlabs.com

For Range Semantics

PreludeThese are good posts to read first to better understand the material presented in this post:Index of the four part series:1) Language Mechanics On Stacks And Pointers2) Language Mechanics On Escape Analysis3) Language Mechanics On Memory Profiling4) Design Philosophy On Data And SemanticsThe idea of value and pointer semantics are everywhere in the Go programming language. As stated before in those earlier posts, semantic consistency is critical for integrity and readability. It allows developers to maintain a strong mental model of a...

ardanlabs.com

Design Philosophy On Data And Semantics

PreludeThis is the final post in a four part series discussing the mechanics and design behind pointers, stacks, heaps, escape analysis and value/pointer semantics in Go. This post focuses on data and the design philosophies of applying value/pointer semantics in your code.Index of the four part series:1) Language Mechanics On Stacks And Pointers2) Language Mechanics On Escape Analysis3) Language Mechanics On Memory Profiling4) Design Philosophy On Data And SemanticsDesign Philosophies“Value semantics keep values on the stack, which...

ardanlabs.com

Language Mechanics On Memory Profiling

PreludeThis is the third post in a four part series that will provide an understanding of the mechanics and design behind pointers, stacks, heaps, escape analysis and value/pointer semantics in Go. This post focuses on heaps and escape analysis.Index of the four part series:1) Language Mechanics On Stacks And Pointers2) Language Mechanics On Escape Analysis3) Language Mechanics On Memory Profiling4) Design Philosophy On Data And SemanticsWatch this video to see a live demo of this code:GopherCon Singapore (2017) - Escape AnalysisIntroductionIn...

ardanlabs.com

Language Mechanics On Escape Analysis

PreludeThis is the second post in a four part series that will provide an understanding of the mechanics and design behind pointers, stacks, heaps, escape analysis and value/pointer semantics in Go. This post focuses on heaps and escape analysis.Index of the four part series:1) Language Mechanics On Stacks And Pointers2) Language Mechanics On Escape Analysis3) Language Mechanics On Memory Profiling4) Design Philosophy On Data And SemanticsIntroductionIn the first post in this four part series, I taught the basics of pointer mechanics by using...

ardanlabs.com

Design Philosophy On Packaging

PreludeThis post is part of a series of posts designed to make you think about your own design philosophy on different topics. If you haven’t read this post yet, please do so first:Develop Your Design PhilosophyAfter this post, read this next one:Package Oriented DesignIntroductionIn an interview given to Brian Kernighan by Mihai Budiu in the year 2000, Brian was asked the following question:“Can you tell us about the worse features of C, from your point of view”?This was Brian’s response:“I think that the real problem with C is that...

ardanlabs.com

Package Oriented Design

Updated on February 28th, 2017PreludeThis post is part of a series of posts designed to make you think about your own design philosophy on different topics. If you haven’t read these posts yet, please do so first:Develop Your Design PhilosophyDesign Philosophy On PackagingIntroductionPackage Oriented Design allows a developer to identify where a package belongs inside a Go project and the design guidelines the package must respect. It defines what a Go project is and how a Go project is structured. Finally, it improves communication between...

ardanlabs.com

Language Mechanics On Stacks And Pointers

PreludeThis is the first post in a four part series that will provide an understanding of the mechanics and design behind pointers, stacks, heaps, escape analysis and value/pointer semantics in Go. This post focuses on stacks and pointers.Index of the four part series:1) Language Mechanics On Stacks And Pointers2) Language Mechanics On Escape Analysis3) Language Mechanics On Memory Profiling4) Design Philosophy On Data And SemanticsIntroductionI’m not going to sugar coat it, pointers are difficult to comprehend. When used incorrectly,...

ardanlabs.com

Focus On Being Precise

IntroductionI was guided for many years to write functions that are generalized and to create layers upon layers of abstraction so things don’t break as business requirements change. That the cost of breaking a function signature, for example, is expensive and something that should be avoided. Therefore, write functions that take more generic parameters or hide things in a receiver or context to be less prone to breakage.On the surface this seems like a good and reasonable idea. However, I have come to believe that this practice leads to...

ardanlabs.com

Scheduling In Go : Part III - Concurrency

PreludeThis is the third post in a three part series that will provide an understanding of the mechanics and semantics behind the scheduler in Go. This post focuses on concurrency.Index of the three part series:1) Scheduling In Go : Part I - OS Scheduler2) Scheduling In Go : Part II - Go Scheduler3) Scheduling In Go : Part III - ConcurrencyIntroductionWhen I’m solving a problem, especially if it’s a new problem, I don’t initially think about whether concurrency is a good fit or not. I look for a sequential solution first and make sure...

ardanlabs.com

Goroutine Leaks - The Forgotten Sender

IntroductionConcurrent programming allows developers to solve problems using more than one path of execution and is often used in an attempt to improve performance. Concurrency doesn’t mean these multiple paths are executing in parallel; it means these paths are executing out-of-order instead of sequentially. Historically, this type of programming is facilitated using libraries that are either provided by a standard library or from 3rd party developers.In Go, concurrency features like Goroutines and channels are built into the language and...

ardanlabs.com

Scheduling In Go : Part I - OS Scheduler

PreludeThis is the first post in a three part series that will provide an understanding of the mechanics and semantics behind the scheduler in Go. This post focuses on the operating system scheduler.Index of the three part series:1) Scheduling In Go : Part I - OS Scheduler2) Scheduling In Go : Part II - Go Scheduler3) Scheduling In Go : Part III - ConcurrencyIntroductionThe design and behavior of the Go scheduler allows your multithreaded Go programs to be more efficient and performant. This is thanks to the mechanical sympathies the Go...

ardanlabs.com

Ultimate Go Service

IntroductionI teach a class called Ultimate Go. The class is three days long and teaches you the history, mechanics and semantics of the Go programming language. The idea is to teach you how to read code to the level that you can understand the behavior and impact your program is having on the machine. This helps you make better and more consistent engineering decisions.At the same time, the class is very focused on teaching you how to optimize for correctness so the code you are writing is readable as a first priority. After three days in the...

ardanlabs.com

Interface Values Are Valueless

IntroductionI’ve been seeing a lot of question about interfaces lately on Slack. Most of the time the answers are technical and focus on implementation details. Implementation is important to help with debugging, but implementation doesn’t help with design. When it comes to designing code with interfaces, behavior has to be the main focus.In this post, I hope to provide a different way to think about interfaces and how to design code with them. I want you to stop focusing on the implementation details and focus on the relationship...