惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 最新话题
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
L
Lohrmann on Cybersecurity
博客园 - 【当耐特】
P
Privacy & Cybersecurity Law Blog
V2EX - 技术
V2EX - 技术
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cloudbric
Cloudbric
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
Webroot Blog
Webroot Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
The Hacker News
The Hacker News
MyScale Blog
MyScale Blog
Vercel News
Vercel News
B
Blog RSS Feed
F
Fortinet All Blogs
Google DeepMind News
Google DeepMind News
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
博客园 - 三生石上(FineUI控件)
D
Docker
O
OpenAI News
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
AI
AI
T
Tor Project blog
Project Zero
Project Zero
H
Heimdal Security Blog
Latest news
Latest news
NISL@THU
NISL@THU

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
You Don't Use Linked Lists. But They're Running Half Your Software.
Islam Hafez · 2026-06-27 · via DEV Community

The data structure everyone learns for interviews and forgets by Monday — and why that's exactly backwards.


Here's the honest version of what most linked list tutorials skip:

You are almost certainly never going to write a linked list in JavaScript. Not in production. Not in a side project. Your language's built-in array already handles dynamic sizing, and it does it faster than a linked list in most cases, for reasons we'll get into. The interview circuit trained you to implement one on a whiteboard, and that's fine — but it created the wrong mental model. You walked away thinking linked lists are a data structure you might use. They're actually a data structure you need to understand — because they're hiding inside the tools you use every day, and knowing they're there changes how you reason about performance.

Your browser's back/forward navigation? Doubly linked list. Your text editor's undo history? Doubly linked list. The LRU cache inside every high-traffic web server, CDN, and database query optimizer? A doubly linked list fused with a hash map. Redis's LPUSH/RPUSH commands operate on a linked list. The Node.js event queue has linked list characteristics. The Linux kernel's process scheduler uses circular doubly linked lists internally.

They're not a relic. They're infrastructure. You just can't see them because they're one layer below where you usually work.

So let's learn them the right way — starting with the hardware, not the textbook.


Why Memory Layout Is the Whole Story

Before you write a single node, you need to understand the one thing that determines when a linked list wins and when it loses: cache locality.

Your CPU doesn't read from RAM one byte at a time. It's too slow for that — a RAM access takes 200–300 CPU cycles, while a cache hit takes 4. So the CPU plays a prediction game: when you access a memory address, it automatically pulls in the surrounding 64 bytes (a "cache line") on the assumption that you'll need nearby data next. This is called spatial locality, and it's why arrays are fast.

When you store an array of numbers, they sit next to each other in memory. When you loop over them, the CPU loads the first element — and gets the next 15 for free in the same cache line. It's reading ahead before you even ask.

Array in memory:
[ 10 | 20 | 30 | 40 | 50 | 60 ] → contiguous, cache-friendly
  ^                               one cache fetch, all 6 loaded

A linked list destroys this. Each node is a separate heap allocation, scattered wherever the allocator found space. Following a next pointer means jumping to an arbitrary memory address — potentially on a completely different cache line, triggering a new RAM fetch, costing those 200–300 cycles, every single time.

Linked list in memory:
[10 | ptr] ──→ [20 | ptr] ──→ [30 | ptr]
 0x1a04          0x7f82         0x3c11
 (separate allocations, scattered across memory)

In practice, benchmarks consistently show linked list traversal running 10–100x slower than array traversal for large datasets — even though both are O(n) on paper. Big-O notation lies to you about this. It ignores constants, and the constant for "RAM access" is enormous on modern hardware.

This isn't a reason to dismiss linked lists. It's the reason to understand exactly when their advantages outweigh this cost. That answer is more specific than most tutorials admit.


Singly Linked List — The Minimal Form

A singly linked list is a chain of nodes where each node holds data and a pointer to the next node. That's it. No backward travel. No shortcuts.

class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

class SinglyLinkedList {
  constructor() {
    this.head = null;
    this.size = 0;
  }

  // O(1) — we know exactly where the head is
  prepend(value) {
    const node = new Node(value);
    node.next = this.head;
    this.head = node;
    this.size++;
  }

  // O(n) — must walk to the end
  append(value) {
    const node = new Node(value);
    if (!this.head) {
      this.head = node;
    } else {
      let current = this.head;
      while (current.next) current = current.next;
      current.next = node;
    }
    this.size++;
  }

