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

推荐订阅源

N
News and Events Feed by Topic
Malwarebytes
Malwarebytes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
F
Future of Privacy Forum
C
Cisco Blogs
T
The Exploit Database - CXSecurity.com
A
Arctic Wolf
S
Securelist
K
Kaspersky official blog
S
Schneier on Security
T
ThreatConnect
T
Tenable Blog
Spread Privacy
Spread Privacy
T
True Tiger Recordings
AWS News Blog
AWS News Blog
F
Fox-IT International blog
量子位
T
Threatpost
V
Vulnerabilities – Threatpost
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
GbyAI
GbyAI
宝玉的分享
宝玉的分享
腾讯CDC
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
Cyberwarzone
Cyberwarzone
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
U
Unit 42
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
The Register - Security
The Register - Security
MyScale Blog
MyScale Blog
小众软件
小众软件
A
About on SuperTechFans
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
美团技术团队
Google Online Security Blog
Google Online Security Blog
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

DEV Community

Why Most AI Music Tools Feel Wrong to Developers How I Use Antigravity 2.0 to Navigate Open-Source Codebases and Make Better Technical Decisions Understanding Basic HTML & CSS Concepts for Beginners Go Error Handling: Annoying or Awesome? Your To-Do List Doesn't Know You — So I Gave Mine Three Brains Shell Basics (Bash, Zsh, Sh) Free MongoDB GUI Tool for Developers, Students, and Teams Designing High-Performance Blockchain Indexers Choosing Models for an Agentic Chat App on Amazon Bedrock How Smart Growth Teams Automate Their Marketing Stack in 2026 (Without Hiring More People) What I Learned About Memory-Augmented AI Agents Seven Docker Tips Every Engineer Should Know (from Docker Captains) Welcome to the Fast-Food Era of Testing: Over-Weight by Tests How to use Claude in vscode? Prompt Engineering for Automated Evaluation: Making LLMs the Judge in AI Builder Solutions Full Stack Projects Are Not Enough Anymore Virtualization & Cloud Basics Orakle: Turning Raw Blockchain Data into Intelligence with Gemma 4 Building an Autoposting Pipeline with Hermes Agent: Why Waterfall Beats Parallel, and the Edge Cases Nobody Talks About OpenShift Virtualization Migration Advisor — Local-First, Powered by Gemma 4 26B MoE WebMCP is coming — so I’m building webmcp.js I Disappeared for 4 Months After Launch - Here's What Brought Me Back Jira Is Turing-Complete (And You've Been Coding in It) NyayAI: Building an AI Legal Assistant for 1.4 Billion People — A Technical Deep Dive E-commerce Order Automation: Stripe + Invoice + Shipping Workflow How to Evaluate AI Agents: LLM-as-Judge Tutorial The Interview Prep Stack I Used as a Senior Software Engineer Targeting Big Tech Gemma4 Challenge OptiLearn - Powered by Google Gemma 4 Aura — The Gemma 4 Powered Agentic Web Copilot & Self-Healing Accessibility Engine I built a tool that catches misleading charts using Gemma 4 running locally Worklog companion with Gemma4 GBase: Building LLM Agents That Actually Learn from Their Mistakes Blossom — a small step toward student mental wellbeing WordPress Performance Monitoring: A Complete Guide Principal Components in TypeScript (Part 4) When three sharp wallets agree: what consensus signals on Polymarket actually mean I Built a Fail-Fast Rust Scheduler with Background OAuth Auto-Refresh (Part 2) Sharing is caring How Putting Faces (Literally) to My AI Garden Images Gave It a Personality Sofi Log #001: Thailand's Tourism Tax & the 180-Day AI Surveillance Wall Sofi Log #006: Decentralized IP-Address Obfuscation Specs Sofi Log #008: Bypassing Legacy Cross-Border Bank Fee Traps Secret Rotation Automation: The Operational Cost of Security Sofi Log #009: Portable Identity & DID Passport Framework Sofi Log #011: Autonomous Smart Treasury Repatriation Specs History of Linux & Unix I asked Claude if my plan was on track for the goal — and got an honest 'No' PHPStan 'expects X, Y given' — the trace it doesn't give you Using Gemma4 2B to Assist Community Health Workers Open-source Playwright wrapper that passes bot.sannysoft.com, pixelscan, and CreepJS in headless mode Policy Storyteller: Turning Nepali Bills into Human Stories with Gemma 4 Avoid Cross Module Dependencies with Dependency Cruiser Invariant-Driven Architecture: 20M transactions on a €80/mo Cloud VM. Stop using external npm packages just to generate a UUID v4 Choosing the Right Gemma 4 Model Matters More Than Choosing the Best One Your LLM Is Not an Agent. Your Framework Is Not Enough. You Need a Harness. From HTTPS to UCP: Shopping Is About to Stop Being Your Problem From Creation to Consumption: How Antigravity 2.0 and Gemini Spark Are Defining the Agentic Era 10 Mistakes I Wish I Knew Before Taking the CKA Exam AI That Actually Does Stuff: Autonomous Agents Explained Exploring AI workflow Orchestration: Comparing Weft, Python & Alternative Pipeline Approaches El Poder del Aprendizaje Federado: Cuando los Algoritmos Distribuidos Entrenan a la IA Email Marketing Automation in 2026: 5 Tools (and 1 Self-Hosted) Through Their APIs A Replay Runbook For Missed Publishing Windows Why timeout handling matters more than most backend logic How I Make $6,800/Month Selling Niche VS Code Extensions Model Routing Cost Checklist: Hosted APIs, Open Models, Or Self-Hosted Inference? ORA-00207 오류 원인과 해결 방법 완벽 가이드 Deno 2.8 Operator Upgrade Checklist: CI, Lockfiles, Node Compatibility, And Rollback AI-Discovered Vulnerabilities Need A Triage Queue, Not A Panic Channel AI Agent Workboards Need Audit Controls Before They Need More Agents Demystifying DevRel: What It Actually Is (And Why Should You Become One?) Your AI, Your Device, Your Data - Introducing Aide Gemma 4 GenAI Coach - GenAI Concepts Made Easy with an Interactive Playground QuietPulse - Mood Tracker Principal Components in TypeScript (Part 3) The pgAudit Attribution Gap: Why Role-Level Logging Fails GDPR and How to Close It Gemma 4 CAD Orchestrator I built a local Postgres triage co-pilot because HIPAA says I can't paste plans into ChatGPT or Claude Live Holographic Editor In Fractal Time Everbench: A document management system with Local Intelligence Instanton in Fractal Time The Hidden Features of Claude How I Built an AI News Brief with Next.js, Supabase, Vercel, and GPT-4o-mini How We Built a Multi-Agent AI Documentation System (And What We Learned) I got tired of writing post-mortems — so I built RCAi for SREs MIA: A Futuristic AI Desktop Assistant Built with Voice, Gestures, and Controlled Chaos Best Programming Language for Backend Web Development: PHP vs Python PayPal Alternatives for Indian Businesses: Best Payment Gateways for International Card Payments (2026) Gemma 4 Made Me Rethink Local AI: Not Just Text, But Images Too Clean Architecture in .NET Explained (The Dependency Rule) I Compiled Rust to WebAssembly and Made My JavaScript 6 Faster Outlook.com Is the Final Boss of 'Just Send an Email' Conditional Statements and Control Flow in Python Insults & Cutlasses, Local LLM Sword Fighting on Melee Island Production Lab: ECS Fargate + Prometheus + Grafana + Loki + Alloy + Node Exporter How 12 AI agent frameworks handle human approval (most badly) The Four-Index Reality: Why AI Search Isn't One Thing I Scanned 1 Million AI Services. Here's What Worries Me More Than the Vulnerabilities
Goroutines vs. Promises: Why Go and JavaScript Look at Concurrency Completely Differently
Juma Evans · 2026-05-25 · via DEV Community

Handling concurrency is one of the most critical decisions in modern software architecture. When applications need to handle thousands of simultaneous tasks—like serving HTTP requests, streaming data, or background processing. The design of a language’s concurrency model dictates how easily developers can write fast, safe, and maintainable code.
​Go is famous for making concurrency a native, deeply integrated primitive through goroutines and channels. To truly appreciate Go's design, it helps to contrast it with JavaScript, which handles concurrency using a completely different philosophy: a single-threaded Event Loop fueled by asynchronous non-blocking I/O.
​Here is an architectural deep dive into Go's multi-threaded concurrency engine and how it measures up against JavaScript's single-threaded asynchronous model.

Part 1: The Foundations of Go Concurrency
​Go’s concurrency model is based on a paper by C.A.R. Hoare called Communicating Sequential Processes (CSP). The core philosophy of CSP in Go can be summarized by its most famous mantra:
"Do not communicate by sharing memory; instead, share memory by communicating."
​Instead of having multiple threads fight over the same piece of memory using complex locks, mutexes, and semaphores, Go encourages developers to run independent processes (goroutines) that pass data back and forth through safe conduits (channels).

Primitives: Goroutines and Channels
​Go replaces heavy, operating system-level threads with goroutines.
​Goroutines: They are incredibly lightweight, starting with a stack size of just a few kilobytes (typically 2KB), which can grow and shrink dynamically. Because they require so little overhead, a single Go application can easily spin up hundreds of thousands of concurrent goroutines without exhausting system memory.
​Channels: These are typed pipelines that allow goroutines to synchronize and exchange data. By default, channels are unbuffered, meaning a sender will block until a receiver is ready to take the data, creating natural synchronization points without manual locks.
​The Magic Under the Hood: The M:N Scheduler
​Go achieves this high efficiency using its internal Go Runtime Scheduler, often referred to as the GMP Model:
​G (Goroutine): Represents the goroutine, its stack, and current status.
​M (Machine): Represents a physical, OS-level thread managed by the operating system kernel.
​P (Processor): Represents a logical resource or context required to execute Go code. The number of Ps usually matches the machine's physical CPU cores.
​The scheduler assigns multiple goroutines (G) onto a smaller pool of OS threads (M) via the logical processors (P).
​If a goroutine performs a blocking action, such as waiting for a network response or a file read—the Go runtime is smart enough to swap out that blocked goroutine, move the remaining active goroutines to a different OS thread, and keep the CPU busy. This concept is known as work-stealing, and it happens completely automatically behind the scenes.

Part 2: Go Concurrency in Action
​Writing concurrent code in Go requires very little boilerplate. You simply prefix a function call with the go keyword.
​Here is a practical pattern: a worker pool where multiple concurrent workers process jobs sent via a channel, and report their progress safely.

package main

import (
"fmt"
"sync"
"time"
)

// worker processes incoming jobs from the jobs channel
func worker(id int, jobs <-chan int, results chan<- int, wg *sync.WaitGroup) {
defer wg.Done() // Signal completion when the worker exits

for job := range jobs {
    fmt.Printf("Worker %d started job %d\n", id, job)
    time.Sleep(time.Millisecond * 100) // Simulating an I/O task
    results <- job * 2
}

Enter fullscreen mode Exit fullscreen mode

}

func main() {
numJobs := 5
jobs := make(chan int, numJobs)
results := make(chan int, numJobs)

var wg sync.WaitGroup

// Spin up 3 concurrent workers
for w := 1; w <= 3; w++ {
    wg.Add(1)
    go worker(w, jobs, results, &wg)
}

// Send jobs to the channel
for j := 1; j <= numJobs; j++ {
    jobs <- j
}
close(jobs) // Closing tells workers no more jobs are coming

// Wait for all workers to finish in the background
go func() {
    wg.Wait()
    close(results)
}()

// Collect all results
for res := range results {
    fmt.Printf("Result processed: %d\n", res)
}

Enter fullscreen mode Exit fullscreen mode

}

Part 3: The Contender
How JavaScript Handles Asynchrony
​While Go provides a multi-threaded runtime that automatically abstracts away hardware limitations, JavaScript takes an entirely opposite approach. JavaScript's core philosophy is single-threaded simplicity driven by an Event Loop.
​JavaScript operates on exactly one thread of execution (the main thread). It cannot natively execute two mathematical formulas simultaneously on different CPU cores. To prevent this single thread from freezing when downloading data or reading files, JavaScript relies on Asynchronous Non-Blocking I/O.

Primitives: Promises and Async/Await
​Instead of lightweight threads, JavaScript relies on Promises and state management.
Promises: A Promise is an object representing the eventual completion (or failure) of an asynchronous operation. When a network request is fired, JavaScript leaves a Promise placeholder and immediately frees up the main thread to handle other UI interactions or requests.
Async/Await: Syntactic sugar built over Promises. When you mark a function as async, it pauses execution inside that specific function when it hits an await keyword, returning control of the main thread back to the runtime execution engine until the background task is ready.

The Engine: The Event Loop
​Because JavaScript doesn't have a multi-threaded scheduler, it passes heavy lifting (like cryptography, network calls, or disk interactions) off to its container environment (the browser's Web APIs or Node.js background thread pool).
​Once those background operations finish, they drop their callbacks into a Task Queue. The Event Loop constantly monitors the main thread. If the main thread is empty, it grabs the next task from the queue and executes it.
​Let's look at how JavaScript achieves a similar worker execution strategy using Promises and Promise.all:
// Simulating an asynchronous job
async function worker(id, job) {
console.log(Worker ${id} started job ${job});

// Simulating an I/O task (like a database query) using a non-blocking timeout
await new Promise(resolve => setTimeout(resolve, 100));

return job * 2;
}

