Top all-time · #2804
Ben Cherry
Personal blog · adequatelygood.comprogrammingweb
Ben Cherry writes Adequately Good, a personal blog at adequatelygood.com about programming and web. Since 2010, 27 different Hacker News readers have linked it 28 times, most often “Understanding Tricky JavaScript Scoping and Hoisting Issues”. The last post was in 2011, but the archive is still widely read.
Most-linked posts?
- Understanding Tricky JavaScript Scoping and Hoisting Issues7 people · 7 mentions · first linked 2010-08-20
- JavaScript Module Pattern: In-Depth7 people · 7 mentions · first linked 2010-03-15
- JavaScript Module Pattern in depth (2010)2 people · 2 mentions · first linked 2013-07-17
- /JavaScript-Scoping-and-Hoisting.html2 people · 2 mentions · first linked 2013-03-26
- Writing Testable JavaScript2 people · 2 mentions · first linked 2010-07-08
- Twitter's Ben Cherry's response to Hashbangs (or hash-bashing)2 people · 2 mentions · first linked 2011-02-11
What Hacker News says?
http://www.adequatelygood.com/JavaScript-Module-Pattern-In-D...
Comment linking /JavaScript-Module-Pattern-In-Depth.html
on “Enough with the JavaScript already”Submitted Writing Testable JavaScript as a story · 35 points
HN discussionI've been trying to come up with a javascript module pattern for my rails apps. Right now, I use the Foundations javascript libraries, however those are very generic. I'd like to do something like Foundation does: have separate js files for accordians, sliders, tooltips, etc...I've been looking at the module patterns, however, as a new-comer to js (I'm ruby backend dev), there seems to be so many ways ( http://www.a…
Comment linking /2010/3/JavaScript-Module-Pattern-In-Depth
on “Superhero.js: articles and videos on building large JavaScript apps”Submitted JavaScript Module Pattern: In-Depth as a story · 11 points
HN discussionhttp://www.adequatelygood.com/2010/3/Performance-of-vs-
Comment linking /2010/3/Performance-of-vs-
on “Some web development tips from a former Digg developer”Submitted Javascript Module Pattern In Depth as a story · 9 points
HN discussionI don't know the answer to this, but I've always been genuinely curious: how accurate is the Date object? setInterval's minimum interval is ~15ms [1], so shouldn't something like... setInterval(() => (new Date()).valueOf() % DESIRED_TICK_INTERVAL < 15 && tickTheMetronome(), 15) ...get you within 15ms accuracy, and it can probably be reduced in Chrome et al? [1] http://www.adequatelygood.com/Minimum-Timer-Intervals-i…
Comment linking /Minimum-Timer-Intervals-in-JavaScript.html
on “Metronomes in JavaScript”Submitted Twitter's Ben Cherry's response to Hashbangs (or hash-bashing) as a story · 8 points
HN discussionWhat is it that you don’t like about this. Is it that the var is hoisted? http://www.adequatelygood.com/JavaScript-Scoping-and-Hoistin... Hoisting generally seems ugly to me. Edit: I think there is some confusion here about scoping. One axis is dynamic versus lexical scoping (are there other options?). Another axis is function, block, global, etc. scope. They seem orthogonal to me.
Comment linking /JavaScript-Scoping-and-Hoisting.html
on “JavaScript Isn't Scheme”Submitted JavaScript Module Pattern in depth (2010) as a story · 4 points
HN discussion2011-02-11: "We've made a tradeoff, however, in making twitter.com into an application using the hash, which is that it now cannot be both an app and a site at the same time." http://www.adequatelygood.com/2011/2/Thoughts-on-the-Hashban...
Comment linking /2011/2/Thoughts-on-the-Hashbang
on “Twitter Rolls Twitter.com Back to a Server-Side Architecture”Submitted JavaScript Module Pattern (2010) as a story · 4 points
HN discussion(I'm the author.) JavaScript can be pretty overwhelming to newcomers. You mention scope, which is a good example of where CoffeeScript actually clarifies rather than hides the underlying semantics. The most important thing to understand about scope in JS is that only functions create scope . This is very different from C and Java, and since JavaScript looks like C and Java, that difference is surprising (see e.g. ht…
Comment linking /2010/2/JavaScript-Scoping-and-Hoisting
on “A CoffeeScript Intervention”Submitted Writing Testable JavaScript Code as a story · 3 points
HN discussionMost javascript modules are defined inside a similar pattern, I'm surprised you haven't seen it yet. http://www.adequatelygood.com/2010/3/JavaScript-Module-Patte... https://github.com/jquery/jquery/blob/master/src/ajax.js
Comment linking /2010/3/JavaScript-Module-Pattern-In-Depth
on “An Open Letter to JavaScript Leaders Regarding Semicolons”Submitted Understanding Tricky JavaScript Scoping and Hoisting Issues as a story · 2 points
HN discussionI can take a stab at it. All variables are hoisted to the top of a function, where they are defined as 'undefined'. This is confusing, I know - there is actually a difference between an undefined variable (accessing it will cause a ReferenceError) and a variable defined as 'undefined', which is in many cases identical to null, except in object syntax. An example you can run in your inspector: function foo(){ console…
Comment linking /2010/2/JavaScript-Scoping-and-Hoisting
on “Common JavaScript Gotchas”Submitted JavaScript Scoping and Hoisting as a story · 2 points
HN discussionI learned this method with the book JavaScript the Good Parts, though it was a while ago and I can't remember the specific reasoning behind the books' recommendation. From the other commenter's SO link, I found this link to go more in depth into the differences of declaring functions, and it seems to come down to having stricter control on the order of events with no surprises. http://javascriptweblog.wordpress.com/…
Comment linking /JavaScript-Scoping-and-Hoisting.html
on “Show HN: jQuery.pin – a plugin for making stuff stick”Submitted Writing Testable JavaScript as a story · 1 points
HN discussionI have a similar background, and I found these two excellent reads removed a lot of the ambiguity that I think comes with JavaScript. For me, I was constantly having an internal argument around designing functionally--encapsulation and messaging via closures--vs designing in an object-oriented paradigm. http://eloquentjavascript.net/ http://javascript.crockford.com/private.html Also, I'd recommend making this the wa…
Comment linking /2010/3/JavaScript-Module-Pattern-In-Depth
on “Ask HN: How to learn Javascript and HTML for devs coming from C++/Java/Python?”Submitted JavaScript Scoping and Hoisting as a story · 1 points
HN discussionI tend to do the same thing. Except, since JavaScript doesn't have block scope, it all ends up at the top of the function. Which is much more preferable than scattered around the function. Especially due to hoisting[1]. My functions typically go in the order of: declare variables; declare any local functions if necessary (most of the time these eventually get refactored out to somewhere else, because they tend to be…
Comment linking /2010/2/JavaScript-Scoping-and-Hoisting
on “Readability and Naming Things”Submitted JavaScript Module Pattern: In-Depth as a story · 1 points
HN discussionSo say 50 elements. With a 50ms difference that's 2.5 seconds of total time. Most browsers will do 2-4 simultaneous connections, so let's say 4, that's still over 1/2 second faster page load. Now put that end user in Europe or Africa, and you're looking at 200-500 ms latency per call, versus 10 ms. You can see how the math works. Assets loaded on some of your recently submitted URLs: 21 - http://www.mozilla.org/en-U…
Comment linking /2010/2/JavaScript-Scoping-and-Hoisting
on “Is Google (and mod_pagespeed) the Poor Man's CDN?”Submitted Replacing `setTimeout` Globally as a story · 1 points
HN discussionI'm fairly certain that writing about JavaScript on my personal blog ( https://adequatelygood.com ) led directly to landing a lucrative job at Twitter in 2010 which was foundational to my career. I had just a few months of experience in JavaScript (or programming in any serious professional capacity) but writing about it made me taken seriously and was a major accelerant to my career. Not sure of whether that experi…
Comment linking /
on “Ask HN: What has your personal website/blog done for you?”Submitted JavaScript: Debugging closures and modules as a story · 1 points
HN discussion