I just love new programming languages. Perhaps it's the inevitable familiarity and ennui with regard to existing languages and the frustration with existing tools, syntaxes, coding conventions, and performance. Maybe I'm just hunting for that one "language to rule them all". Whatever the reason, any time a new or experimental language is released, I have to dive right in.
This has been a golden age for new languages and language design. Think about it: the C language was released in the early 1970s—a time when resources were so scarce that verbosity, clarity, and syntactical logic were often eschewed for thrift. And most of the languages we use today were either originally written in this era or were directly influenced by those languages.
Since the late 1980s and early 1990s, there has been a slow flood of powerful new languages and paradigms—Perl, Python, Ruby, PHP, and JavaScript—have taken an expanding user base by storm and has become one of the most popular languages (up there with stalwarts such as C, C++, and Java). Multithreading, memory caching, and APIs have allowed multiple processes, dissonant languages, applications, and even separate operating systems to work in congress.
And while this is great, there's a niche that until very recently was largely unserved: powerful, compiled, cross-platform languages with concurrency support that are geared towards systems programmers.
Very few languages match these parameters. Sure, there have been lower-level languages that fulfill some of these characteristics. Erlang and Haskell fit the bill in terms of power and language design, but as functional languages they pose a learning barrier for systems programmers coming from a C/Java background. Objective-C and C# are relatively easy, powerful, and have concurrency support—but they're bound enough to a specific OS to make programming for other platforms arduous. The languages we just mentioned (Python, JavaScript, and so on)—while extremely popular—are largely interpreted languages, forcing performance into a secondary role. You can use most of them for systems programming, but in many ways it's the proverbial square peg in a round hole. So when Google announced Go in 2009, my interest was piqued. When I saw who was behind the project (more on that later), I was elated. When I saw the language and its design in action, I was in heaven.
For the last few years I've been using Go to replace systems applications I'd previously written in C, Java, Perl, and Python. I couldn't be happier with the results. Implementing Go has improved these applications in almost every instance. The fact that it plays nicely with C is another huge selling point for systems programmers looking to dip their toes in Go's pool.
With some of the best minds in language design (and programming in general) behind it, Go has a bright future.
For years—decades, really—there have been less than a handful of options for writing servers and network interfaces. If you were tasked with writing one, you probably reached for C, C++, or Java. And while these certainly can handle the task, and while they all now support concurrency and parallelism in some way or another, they weren't designed for that.
Google brought together a team that included some giants of programming—Rob Pike and Ken Thompson of Bell Labs fame and Robert Griesemer, who worked on Google's JavaScript implementation V8—to design a modern, concurrent language with development ease at the forefront.
To do this, the team focused on some sore spots in the alternatives, which are as follows:
Chapter 1, An Introduction to Concurrency in Go, introduces goroutines and channels, and will compare the way Go handles concurrency with the approach other languages use. We'll build some basic concurrent applications utilizing these new concepts.
Chapter 2, Understanding the Concurrency Model, focuses on resource allocation, sharing memory (and when not to), and data. We will look at channels and channels of channels as well as explain exactly how Go manages concurrency internally.
Chapter 3, Developing a Concurrent Strategy, discusses approach methods for designing applications to best use concurrent tools in Go. We'll look at some available third-party packages that can play a role in your strategy.
Chapter 4, Data Integrity in an Application, looks at ensuring that delegation of goroutines and channels maintain the state in single thread and multithread applications.
Chapter 5, Locks, Blocks, and Better Channels, looks at how Go can avoid dead locks out of the box, and when and where they can still occur despite Go's language design.
Chapter 6, C10K – A Non-blocking Web Server in Go, tackles one of the Internet's most famous and esteemed challenges and attempt to solve it with core Go packages. We'll then refine the product and test it against common benchmarking tools.
Chapter 7, Performance and Scalability, focuses on squeezing the most out of your concurrent Go code, best utilizing resources and accounting for and mitigating third-party software's impact on your own. We'll add some additional functionality to our web server and talk about other ways in which we can use these packages.
Chapter 8, Concurrent Application Architecture, focuses on when and where to implement concurrent patterns, when and how to utilize parallelism to take advantage of advanced hardware, and how to ensure data consistency.
Chapter 9, Logging and Testing Concurrency in Go, focuses on OS-specific methods for testing and deploying your application. We'll also look at Go's relationship with various code repositories.
Chapter 10, Advanced Concurrency and Best Practices, looks at more complicated and advanced techniques including duplicating concurrent features not available in Go's core.
3.15.140.68