async function main() {
const jobs = [1, 2, 3, 4, 5];

// Map our jobs into an array of concurrent Promises.
// JavaScript kicks them all off immediately in the background.
const workerPromises = jobs.map((job, index) => {
const workerId = (index % 3) + 1; // Distribute across 3 simulated workers
return worker(workerId, job);
});

// Wait for all background tasks to finish and collect results
const results = await Promise.all(workerPromises);

results.forEach(res => {
console.log(Result processed: ${res});
});
}

main();

Part 4: Head-to-Head Comparison
​To understand which paradigm fits a project best, we have to look at the architectural trade-offs between Go's implicit multi-threaded runtime and JavaScript's single-threaded execution queue.
a. Primary Model & Execution Strategy
The Go Way: Uses Communicating Sequential Processes (CSP). Concurrency is handled by spinning up independent, lightweight threads (goroutines) that communicate safely by passing data through typed conduits called channels.
The JS Way: Uses an Event-Driven Architecture. Concurrency is handled on a single main thread via an Event Loop that relies on Promises and callbacks to manage tasks asynchronously.

b. Hardware & CPU Utilization
​The Go Way: Multi-threaded by default. Go’s built-in scheduler automatically distributes workloads across all available physical CPU cores, allowing for true, simultaneous hardware parallelism.
The JS Way: Single-threaded by default. It executes code on only one CPU core. While it can handle thousands of tasks concurrently by overlapping wait times, it cannot execute tasks simultaneously on the same thread.
c. Task Mechanism & Memory Overhead
The Go Way: Driven by Goroutines, which are managed entirely by the Go runtime rather than the OS. They are incredibly lightweight, starting with a tiny memory footprint of just around 2KB per goroutine.
The JS Way: Driven by Promises and Async/Await. These are not threads, but rather JavaScript object state machines that track the progress of a background task, carrying the memory overhead of the V8 JavaScript engine.

