编程 · 最新文章

今日新增 29 篇 · 共 2,698 篇 · 来自 79 个博客

Lea Verou··Lea Verou

Import non-ESM libraries in ES Modules, with client-side vanilla JS

AI 摘要The article explains techniques for importing non-ESM libraries—such as those relying on globals or CommonJS—in browser-based ES Modules using vanilla JavaScript. Global-based libraries can be loaded with a bare import statement for their side effects, while CJS libraries can be handled by stubbing window.module and using dynamic import() (since static imports are hoisted), wrapped in a custom require() helper. The author also shares some gripes with ESM design, such as its lack of backward compatibility, forced strict mode, and same-origin restrictions, while remaining overall enthusiastic about native JS modules.

Svelte Blog·

Svelte <3 TypeScript

AI 摘要Svelte now officially supports TypeScript, its most requested feature, enabling developers to use TypeScript in

Without Boats·

Shipping Const Generics in 2020

AI 摘要The author reflects on RFC 2000, opened over three years ago to define const generics for Rust, noting how much has changed since then, such as const fns being stabilized and consts now being evaluated with miri. Despite years of work, the const generics feature has not yet shipped. However, the author believes a useful subset of const generics is now stable enough to ship in the near term.

Tailwind CSS Blog·

Tailwind CSS v1.5.0

Tailwind CSS v1.5.0 is here, now with component variants, responsive container variants, focus-visible support, and more.

Tailwind CSS Blog·

Introducing Tailwind CSS Typography

AI 摘要Tailwind CSS has released @tailwindcss/typography, a new plugin that makes it easy to style vanilla HTML content with beautiful typographic defaults. Previously, styling articles, documents, or blog posts with Tailwind was a tedious task requiring a keen eye for typography and lots of complex custom CSS.

Lea Verou··Lea Verou

Releasing MaVoice: A free app to vote on repo issues

AI 摘要The author announces the release of MaVoice, a free Mavo app that displays GitHub repository issues as proposals and sorts them by 👍 reactions, UserVoice-style but without the cost. It was built to gather community input on which CSS statistics to study for the Web Almanac 2020, and can be customized for any repo and label via URL parameters. Caveats include a limit of 100 issues that can be accurately sorted due to GitHub API restrictions and no cap on how many issues a user can vote on.

Preshing on Programming··Jeff Preshing

I/O in Plywood

AI 摘要The article introduces the I/O system of Plywood, an open-source C++ framework, positioning it as a modern alternative to the decades-old standard C and C++ runtime I/O libraries. It explains core concepts such as the buffered OutStream and StringWriter classes, adapter-based chaining for newline conversion and character encoding (e.g., writing a UTF-16 file from UTF-8 input), and buffered text reading with InStream and StringReader, illustrated through code examples. The author also highlights design decisions like OutStream objects not being thread-safe, requiring explicit creation via StdOut::binary() or StdOut::text(), and Plywood's general preference for working with UTF-8 text internally.

Lea Verou··Lea Verou

The Cicada Principle, revisited with CSS variables

AI 摘要The article revisits the Cicada Principle—the idea that using prime numbers for repeating-unit sizes maximizes the appearance of organic randomness—and shows how to implement it with CSS variables and nth-child()/nth-of-type() selectors. The author demonstrates the technique by pseudo-randomizing the clip-path angles of code snippets on their blog, then shares further experiments including randomized color swatches, border-radius, and snowfall animations. Larger primes produce a better illusion of randomness but require more selectors, and the author outlines two approaches—one that varies primes per value and one that varies offsets—which trade off between flexibility and avoiding gaps in variation.

Travis Downs··Travis Downs

A Concurrency Cost Hierarchy

AI 摘要The article introduces a taxonomy of six performance levels for concurrent operations, each roughly an order of magnitude slower than the previous, illustrated through benchmarks of safely incrementing a shared integer counter across threads on Intel and Graviton hardware. Starting at level 2 (contended atomics such as mutexes, atomic increments, and CAS), the author shows that contended access to shared cache lines sets a baseline cost of around 125 nanoseconds, while fair locks that trigger system calls on nearly every operation (level 3) are an order of magnitude slower. The article then moves on to level 4, where lock implementations force costly context switches between threads.

Without Boats·

Ringbahn II: the central state machine

AI 摘要This article is the first in a series examining the mechanisms behind ringbahn, a safe API for using io-uring from Rust. It focuses on the core state machine that makes ringbahn memory safe, highlighting the key Ring and Completion types involved.