Understanding JavaScript - A Resource

Using the tiny Diggit / Blog feature in StackOverflow described here :

I would like to post the next Google text video that I just saw, and that I found quite interesting.

I've always had problems understanding the "nature" of javascript.

Useful JavaScript Details Here Described by Douglas Crockford

I hope you find this link useful.

Now the question is:

What are your complaints about javascript? Do you use an IDE to edit javascript? Do you think this video helps to understand the "good parts"?

+5
javascript video
Feb 28 '09 at 6:25
source share
5 answers

JavaScript: the bad parts.

  • The biggest mistake is late error detection. JavaScript will gladly allow you to access a nonexistent object or pass the wrong number of arguments to a function and fill in the blank with undefined objects, which, if you do not intentionally check them (which is impractical to continue doing everywhere), will result in an exception or subsequent failure. Perhaps much later, the result is subtle and difficult to debug errors that appear almost next to the actual problem code. These conditions should have thrown exceptions, with the exception that JS initially had no exceptions to raise. 'undefined was a quick and dirty hack with which we are now stuck.

  • Undeclared default variables for global scope. This is almost never what you want, and can cause subtle and difficult to debug errors when two functions forget “var” and “start” do the same global thing.

  • The constructor function model is strange even for the prototype-based OO language and confuses even experienced users. Forgetting the “new” can lead to subtle and difficult to debug errors. Despite the fact that you can make a skipped class / instance system out of it, there is no standard, and most of the class systems proposed in the early tutorials that people still use are desperately inadequate and confuse what JavaScript actually does.

  • Lack of related methods. It is completely unintuitive that accessing "object.method" when called makes a magic connection to the "object" in it, but passing "object.method" as a link loses the connection; no other language works this way. When this happens, "it is set to an unexpected value, but it is not" undefined "or anything else that will throw an exception. Instead, all access to the properties ends in a" window ", which leads to more subtle and complex debugging.

  • No integer type. The number looks like one, but breaks in various ways (for example, n + 1 == n for a sufficiently high n). Each time NaN or Infinity make their way (quite unexpectedly, if you think you are dealing with integers), you won’t know right away; instead, there will be subtle and hard to debug errors in the line.

  • There is no associative array type. The object looks like one, but breaks into various unexpected keys. Arrays are not clean lists. Every time you ever use "for ... inside", you are likely to be trapped and will experience ... yes, subtle and hard to debug errors.

  • As a rule, a poor order of processing strings, at least for the scripting language. String.split (, limit) and String.replace () do not do what you think calling ... you know. The results of toString () are usually bad and not useful for debugging. Meanwhile, we are stuck with garbage that, according to Netscape, might be useful, like String.prototype.blink () and permanently broken escape (). Yay

  • And then all the browser differences (IE still lacks many basic methods for the main objects), and the DOM ...

  • And finally, even when an exception occurs, it is hidden from view, so the author does not even understand that something is wrong. As a result, most sites are full of bugs; include the full JavaScript error message in IE and the result will be unusable.

What scares me is the idea that a new generation of programmers is learning this nausea as the first language. To make matters worse, most of the training material from which they learn ("My fiRST AEWsome R0LL0VERZ!") Invariably encourages the worst possible practice. 'Javascript: URLs,' eval () for everything, accessing DOM data for the browser ... oy.

+17
Feb 28 '09 at 9:08
source share

The hard part about javascript , in my opinion, is this:

  • Browser development / debugging issues
  • Cross browser issues / model (bubbling event, etc.)
  • Lack of "classes" (subjective)
  • Lack of good reliable debugging support in browsers

Firebug helps a lot for FireFox, but I did not find anything good for IE - and just the fact that it is complicated.

On the bright side, if you build a script from scratch and understand every step, it can be really nice and powerful.

+1
Feb 28 '09 at 6:30
source share

alt text http://oreilly.com/catalog/covers/9780596517748_cat.gif Javascript Good Parts is a pretty decent book.

For Javascript, Firefox + Firebug and Notepad ++ is my IDE. jQuery (and various plugins) is my platform. My biggest javascript complaint is IE6

+1
Feb 28 '09 at 6:44
source share

My biggest complaint when using JavaScript is the DOM bindings, but it's actually not a JavaScript error, as each browser implements it in its own way. Along these lines, IE is the worst offender.

In terms of purely JavaScript issues, I'm still not fully prototyping prototypes so that I can use its full power; but this is less of a complaint than my personal failure. As a language, I really like JavaScript, and any complaints I have on it are overshadowed by its interaction with the DOM.

I use Firefox + Firebug heavily for my main coding and debugging. Opera and Safari have debuggers that I use if certain problems occur in the browser. Heaven helps me when I need to debug IE.

I encode any text editor and highlight syntax. I tend to use the YUI framework, but this is only because I know that this is best; I hope that someday I will learn more about other frameworks and decide what would be best for personal projects.

Until I saw the video, this week I just read "Good Details." If the video is nothing like a book, it will be very useful. The book itself is great because it is concise and informative. He goes to the level of language discussion, which is not often seen when Googling for information, which gives a better understanding of the language as a whole.

+1
Feb 28 '09 at 7:40
source share

I really like prototyping, it feels a lot stronger than regular classes.

0
Feb 28 '09 at 8:56
source share



All Articles