  // O(n) — must walk to find it
  delete(value) {
    if (!this.head) return;

    if (this.head.value === value) {
      this.head = this.head.next; // drop the head, O(1)
      this.size--;
      return;
    }

    let current = this.head;
    while (current.next) {
      if (current.next.value === value) {
        current.next = current.next.next; // skip the node, O(1) once found
        this.size--;
        return;
      }
      current = current.next;
    }
  }

  toArray() {
    const result = [];
    let current = this.head;
    while (current) {
      result.push(current.value);
      current = current.next;
    }
    return result;
  }
}

Notice something about delete: finding the node is O(n), but the actual removal is O(1) — you just redirect one pointer. No shifting. No copying. No reorganizing memory. Compare that to an array, where deleting from the middle means shifting every subsequent element one position left — O(n) work even after you found the element.

This is the trade-off in one sentence: linked lists pay for access with their insertion/deletion advantage.

The singly linked list's natural shape is a stack — you push and pop from the head, both O(1), never need to go backward. It also fits a task queue where you only ever consume from one end.

What it genuinely can't do: random access. If you want the 500th element, you walk 500 nodes. There's no formula. This alone disqualifies singly linked lists from most use cases where you're searching or indexing.


Doubly Linked List — Where It Gets Actually Useful

Add a prev pointer to every node and something real changes: you can traverse in both directions, and — critically — you can remove a node in O(1) if you already have a reference to it.

class DNode {
  constructor(value) {
    this.value = value;
    this.next = null;
    this.prev = null;
  }
}

class DoublyLinkedList {
  constructor() {
    this.head = null;
    this.tail = null;  // tail pointer makes append O(1)
    this.size = 0;
  }

  // O(1) — we hold both ends
  prepend(value) {
    const node = new DNode(value);
    if (!this.head) {
      this.head = this.tail = node;
    } else {
      node.next = this.head;
      this.head.prev = node;
      this.head = node;
    }
    this.size++;
  }

  // O(1) — tail pointer, no walking required
  append(value) {
    const node = new DNode(value);
    if (!this.tail) {
      this.head = this.tail = node;
    } else {
      node.prev = this.tail;
      this.tail.next = node;
      this.tail = node;
    }
    this.size++;
  }

  // O(1) — given the node directly, no searching required
  removeNode(node) {
    if (node.prev) node.prev.next = node.next;
    else this.head = node.next; // it was the head

    if (node.next) node.next.prev = node.prev;
    else this.tail = node.prev; // it was the tail

    node.next = node.prev = null;
    this.size--;
  }

  // O(1) — both ends accessible instantly
  removeHead() { if (this.head) this.removeNode(this.head); }
  removeTail() { if (this.tail) this.removeNode(this.tail); }
}

The removeNode(node) method is the entire reason doubly linked lists exist in serious systems. When you have a direct reference to a node — not a value you need to search for, but the actual node object — deletion is just pointer surgery. Four pointer updates. Done.

This changes everything for the use case that actually matters.


The One Pattern Where Linked Lists Are Irreplaceable

The LRU (Least Recently Used) cache is the canonical real-world use case — and it's worth understanding in detail because it appears in CDN edge nodes, database query planners, CPU cache replacement policies, DNS resolvers, and web server in-memory caches.

The problem: you have a cache with limited capacity. When it's full and you need to add something new, you evict the item that was accessed least recently. You need:

  • O(1) lookup: "Is this key in the cache?"
  • O(1) insert: "Add this new key-value pair"
  • O(1) eviction: "Remove the least recently used item"
  • O(1) promotion: "This key was just accessed, move it to 'most recently used'"

An array can't do this. When you access an item, you need to move it to the "recently used" position — that's O(n) shifting. A hash map alone can't do it either — it has no concept of order.

The solution is a doubly linked list paired with a hash map:

class LRUCache {
  constructor(capacity) {
    this.capacity = capacity;
    this.map = new Map();       // key → node (O(1) lookup)
    this.list = new DoublyLinkedList(); // ordered by recency
  }

  get(key) {
    if (!this.map.has(key)) return -1;

    const node = this.map.get(key);
    this.list.removeNode(node);   // O(1) — we have the node directly
    this.list.prepend(node.value); // O(1) — move to head (most recent)
    this.map.set(key, this.list.head);

    return node.value.val;
  }