d. Handling Heavy Math and Computation
The Go Way: Excellent. Because it can utilize multiple CPU cores, heavy computations, data processing, or cryptography can run in the background without affecting or slowing down the rest of the application.
The JS Way: Weak. Because everything runs on a single thread, any heavy mathematical calculation or CPU-bound task will completely freeze the Event Loop, stalling the entire application until the calculation finishes.

e.Inter-Task Communication
The Go Way: Features Native Typed Channels. This built-in primitive allows goroutines to pass data to one another seamlessly, acting as a natural synchronization barrier without needing manual memory locks.
The JS Way: Relies on patterns like EventEmitters, Streams, or Async Generators. Because there is only one thread, tasks don't need to coordinate memory access, but streaming data requires using event-based libraries.

f.Task Control and Preemption
The Go Way: Supports Preemption. The Go runtime scheduler is highly intelligent; if it notices a single goroutine is acting greedily and hogging a CPU core for too long, it will forcefully pause it to give other tasks a turn.
The JS Way: Has No Preemption. JavaScript code is strictly cooperative. If a function contains a long, synchronous loop that doesn't include an await keyword, it will hold the entire main thread hostage until it completes.

  1. True Parallelism vs. Non-Blocking Concurrency ​The ultimate mechanical difference is Parallelism vs. Concurrency. ​Go is capable of parallelism. If you have an 8-core CPU processor, Go can run 8 different computing tasks at the exact same millisecond. If one goroutine goes rogue and gets stuck in an infinite mathematical calculation loop, Go's scheduler will forcefully step in (preemption), pause it, and use the other CPU cores to keep your application running smoothly. ​JavaScript is strictly concurrent but serial. It excels at waiting without locking things up. If 1,000 users request data from a database at once, JavaScript fires off all 1,000 queries to the OS database drivers immediately, moves on to do other things, and handles the results one by one as they crawl back. However, if you give JavaScript a heavy mathematical equation to calculate, it cannot delegate it to another core—the entire server or UI freezes completely until that calculation finishes.

