Better HN
topnewbestaskshowjobs
Log inSign up

_getify

192 karma · joined Apr 23, 2013 (13y ago) · 126 submissions

Kyle Simpson is a web-oriented software engineer, widely acclaimed for his "You Don't Know JS" book series and nearly 1M hours viewed of his online courses. Kyle's superpower is asking better questions, who deeply believes in maximally using the minimally-necessary tools for any task. As a "human-centric technologist", he's passionate about bringing humans and technology together, evolving engineering organizations towards solving the right problems, in simpler ways. Kyle will always fight for the people behind the pixels.

[ my public key: https://keybase.io/getify; my proof: https://keybase.io/getify/sigs/SxqB6BQX2LQ92yiAfs1FYql_tPEhCqCGAZhnkap6tVY ]

Submissions

comment 11y ago · link · parent

> `var` is broken

Nonsense. Revisionism at its finest.

But that's an argument I made in a different blog post: http://davidwalsh.name/for-and-against-let

> It would be nicer to have real, deep immutability, but `const` isn't it.

Yep, agree with you on that. That was one of the main points of my post.

> Because `const` requires to be initialized at the time of definition, you know the variable is valid for its entire lifetime.

No, that's where you're mistaken. All you really know is that the variable assignment is reliable. If the assignment happens to be of an immutable value, great.

But given the choice between these two guarantees:

1. The assignment is immutable

2. The value is immutable

(1) is almost pointless -- and a quick scan of your small block where it's scoped will verify that or not.

(2) is the absolute important one.

`const` masquerades as (2) when it's really only (1). That's what I don't like about it.

comment 11y ago · link · parent

What you're thinking about in ES6 is called "function name inference" and only refers to certain forms, like this one, where the name -- PURELY FOR DEBUGGING -- can be inferred. Actually, it goes for all assignments, `var`, `let`, and `const`.

Otherwise, the arrow itself is anonymous and thus you don't have a name to make an inner self-reference with.

comment 11y ago · link · parent

Except that any variation of these doesn't produce the same thing as a declaration, since function declarations hoist and function expression assignments do not.

Most people don't like hoisting -- and I agree that variable hoisting is crazy. I'd never advocate this:

    a = 2;
    var a;
But function hoisting I find super useful. I always prefer to write my files like this:

    foo();
    bar();
    
    // ....
    
    function foo() { .. }
    
    function bar() { .. }
...because when I open a file, I don't want to go hunting for any executable code, I just want to look at the very top. Function declaration hoisting lets me put those definitions at the bottom and the code that uses them at the top.

I've found this to be much more useful in code maintenance.

comment 11y ago · link · parent

Yeah, see, this is exactly the problem. I think most developers assume the latter, when the former is all that's meant according to JS.

I don't think the former is all that useful, and the latter is super useful but `const` doesn't do anything to help with that.

comment 11y ago · link · parent

> Why not use `const` as default?

The argument I made toward the end of the post is that refactoring from `const` back to `let` is more risky than the other way around.

Moreover, surveying my own code, honestly, the vast majority of my declarations should be `var` or `let`, and only a much smaller amount being `const`. I think a lot of people are rushing blindly to `const` without realizing its full behavior.

> [`const`] has less rules ... using `let` will introduce complexity

I think this is completely backwards. `let` has no special caveats (other than the TDZ thing, which they both have), whereas `const` has this caveat that it's only about assignment bindings and not about values.

Imagine a piece of code that has `const x = 2` that you later refactor to `const x = [2]`. The complexity is, you now have to contend with the `[2]` being a mutable value where `2` wasn't, and `const` sorta pretends to keep you safe but doesn't.

That's the complexity I disfavor.

comment 11y ago · link · parent

disclosure: self submission

37.

Constantly Confusing ‘const’(blog.getify.com ↗)

33 points · by _getify · 11y ago · 51 comments

comment 11y ago · link · parent

If we're gonna go that route, I still like "middle-end" JS better. :)

comment 11y ago · link · parent

disclosure: self submission

40.

Unimorphic Isoversal JavaScript What?(blog.getify.com ↗)

13 points · by _getify · 11y ago · 7 comments

comment 11y ago · link · parent

> If the threads and their scheduling are implemented wholly by the language

There's just one thread, one event loop, for all of JavaScript... so we're not talking about true thread-level race conditions.

> strongly implying that it takes unusual conditions for events to lag significantly

As far as expectations of software running inside of web pages, it is in fact quite exceptional for there to be significant delays between when you expect for something to happen and when it actually happens.

For example, if I set up a timer for 953ms from now, and it actually runs at 3953ms from now, that extra 3 seconds is extremely uncommon for the UX expected on the web.

I think the disconnect here is that you're really asserting things about what happens at the OS level, where multiple threads and real I/O are happening, etc.

I'm entirely talking about JavaScript, which is single-threaded, and where asynchrony is just simple event-loop concurrency (interleaving actions). It means that two timers should, in simplest terms, order themselves according to normal expectations. It'd be unusual for there to be significant deviations.

comment 11y ago · link · parent

But the article is not about the precision of timers happening at exact moments. It's about the nature of their relative timings. I don't see why the OS would need to be involved in the latter.

comment 11y ago · link · parent

disclosure: self submission

44.

Well, actually; Not all semicolons(blog.getify.com ↗)

1 points · by _getify · 11y ago · 1 comment

45.

ES6: Features by Testing(davidwalsh.name ↗)

1 points · by _getify · 11y ago · discuss

46.

JavaScript Coercions Grid(getify.github.io ↗)

2 points · by _getify · 11y ago · discuss

comment 11y ago · link · parent

Great point! The order of titles listed here is the intended reading order:

https://github.com/getify/You-Dont-Know-JS/blob/master/READM...

Also, the "Up & Going" title, Chapter 3, has descriptions about the titles and the narrative/story arc being told across them, which helps understand the intended order as well:

https://github.com/getify/You-Dont-Know-JS/blob/master/up%20...

comment 11y ago · link · parent

That is exactly my intent. I certainly hope the books live up to that vision.

comment 11y ago · link · parent

The books point all the arcane points of the language so that the reader can understand them. They're also full of commentary like "never do this".

Rather than most books which gloss over the "bad parts", which prevents people from fuller learning and leaves them to their own devices when they run across that stuff in the real world, YDKJS covers all the parts, and tries to use the deeper understanding as a tool and guide to making better-informed decisions about how to effectively write JS.

I think it's entirely unfair to suggest that covering "technical arcana" is the same thing as endorsing it.

comment 11y ago · link · parent

I understand and appreciate your feedback. Unfortunately, given that most of the series is done and half of them are already in print, it's too late to change.

I did have lengthy discussions with my book editor about the title and its potential to be off-putting to some. We wrangled with the decision awhile, but ultimately came to the conclusion that most would find it a mix/balance of playful, attention grabbing (in a sea of "JS: The Handy Guide" type titles), and challenging.

The title itself is supposed to be equal parts a joke and a serious commentary on what I consider to be a disturbing trend in JS specifically, which is either a false sense of confidence or (worse) an apathy to not care about what is not known.

Again, thank you for your thoughtful response and your feedback. I do regret that it's hit you the way it has. Perhaps at some point you may give it another shot.

comment 11y ago · link · parent

fyi: there were some who felt that it would detract from or dillute the brand "the good parts", which is also an oreilly title.

comment 11y ago · link · parent

> For the love of God please don't put a giant headed person on your cover though

These are what the covers of all the books in the series look like:

http://shop.oreilly.com/product/0636920026327.do

------

side note: my kickstarter for the books, 2 years ago, playfully used the bald head image to catch people's attention (never the intended branding). I soon afer got a friendly lawyer takedown notice from the folks who own the game. We worked it out, and the new branding was born. :)

comment 11y ago · link · parent

> each $20

I'm trying to work with O'Reilly to bring down the prices on the books a little bit. I always wanted them to be priced so that price wasn't a barrier to entry. As you can imagine, there's lots of intricate details which restrict what I can do with pricing.

> none of them that big

Hmmm...

Page counts on the titles (so far) are: 65, 98, 176, 189, 296. The last book isn't finished yet, but I'm projecting it to be somewhere around the 150-200 mark.

I can appreciate that $20 for a 100pg book may feel "excessive", but what about $26 for a 296 page book?

Moreover, I'm working (still) on getting O'Reilly to release a box set for a flat price that will be much more reasonable than buying each book individually, so that if you want the whole series you'll have an affordable option for that.

And you'll of course still have the option to buy just one or two of the books if that's your fancy.

comment 11y ago · link · parent

Also note that these books are available for purchase as actual official ebooks. If you read the content and find it helpful, I of course appreciate any purchases made. :)