  put(key, val) {
    if (this.map.has(key)) {
      this.list.removeNode(this.map.get(key)); // O(1)
    } else if (this.list.size >= this.capacity) {
      // evict the tail — it's the least recently used
      this.map.delete(this.list.tail.value.key);
      this.list.removeTail(); // O(1)
    }

    this.list.prepend({ key, val }); // O(1)
    this.map.set(key, this.list.head);
  }
}

Every operation is O(1). The hash map gives instant lookup. The doubly linked list maintains order and provides O(1) removal because we store the node reference in the hash map — we never search for the node, we go directly to it.

This is the move that makes the whole structure work. The hash map stores node references, not values. When we access a key, we pull the node directly out of the middle of the list and move it to the head — no traversal. That's only possible with a doubly linked list where removeNode doesn't require knowing where the node is in the sequence.


The Honest Comparison

Most tutorials give you a comparison table. Here's one that's actually honest about modern hardware:

Operation Array Singly LL Doubly LL
Access by index O(1) O(n) O(n)
Search by value O(n) O(n) O(n)
Insert at head O(n) — shift all O(1) O(1)
Insert at tail O(1) amortized O(n) or O(1) w/ tail ptr O(1) w/ tail ptr
Delete at head O(n) — shift all O(1) O(1)
Delete in middle (by value) O(n) find + O(n) shift O(n) find + O(1) remove O(n) find + O(1) remove
Delete by node reference O(1) ← the whole game
Memory per element Low (just data) Medium (+1 pointer) Higher (+2 pointers)
Cache performance Excellent Poor Poor
Traversal speed in practice ~10–100x faster Slow Slow

The "delete by node reference" row is the one that matters. It's the entire reason doubly linked lists exist in production systems. Everything else, arrays do better or equal for most workloads — because of cache locality, not because of Big-O.

If you're choosing between array and linked list for a problem where you're iterating through data, an array wins even if your Big-O analysis says they're equal. The constant factor of cache performance is that significant.


When to Actually Use Each One

Reach for a singly linked list when:

  • You're building a stack and want textbook clarity (though an array works fine here too)
  • You're implementing something where you only ever add/remove from one end
  • Memory is extremely tight and you can't afford the extra prev pointer

Reach for a doubly linked list when:

  • You need O(1) deletion and you'll have direct node references (LRU cache, undo history where each action holds its own node)
  • You're building anything that requires backward traversal without a second pass
  • You're implementing a deque (double-ended queue) with O(1) operations at both ends

Don't reach for either when:

  • You're just storing and iterating over data — use an array
  • You need frequent random access — use an array
  • You're searching by value — use a hash map or sorted array with binary search

The deeper point: linked lists are most valuable not as standalone structures but as the ordered component inside composite structures. The LRU cache doesn't use a linked list instead of a hash map — it uses them together. That combination produces something neither could achieve alone. That's the real lesson.


Where They're Already Running in Your Stack

Without writing a single line of linked list code, these structures are running around you right now:

Node.js — The timers module maintains doubly linked lists to track setTimeout/setInterval expiry. The http module uses them for connection pools.

V8 (Chrome's JS engine) — The garbage collector uses linked list-like structures to track object generations and manage the free list of available memory blocks.

RedisLPUSH/RPUSH/LPOP/RPOP operate on a linked list. Redis lists are actually a hybrid (ziplist for small sizes, linkedlist for large), but the interface is a linked list.

Linux kernel — The process scheduler's run queue is a doubly linked list. The list_head structure in the kernel source is one of the most used data structures in any OS codebase.

Your browser's navigation — Every window.history.back() and window.history.forward() is a doubly linked list traversal.

You've been using linked lists constantly. You just didn't know their name.


The Real Reason to Learn This

Interview prep is the wrong motivation to learn linked lists. The right motivation is this: understanding why a doubly linked list paired with a hash map gives you O(1) everything for an LRU cache — that kind of reasoning is what separates engineers who design systems from engineers who just implement requirements.

When someone at a senior system design interview says "we need an LRU cache with O(1) get and put" and you immediately know the structure — and, more importantly, you know why that structure works at the hardware level — that's not trivia. That's thinking.

The data structure is simple. The thinking behind it isn't.


Code examples are in JavaScript for readability. The concepts apply identically in Python, Go, Rust, or any other language. In production systems you'd typically use the language's built-in deque or list structures rather than rolling your own — but understanding the internals is exactly the point.


Cheers !