Learning from Giants #60
A visual reference of CSS selectors, B-tree B+-tree and binary tree real-world usage in ScyllaDB, an an essay on why writing can be your superpower.
👋 Hi, this is Mathias with your weekly drop of the 1% best, most actionable, and timeless resources to grow as an engineering or product leader. Handpicked from the best authors and companies. Guaranteed 100% GPT-free content.
Did a friend send this to you? Subscribe to get these weekly drops directly in your inbox. Read the archive for even more great content. Also: I share these articles daily on LinkedIn.
CSS Selectors: a visual guide and reference
Every style you apply with Javascript has a more elegant CSS-only alternative. And that's a great way to tell apart senior frontend engineers from React-only tinkerers. They have a deep knowledge of CSS selectors.
“CSS selectors are patterns used in CSS to select and style HTML elements on a page."
And with every new browser version comes a new set of CSS language extensions, including many new selectors. So they're something you must learn and re-learn.
Along with traditional CSS selectors, CSS has pseudo-classes and pseudo-elements. They're called pseudo because they're not user-applied classes nor actual HTML elements but can be selected precisely like classes and elements.
“Pseudo-classes allow us to define styles based on an element's state or its relation to other elements. [...] Pseudo-classes start with a colon character (:)."
“Pseudo-elements give you the power to target and style specific parts of an element, such as its first line or before and after its content. Pseudo-elements start with two colons (::)."
📗 Sébastien Noël's CSS Selectors: A Visual Guide & Reference describes the most popular and useful CSS selectors. It's an effective way to grow your frontend engineering skills and replace your 100-line Javascript style functions with an elegant CSS solution.
The taming of the B-trees
B-trees, binary trees, what’s the difference? Let's learn from engineers who have had to make this critical decision to build a database: Scylla DB.
"One of the core components that greatly affects ScyllaDB's performance is the in-memory cache of the user data (we call it the row cache). And one of the key factors to achieving the performance goal is a good selection of collections".
Let's start with definitions.
A binary tree is a tree data structure in which each node has at most two children.
The tree is called a B-tree when the number of children per node is higher than two. Fun fact: the "B" doesn't stand for anything officially; it's just "B".
"The common belief about binary vs B- trees is that the former ones should be used when the data is stored in the RAM, whilst the latter trees should live in the disk. [...] However, there are many reasons why B-trees are often a good choice for in-memory collections."
With newer hardware and all datasets getting larger, B-trees and their variants can significantly improve performance over binary trees.
"On a B-tree, this search will consist of two phases — intra-node search and descending the tree — executed one after another."
“The two-phased B-tree search can be made better with respect to branch predictions. The trick is in making the intra-node search linear, i.e. walking the array of keys forward key-by-key. In this case, there will be only a "should we move forward" condition that's much more predictable."
And with SIMD instructions doing linear search on up to 64 values simultaneously, that intra-node search can be further optimized to give B-trees a big edge.
📗 Pavel Emelyanov's The Taming of the B-Trees goes further than describing how great B-trees can be. The rest of the article describes B+-trees, a variant of the B-trees that only have values on leaf nodes and the solutions the Scylla engineers had to develop to use B+-trees in production. Academic theory often needs real-world adaptation that companies rarely share, making the post even more valuable.
Why write?
"Why write an essay when you can type a few words and have AI generate one for you?"
Writing is a lot more than coming up with words and sentences. The process can create a higher value than output. Let's explore why:
“Writing is not just a vehicle to share ideas with others but also a way to understand them better yourself."
Writing requires the compression of an idea." That compression requires deep understanding of the essence of the topic.
Why write in the ocean of mediocre AI-generated content? Why now?
Think about it: if no one understands anything to the level of being able to write about it anymore, this can be your superpower.
📗 Farnam Street's Why Write is a quick reminder that the value of writing goes beyond sharing content with the world. The profound personal impact is almost more valuable; it's like journaling. Write about what you did and what you'll do. Write about your strategy.