comment 11y ago · link · parent

Just wanted to say I appreciate any contributions (even "tiny tiny bit") you've made on GH. :)

comment 11y ago · link · parent

The book series (6 of them) is drafted, and to some extent edited, on GitHub. What you see is what you get.

There are some edits and refinements that happen to the content during the publishing/production phase at O'Reilly that aren't necessarily appropriate to back-port to the repo. But I do try to get most of the main substance stuff sync'd.

The free GitHub repo versions of this content represents the drafts of the books in the mostly complete stage, whereas the published books (digital or print) are the final, final versions.

comment 11y ago · link · parent

The proposition that I approach JS from, including my writing of these books, the JS workshops I teach, my OSS work, etc, is this:

If you're going to make JS your primary language that you write on a daily basis, doesn't it make sense to invest more time into learning it than just whatever you might accidentally pick up through trial-and-error?

Most developers in most other languages do tend to take formal learning of the language, to a deep extent often, a more serious task, but with JS it seems many developers just kinda get whatever they get along the way.

I have found that approach to be good at getting and keeping yourself employed, but bad at giving you any confidence that you actually know what's going on. If you aren't really sure exactly why your code works, my theory is that you'll never know exactly why your code doesn't work either.

I'm just trying to provide resources for developers who want to take learning JS seriously, and challenge "all" of us to ask, "just how much DO I know JS?" The rest is up to you. :)

comment 11y ago · link · parent

> I found very little to suggest

Just curious what parts you looked at? Did you glance at the table of contents, or did you read full chapters? I certainly tried to reveal in every chapter several different things that, in my professional experience teaching JS to teams of developers, are commonly misunderstood or under-understood.

If you had any specific feedback on what I could have done better to live up to the title, tone, and mission of the book series, I'd be appreciative of it.

> very early draft

Depends on which book(s) you looked at. The series is 18 months old by now, with 6 titles. 5 of them are already "complete".

3 of them have already been edited and published (though publisher edits didn't necessarily all make it back into the free repo versions).

2 of them are in final editing and production stages, so they're still being cleaned up. The sixth one is still a very early and partial draft, so it's quite rough.

comment 11y ago · link · parent

the game was a play on that phrase, and my book title is a play on both. :)

comment 11y ago · link · parent

I explain the title, and the intended tone and purpose of the book series, in the preface. If you wouldn't mind taking the 3 minutes to read it, I'd be curious if it changes anything about your opinion of the title:

https://github.com/getify/You-Dont-Know-JS/blob/master/prefa...

12345