最新文章

今日新增 446 篇 · 共 7,325 篇 · 来自 241 个博客

Mara Bos·

Compile time unit arithmetic in C++

AI 摘要The article builds on Bjarne Stroustrup's technique from Software for Infrastructure, which uses C++ templates to make the compiler aware of value units, allowing it to verify consistent usage and prevent disasters like NASA's 1999 unit-mixing error. The author extends this idea to support any number of base units and linearly related units (such as centimetres, metres, and inches) by teaching the compiler to perform arithmetic on units at compile time.

Andrew Kelley·

Do Not Use bodyParser with Express.js

AI 摘要The article warns that Express.js's bodyParser middleware creates temporary files on disk for every multipart request, even on endpoints that don't handle uploads, allowing attackers to exhaust disk space and crash the server. It presents several mitigations, including manually deleting temp files, scheduling cleanup utilities like tmpwatch or reap, using the defer option, or parsing uploads directly with modules like multiparty, busboy, parted, or formidable. The recommended approach is to avoid the deprecated bodyParser and instead explicitly use only the middleware needed, such as express.json() and express.urlencoded().

Andrew Kelley·

JavaScript Callbacks are Pretty Okay

AI 摘要The author argues against recent criticism of JavaScript callbacks, claiming they are perfectly workable if you follow two simple rules of thumb: avoid nontrivial anonymous functions and place all function declarations after the synchronous code that does the actual work. Through examples refactoring deeply nested callback code, the author shows these rules make async JavaScript easy to read. The article also argues that the downsides of compile-to-JS languages—such as reduced contributions, harder code evaluation, and added build steps—often outweigh their benefits.

Andrew Kelley·

I am not a "JavaScript Developer".

AI 摘要The author objects to being labeled a "JavaScript Developer" by GitHub and recruiters, explaining that JavaScript is just one of many tools he uses depending on the problem at hand. He describes himself as a generalist and problem solver who has built nontrivial projects across many languages and frameworks, and insists that if he must be called anything, it should be "Problem Solver" or "Software Developer" rather than being defined by a single technology.

Sara Soueidan··Sara Soueidan

Building A Circular Navigation With CSS Transforms

In this article, we will learn how to apply CSS transforms to fake a "slice" shape, creating a circular navigation using nothing but CSS (and some maths!). The article includes an interactive demo that explains visually and step by step how

Andrew Kelley·

7dRTS Game Reviews

AI 摘要This article is a one-person review guide to 7dRTS (7-day real-time strategy) games, sorting them into categories ranging from must-play titles like Chess Play, Holo Wars, and Pillagers!, to games that are merely worth a look, not yet playable, or impossible to run. The reviewer praises entries with simple, polished gameplay, good tutorials, and browser accessibility, while criticizing overly difficult, unfinished, or glitchy games. Many titles couldn't be tested at all because the review was done on a Linux system and those games required Windows, .NET, or the Unity web player.

Andrew Kelley·

Pillagers! 7dRTS Game Development Journal

AI 摘要The author chronicles five days of developing 'Pillagers', a browser-based game combining space physics with real-time strategy for the July 2013 7-Day RTS Challenge, working with collaborator Michael Weber on sound, music, and atmosphere. Using a custom canvas-based engine called 'chem' and open-sourcing the code on GitHub, they progressively added ship classes with combat AI, levels, portals, a mini-map, sound effects, and win/lose conditions. Key milestones included fixing a memory leak that tanked the framerate to 16 FPS, adding Sandbox and dogfighting modes, and inviting players to test the game in their browser and provide feedback.

Mara Bos·

C++11: Rvalue references for *this

Recently, gcc added support rvalue references for *this. (Clang has supported it for quite a while now.) In this post, I show how to use this feature, and how it means we can finally define accessors and a few other things like operator= co

Andrew Kelley·

Private Methods in JavaScript

AI 摘要The article demonstrates that JavaScript can have truly private methods without the underscore convention by defining plain helper functions within the same scope (e.g., module) and passing the instance explicitly, which also simplifies callback handling. Benchmarks show this approach has no performance penalty compared to prototype methods. In environments without scoping, such as a browser

Elixir Blog··José Valim

Elixir v0.10.0 released

Elixir v0.10.0 is out with support for streams, sets, pretty printing and many improvements for Mix and ExUnit.

Andrew Kelley·

Spot the Fail

AI 摘要The author shares a lighthearted blog post titled 'Spot the Fail,' featuring screenshots of comically dumb programming mistakes they've made, with each fail being identifiable even without code context. The collection includes 16 examples such as missing break statements, incorrect operators, swapped variables, off-by-one errors, and wrong array indexing. The post ends by recalling Quixey's old hiring promotion that paid $100 for spotting a fail in one minute.

Andrew Kelley·

Statically Recompiling NES Games into Native Executables with LLVM and Go

AI 摘要This article presents original research into statically disassembling and recompiling Nintendo Entertainment System games into native executables using LLVM IR and a toolchain built in Go, rather than writing a traditional runtime emulator. The author walks readers through the entire process in a 'build it together' fashion, covering NES architecture basics, the 6502 CPU, memory-mapped I/O, creating a custom ABI for testing, and writing an assembler with a lexer and parser, while addressing challenges such as runtime address checks, parallel subsystems, interrupts, and jump tables. The work culminates in a demonstration of Super Mario Bros. running as native machine code, though mapper support remains an unsolved challenge.

Elixir Blog··José Valim

Elixir v0.9.0 released

Elixir v0.9.0 is released with support for reducers, umbrella projects, faster compilation times and dropped support for R15 and earlier OTP versions.

Elixir Blog··José Valim

Elixir on Xen

The Erlang on Xen team has added support for Elixir and we will tell you how you can use it.

Sara Soueidan··Sara Soueidan

Lessons from the “Seductive Interaction Design” Book

AI 摘要The article is a review of Stephen P. Anderson's book 'Seductive Interaction Design,' which explains how psychological principles behind human attraction and motivation can be applied to create engaging user experiences for websites and applications. Using examples like LinkedIn, iTunes, and Typeform, the author covers concepts such as progress dynamics, sequencing, feedback loops, and the distinction between usability and psychology in design. The review also highlights the first 'weapon of seduction,' aesthetics, showing how visual cues like shadows, gradients, and proximity communicate functionality and influence users' emotions and behavior.