This post is best described as a technology demonstration; it melds together web servers, plugins, WebAssembly, Go, Rust and ABIs. Here's what it shows: How to load WASM code with WASI in a Go environment and hook it up to a web server. How to implement web server plugins in any language that can be compiled to WASM. How to translate Go programs into WASM that uses WASI. How to translate Rust prog
This post shows how to set up SSH port forwarding ("tunnels") - both local and remote - using the extended Go standard library. Setup While you could set up localhost forwarding for testing, to discuss a more realistic scenario I would recommend spinning up a basic VPS. For the purpose of writing this post, I run a bare-bones Ubuntu VPS on Digital Ocean with the public IP address 159.89.238.232 (a
I've reimplemented my lexical analyzer (lexer) for the the TableGen language in Python, JS and Go so far. The latest post in the series discussed how several years of new Go versions improved my lexer's performance by roughly 2x, and how several additional optimizations won another 37%; the final result is a lexer that churns through 1 MiB of source code in just 5.6 milliseconds. Since I've also b
It's been a while since I've last rewritten my favorite lexical analyzer :-) That post is the last in a series implementing a lexer for the TableGen language in a variety of programming languages, using multiple techniques. The last lexer written, in Go, was very fast indeed - processing 1 MiB of source in about 20 milliseconds. The other day I started wondering whether Go compiler improvements fr
Recently, a new set of sorting functions has landed in Go's golang.org/x/exp/slices package [1]. These functions leverage Go generics to provide a more ergonomic API for sorting (without requiring users to implement sort.Interface), and also deliver a nice performance improvement, as the CL demonstrates. In this post, I'll dive deep into why these generic functions are faster than the existing one
Coding interviews have never been popular in the programming community; I mean, they are prevalent, since many companies still use them to filter candidates, but they are vastly unpopular in the community because people find them too hard, too unfair, too unrepresentative of reality and so on. There are viral stories all around - like when the creator of Homebrew failed Google's interviews [1]. In
Traits are a central feature of Rust, critical for its implementation of polymorphism; traits are used for both static (by serving as bounds for generic parameters) and dynamic (by having trait objects to serve as interfaces) polymorphism. This post assumes some familiarity with traits and discusses only a specific aspect of them - how extension traits affect code readability. To learn the basics
I've been hacking on a small practice project in Rust where I implement the same data structure in several different ways. When testing this project, I want to run exactly the same set of tests on several types that implement the same trait. As a demonstrative example, let's take the following trait: pub trait Calculator { fn new() -> Self; fn add(&self, a: u32, b: u32) -> u32; }
To implement its safety guarantees, the Rust compiler keeps careful track of ownership and references throughout a program. This makes writing certain kinds of data structures challenging; in particular, data structures that have circular references. Let's start with a simple binary tree: struct Tree { root: Option<Node>, } struct Node { data: i32, left: Option<Box<Node>>, right: Option<Box<Node>>
This is the first post in a multi-part series describing the Raft distributed consensus algorithm and its complete implementation in Go. Here is a complete list: Part 0: Introduction (this post) Part 1: Elections Part 2: Commands and log replication Part 3: Persistence and optimizations Raft is a relatively new algorithm (2014), but it's already being used quite a bit in industry. The best known e
This post is going to discuss how to gracefully shut down a TCP server in Go. While servers typically never stop running (until the process is killed), in some scenarios - e.g. in tests - it's useful to shut them down in an orderly way. High-level structure of TCP servers in Go Let's start with a quick review of the high-level structure of TCP servers implemented in Go. Go provides some convenient
Updated (2023-05-08): the Go compiler keeps evolving and it takes time to keep up with changes. While the general gist of this post remains true and it's worth reading to understand how the compiler works on a high level, the details of the modifications are slightly different now. To see up-do-date changes that work with the latest Go (in-development version 1.21 at the time of this update), chec
In this post I want to explore the costs of threads on modern Linux machines, both in terms of time and space. The background context is designing high-load concurrent servers, where using threads is one of the common schemes. Important disclaimer: it's not my goal here to provide an opinion in the threads vs. event-driven models debate. Ultimately, both are tools that work well in some scenarios
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く