John Cox

Blogs · @wyome

Tagged programming · everything

Cargo-Culting in JavaScript - Tuts+

The article argues that JavaScript developers often blindly follow programming conventions—like always using strict equality, checking `typeof x === 'undefined'`, or including `hasOwnProperty` in loops—without understanding the underlying language mechanics that make these rules necessary. By examining specific cases where dogmatic adherence to form creates unnecessary code, the author demonstrates that developers gain more power and write cleaner code when they understand JavaScript's actual behavior well enough to make contextual decisions rather than applying one-size-fits-all rules. The piece concludes by advocating that we should write for an audience of competent developers seeking to learn, not defensive code that assumes incompetence, and that deepening language knowledge is the only way to escape cargo-cult programming.

Permalink

jQuery 1.10.0 and 2.0.1 Released | Official jQuery Blog

jQuery released versions 1.10.0 and 2.0.1 simultaneously, aiming to synchronize features between the 1.x branch (which supports older browsers including IE6-8) and the 2.x branch (modern browsers only). The releases include improvements like relaxed HTML parsing, increased modularity allowing custom builds to exclude certain methods, fixes for browser-specific bugs like IE9's iframe focus issue, and numerous bug fixes across Ajax, selectors, DOM manipulation, and event handling.

Permalink

Statistical Formulas For Programmers

This page collects classical statistical formulas commonly needed by programmers to properly report and analyze data, organized into five categories: reporting averages (standard deviation, confidence intervals, t-tests), proportions (binomial and multinomial confidence intervals, chi-squared tests), count data (Poisson distributions), comparing distributions (Kolmogorov-Smirnov tests), and trend lines (regression). Each formula includes its mathematical expression, variable definitions, brief commentary on why it matters, and references for further learning, with the underlying argument that understanding these statistical tools helps programmers move beyond simple point estimates to make meaningful claims about underlying data patterns.

Permalink

What's The Point Of Promises?

Promises fundamentally represent eventual values from operations, allowing asynchronous code to be written in patterns that mirror synchronous code. Beyond the commonly cited benefit of flattening callback nesting, the real power of promises lies in decoupling handler functions (enabling reusability), managing parallel asynchronous operations, and—critically—properly propagating errors through callback chains as failed states rather than thrown exceptions. Libraries should ideally use promises internally to create clean, fluent APIs that let users write asynchronous operations much like they would write synchronous ones.

Permalink

Codeception - BDD-style PHP testing.

Codeception is a PHP testing framework that enables user-centric testing through high-level domain language while supporting multiple testing approaches including browser testing via Selenium or HTTP emulation, framework-integrated testing for faster execution, API testing for REST and SOAP services, and data-driven testing with various databases. It builds on PHPUnit for unit and integration testing capabilities and allows developers to write tests that mirror actual user actions rather than low-level implementation details.

Permalink

How Do You Structure JavaScript? The Module Pattern Edition | CSS-Tricks

The Module Pattern structures JavaScript code into self-contained objects with clearly defined settings, initialization methods, UI event binding, and helper functions—creating a consistent, readable approach where every module follows the same template and is initialized through a single entry point. This pattern makes code maintainable across multiple developers and time, encourages reusability, and creates testable functions by breaking functionality into small, specific tasks rather than scattered global code.

Permalink

Why I loved building Basecamp for iPhone in RubyMotion by Nick of 37signals

The author describes his experience developing the Basecamp iOS app using RubyMotion, a tool that lets Ruby developers write native iPhone applications without learning Objective-C from scratch. He shares practical lessons including avoiding Xcode's Interface Builder by coding layouts directly, adopting Objective-C naming conventions for consistency with iOS APIs, leveraging the BubbleWrap gem for common tasks, and prioritizing device testing over simulator work to catch real-world performance issues. His conclusion is that RubyMotion successfully lowered the barrier to mobile development by preserving his existing Ruby workflow while making it possible to ship a production app.

Permalink

iOS Development Tips I Would Want If I Was Starting Out Today

This article offers practical advice for beginner iOS developers, emphasizing modern tools and practices like ARC for memory management, blocks for cleaner code, and Grand Central Dispatch instead of manual threading. The author advocates for code-based layouts over Interface Builder for anything beyond basic apps, recommends embracing open-source libraries managed through CocoaPods, and stresses the importance of crash tracking, code analysis, and localization from the project's start. Throughout, the piece balances technical guidance with opinions on what tools work best in real-world development scenarios.

Permalink

What’s Hot in 2013: Our Picks | Nettuts+

This article surveys emerging technologies and frameworks expected to gain traction in 2013, compiled from predictions by Nettuts+ staff members. The piece covers backend technologies like Laravel 4, PHP 5.5, and Node.js; frontend tools like Backbone.js, D3, and responsive design; databases including MongoDB and RethinkDB; development environments such as Sublime Text 2 and Brackets; and services like Stripe and Travis CI. The overarching theme emphasizes industry maturation toward standardized practices and the growing viability of JavaScript-based full-stack development, particularly through Node.js and related frameworks.

Permalink

Writing Fast, Memory-Efficient JavaScript | Smashing Coding

This article explains how JavaScript engines like V8 optimize code execution and provides practical strategies for writing memory-efficient applications. It covers garbage collection mechanics, closure pitfalls, performance traps with timers, V8-specific optimization tips for objects and arrays, and tools for profiling and detecting memory leaks in real applications. The author emphasizes measuring actual performance bottlenecks before optimizing, avoiding premature micro-optimizations, and understanding that DOM manipulation often poses greater performance risks than JavaScript execution itself.

Permalink

It’s time to start using JavaScript strict mode | NCZOnline

Strict mode is an opt-in JavaScript feature that makes the language safer by throwing errors instead of silently failing when problematic code patterns occur. Key improvements include preventing accidental global variables, eliminating the `with` statement, preventing `this` coercion to the global object, disallowing duplicate function parameters or object properties, confining `eval()` scope, and throwing errors when attempting to modify immutable properties. To use it safely, apply the `"use strict"` pragma inside individual functions or IIFEs rather than globally, since global strict mode can affect concatenated scripts unexpectedly.

Permalink

Git: Twelve Curated Tips And Workflows From The Trenches - be present now

This collection of practical Git workflows addresses repetitive problems developers face, from display issues like line wrapping in diffs to complex operations like cherry-picking between repositories and rewriting commit history. The twelve tips range from simple configuration tweaks (wrapping long lines, setting proxies) to advanced techniques (selectively stashing files, modifying specific commits via interactive rebase, and promoting a branch to master while preserving merge history). The post emphasizes that many of these solutions come from repeated lookups and eventual alias creation, making it a curated distillation of real-world Git usage patterns.

Permalink

Why I Have Given Up on Coding Standards | Richard Rodger

The author argues that formal coding standards are counterproductive and based on flawed reasoning rooted in developers' own ego and need for control. He traces how well-meaning programmers who internalize best practices often become dogmatic managers imposing rigid rules that don't actually improve outcomes, and contends that trusting skilled developers to make their own judgments about code quality produces better results than constraining them with standards. At his company nearForm, he abandoned coding standards entirely, instead relying on developers' professional judgment to write clean code according to context-specific needs.

Permalink