Live data from Hacker News

John Resig annotates original jQuery source code

genius.com

91–100 of 102 posts

Re: John Resig annotates original jQuery source code

#91
post #89

Earlier quoted context omitted.

I still have 0.3 in my code base, and there are some gems like: // Arrrrghhhhhhhh!! // I overwrote the event plugin's .load // this won't happen again, I hope -John BTW, do you know what happened to Dean Edwards. He was doing some really interesting work around the same time as you.

[deleted]

i have some knowledge of the situation and it's fair to say he had some personal issues that consumed him and he had to make some drastic changes in his life

Re: John Resig annotates original jQuery source code

#92
post #89

Earlier quoted context omitted.

[deleted]

i have some knowledge of the situation and it's fair to say he had some personal issues that consumed him and he had to make some drastic changes in his life

Oof - I'm really sorry to hear that! I hope he is doing well now. Thank you for passing this along.

Re: John Resig annotates original jQuery source code

#93

It's very kind of John to mention my first jQuery plugin in the notes. Unfortunately, it was not a very good plugin and probably set a bad precedent. Like so many new jQuery developers, I went "Chaining? Whoa. Chain all the things!" So I attached the plugin to $.fn, not thinking about the fact that what the plugin did had very little to do with the current element selection. I may have been the first to make this mis…

I suspect a lot of the "unnecessary chaining" that occurs is really a problem of people (A) making something that requires jQuery and they don't want to think about how to ensure that dependency, while (B) liking the idea of associating their little thing with a big-name project.

Then you get things like $("#target").MakeBobsFancyBoxWidget()

Re: John Resig annotates original jQuery source code

#94
post #65

What surprises me is the lack of comments in the original file. This leads to e.g.: this._get(i).$$tmpFunc = f; this._get(i).$$tmpFunc(i); this._get(i).$$tmpFunc = null; with the comment (from now): So this may look crazy — it certainly does to me! Why not just do: f.call(this._get(i))? If I remember correctly, and I just did some double-checking and I think this is the case, but IE 5 didn’t support .call()! The orig…

Also with all my respects to mr. Resig, but this is not really code to learn from. It's full of bad habits and it's hard to read. Poorly named, mostly uncommented and pretty hacky. Not really judging, it was just a bunch of handy hacks he had for personal use. Another reason it's hard to follow is of course: writing a CSS selector is not a trivial task, and that with all the browser quirks workarounds. I'm sure getti…

> and then compact it with tools.

Did we have minification tools back then?

Re: John Resig annotates original jQuery source code

#96
post #13

Earlier quoted context omitted.

This formatting style for annotated sources always seems to work so well: http://robflaherty.github.io/jquery-annotated-source/docs/01...

Indeed, that side-by-side annotated style is great. For those who would like to create similar pages, the original program is Docco[0], a Javascript project. However it's been ported over to many other languages and can be found in these projects: - Pycco[1] Python - Rocco[2] Ruby - Shocco[3] POSIX Shell - Many more, as found here[4] Note each of these projects support highlighting different languages. For example, t…

Here's also a Docco 'implementation' for Java code: https://bitbucket.org/doklovic_atlassian/atlassian-docco

Re: John Resig annotates original jQuery source code

#97
post #65

Earlier quoted context omitted.

Also with all my respects to mr. Resig, but this is not really code to learn from. It's full of bad habits and it's hard to read. Poorly named, mostly uncommented and pretty hacky. Not really judging, it was just a bunch of handy hacks he had for personal use. Another reason it's hard to follow is of course: writing a CSS selector is not a trivial task, and that with all the browser quirks workarounds. I'm sure getti…

> and then compact it with tools. Did we have minification tools back then?

Jepp: http://www.crockford.com/javascript/jsmin.html

Re: John Resig annotates original jQuery source code

#98
post #7
post #2

Very neat content, but does it have to be formatted like this? I respect that it preserves the original file, but it makes it very difficult to read. Comments added to the source code would serve much better for the purposes of understanding the code. This tool makes it impossible to read the annotation and the source code at the same time. Clicking on 'set' for example, about 20-30 lines in, lets you read the annota…

I like it. It almost makes me wish I could comment my code like this somehow. I often find that long comments can break my flow when reading code -- but of course, commenting is necessary, so perhaps it could be useful to pull them aside in an IDE. Does something like that exist?

I wrote a markdown based version of literate-programming that allows one to write it with lots of comments and organize the code in anyway you wish. But then when compiled, you can see all the code without all the long comments. You can still have normal programming comments in there, of course, but the detailed thinking (the why and an overview of relations to other parts) can be taken away.

https://github.com/jostylr/literate-programming-lib

Re: John Resig annotates original jQuery source code

#99
post #65

What surprises me is the lack of comments in the original file. This leads to e.g.: this._get(i).$$tmpFunc = f; this._get(i).$$tmpFunc(i); this._get(i).$$tmpFunc = null; with the comment (from now): So this may look crazy — it certainly does to me! Why not just do: f.call(this._get(i))? If I remember correctly, and I just did some double-checking and I think this is the case, but IE 5 didn’t support .call()! The orig…

Also with all my respects to mr. Resig, but this is not really code to learn from. It's full of bad habits and it's hard to read. Poorly named, mostly uncommented and pretty hacky. Not really judging, it was just a bunch of handy hacks he had for personal use. Another reason it's hard to follow is of course: writing a CSS selector is not a trivial task, and that with all the browser quirks workarounds. I'm sure getti…

    this is not really code to learn from
I used to work with someone who could look over my shoulder, read and evaluate my code, and then tell me where my bug was within seconds. He knew the code better than I did, and I'd written it! I asked him about this mad skill of his and he directed me to easily the worst programme I've ever read in my entire life. [1]

It was a block of unformatted, uncommented, dangerously typecast old-style C, with meaningless single letter names for variables and functions.

So I read it. It took a lot of study and I didn't cheat and run it through a pretty printer. I never really got to the point where I grokked it but my ability to read other code has improved a lot.

So whilst I agree that it's important to write code in the way you describe, I think it's well worth reading code that takes you out of your comfort zone from time to time.

[1] http://keiapl.org/rhui/remember.htm

Post reply on HN