​2. Synchronization and Data Safety
​Because Go shares memory across actual physical CPU threads, it introduces the danger of Data Races (two threads trying to change the exact same memory address at the same time). Go provides channels to prevent this, but if developers get careless, they must use manual mutex locks (sync.Mutex) or run Go's runtime race detector (go run -race) to find hidden multi-threading bugs.
​JavaScript completely bypasses data races by design. Because everything ultimately executes on a single main thread, you never have to worry about two blocks of code altering a variable at the exact same millisecond. This completely eliminates a massive category of complex, hard-to-track multi-threading bugs.

​3. Memory & Resource Footprint
​Go's goroutines are remarkably lightweight (~2KB), but they still carry the overhead of an active, multi-threaded runtime scheduler and an internal Garbage Collector that scans heap allocations across threads.
​JavaScript's basic Promises are incredibly cheap state objects, but because JavaScript runs inside engines like Google's V8, its base memory baseline per application instance is significantly larger than a compiled, lean Go binary.
Conclusion: Which tool is right for the job?
​Choose Go if you are building data-intensive microservices, streaming platforms, heavy background computing tools, or high-throughput network APIs. Go gives your application the muscle to exploit your hardware's full multi-core capacity effortlessly.
​Choose JavaScript if you are building fast I/O bound applications like standard CRUD web APIs, web sockets, or real-time chat apps where the vast majority of execution time is spent passing data back and forth from databases. JavaScript keeps code straightforward, predictable, and exceptionally easy to debug.
​Both ecosystems solved the ancient problem of traditional, clunky OS multi-threading, Go by building a highly advanced multi-threaded coordination engine, and JavaScript by proving exactly how much you can achieve on a single thread if you just learn how to wait effectively.