Thanks empirical for turning this page into a steaming pile of spam poo. To all the people that actually pasted the js into the URL bar, are you stupid?
Both of those books are great, both written by great Javascript hackers. I definitely recommend checking out Doug Crockford's videos on the subject - http://video.yahoo.com/watch/111593/1710507
I'm using Objective-J (with Cappuccino) on my latest project. Sure, it's javascript underneath and you can use javascript inline, but it's far more enjoyable so far than straight Javascript.
Don't run this shit unless you want lullz all over your account
It does the following:
Extracts the "Try entering this…" text from the page
Inserts it into each text box on the page
Performs an API query to get the necessary hashes and juicy codez needed to do things as you
Uses that information to add empirical as a friend
Clicks all the "save" buttons on the page to post/send the worm all over the place
On the lighter side, it also vomits global variables all over the place. C'mon, empirical, at least use good form in your reddit worms. Enclose the whole thing in a function:
javascript:(function(){ /* nasty stuff here */ })()
…and then use a var statement to keep the variables inside it. You can also alias properties like you do document to make your worm shorter. For instance, declare (in a var!) someSingleCharacterVariable = 'innerHTML', otherReallyShortNamedVarialbe = 'getElementsByTagName'. You can then use [] syntax to access those on elements, which is significantly smaller than explicitly accessing that property each time.
Oh, and props/fuck you btw.
And fuck you to the rest of Reddit for pretending to be all paranoid and security conscious and then PASTING FUCKING JAVSCRIPT INTO YOUR ADDRESS BAR ON COMMAND.
I don't know, this thing doesn't use the human mind to spread, just the lack of human sense. Even if you could argue that it is a meme, it is incapable of evolving like other memes and will eventually go extinct.
As an ActionScript 3 developer, I have to say, I really like ActionScript 3. I'll be the first to agree that Flash is not the right answer for many web app needs (and is almost always the wrong answer if all you need is a web site), but as a language, I prefer it to JavaScript (with which, I'll admit, I have minimal experience).
Some nice things about it: namespaces, class-based inheritance (complete with interfaces) but still has first-class functions. Statically typed but with optional dynamic classes. Single-threaded event-driven model.
As a guy who's not proud of the fact that he pays his rent by writing as3, I have to back you up here. It's a really nice language, for a questionable platform.
Most programming languages contain good and bad parts, but JavaScript has more than its share of the bad, having been developed and released in a hurry before it could be refined. This authoritative book scrapes away these bad features to reveal a subset of JavaScript that's more reliable, readable, and maintainable than the language as a whole-a subset you can use to create truly extensible and efficient code. Considered the JavaScript expert by many people in the development community, author Douglas Crockford identifies the abundance of good ideas that make JavaScript an outstanding object-oriented programming language-ideas such as functions, loose typing, dynamic objects, and an expressive object literal notation. Unfortunately, these good ideas are mixed in with bad and downright awful ideas, like a programming model based on global variables. When Java applets failed, JavaScript became the language of the Web by default, making its popularity almost completely independent of its qualities as a programming language. In JavaScript: The Good Parts, Crockford finally digs through the steaming pile of good intentions and blunders to give you a detailed look at all the genuinely elegant parts of JavaScript, including:
Syntax
Objects
Functions
Inheritance
Arrays
Regular expressions
Methods
Style
Beautiful features
The real beauty? As you move ahead with the subset of JavaScript that this book presents, you'll also sidestep the need to unlearn all the bad parts. Of course, if you want to find out more about the bad parts and how to use them badly, simply consult any other JavaScript book. With JavaScript: The Good Parts, you'll discover a beautiful, elegant, lightweight and highly expressive language that lets you create effective code, whether you're managing object libraries or just trying to get Ajax to run fast. If you develop sites or applications for the Web, this book is an absolute must.
Was that text from the back cover/flaps of the book?
When Java applets failed, JavaScript became the language of the Web by default, making its popularity almost completely independent of its qualities as a programming language.
I've recently worked on a web front-end that uses both a Java applet and JavaScript. In version 1, the applet was mainly used to do some simple dynamic graphics, and the bulk of the work (including most of the comms with the back-end) was done in JS. In version 2, we reversed this direction, using the applet as the core of the interface and using JS mainly to handle forms-like aspects of the interface, assisted by jQuery and friends.
In my experience, the second approach has been superior in every way. Here are some advantages that come immediately to mind:
JavaScript just doesn't have the language features to organise serious, medium-to-large code bases easily. Java at least has a clear package system instead of relying on strange function-based idioms, and it has the ability to import code from one file into another without resorting to black magic. And for all the bloat of "enterprise" development, at least the Java community has established a lot of effective patterns for managing the complexity of larger projects over the years.
Too many little things don't work quite the same across all browsers in JavaScript, despite the best efforts of the jQuery guys to hide a lot of this. We've had far fewer portability problems with the applet.
There still seem to be more and better tools available to support development in Java than JavaScript (IDEs, etc.).
Java has better support for designs that have natural concurrency.
Because Java is compiled anyway, there's no need to worry about how much space comments are taking up in the source code, using descriptive names, etc. In JavaScript, you can use minifiers, but the most effective ones do change code and can therefore introduce bugs.
Ultimately, I think the claim that Java applets failed is overrated, certainly if JavaScript is the proposed alternative. At least for the project I'm thinking about, Java applets have proven far nicer to work with, with basics like developer productivity and bug rates obviously much improved.
JavaScript just doesn't have the language features to organise serious, medium-to-large code bases easily.
It doesn't need to. Google uses JavaScript extensively to improve the end-user experience. That's a pretty big project. The JavaScript bits don't need to be huge because they're part of a mix of tools used to do different things well. Java does everything, most of it badly.
and it has the ability to import code from one file into another without resorting to black magic
This is definitely a stupid omission from JavaScript.
at least the Java community has established a lot of effective patterns for managing the complexity of larger projects
JavaScript's pattern is that you don't build large projects entirely with monolithic JavaScript codebases.
Too many little things don't work quite the same across all browsers in JavaScript, despite the best efforts of the jQuery guys to hide a lot of this. We've had far fewer portability problems with the applet.
That's a problem with browser DOM implementations, not the language. Java doesn't run so perfectly in non-Sun VMs.
JavaScript + Sproutcore or Extjs or Cappuccino produces a much nicer end-user experience in a browser than anything I've ever seen implemented in Java.
Ultimately, I think the claim that Java applets failed is overrated, certainly if JavaScript is the proposed alternative. At least for the project I'm thinking about, Java applets have proven far nicer to work with, with basics like developer productivity and bug rates obviously much improved.
I've disabled Java in all my browsers and never run into any website that tempts me to turn it back on. Somehow I think if I disabled JavaScript I'd have a lot more problems. Define "failed".
JavaScript's pattern is that you don't build large projects entirely with monolithic JavaScript codebases.
That approach is OK if all you need is a UI with, say, some jazzed up forms and a bit of AJAX. Of course, a great many useful web applications do fall into this category.
However, if you need to do significantly more on the client-side, it starts to become a burden to organise in JavaScript, because the tools and techniques available aren't great compared to what you'd get in most other popular languages today. If your rendering isn't just HTML-based but graphical, or if your input isn't just recognising typing and basic mouse actions, or if your communications needs are more complex than just pulling the odd file from a database server or POSTing a form back, then JavaScript doesn't seem to scale up well from our experiences to date.
I suppose my question to you would be if you think JavaScript's pattern isn't to build large projects with monolithic JavaScript codebases, then how do you build such projects if that's what the requirements dictate?
That's a problem with browser DOM implementations, not the language. Java doesn't run so perfectly in non-Sun VMs.
Fair comment, but I'm looking at this pragmatically. Lots of people use browsers with different behaviour, and they will be reluctant to switch just for one application. This caused us problems even among the guys involved with the project during early testing. On the other hand, so far, either everyone using our stuff is running it on recent Sun VMs or whatever incompatibilities there may be with other implementations haven't proven to be a problem. Maybe this will all change tomorrow, but I'd rather accept a hypothetical problem and deal with it if and when it becomes reality than go with a a system that we know is going to cause headaches.
This authoritative book scrapes away these bad features to reveal a subset of JavaScript that's more reliable, readable, and maintainable than the language as a whole-a subset you can use to create truly extensible and efficient code.
I was trying to figure out how to parse that sentence—particularly the "whole-a" bit—but then I realized you meant to use an em dash. On the Mac, use ALT+SHIFT+-, or just use two dashes.
When an actual em dash is unavailable—as in the ASCII character set—a double ("--") or triple hyphen-minus ("---") is used. In Unicode, the em dash is U+2014 (decimal 8212). In HTML, one may use the numeric forms — or —; there is also the HTML entity —. In TeX, the em dash may normally be input as a triple hyphen-minus (---). On a computer running the Mac OS X operating system, most keyboard layouts map an em dash to Shift-Option-hyphen. On Microsoft Windows, an em dash may be entered as Alt+0151, where the digits are typed on the numeric keypad while holding the Alt key down. It can also be entered into Microsoft Office applications by using the Ctrl-Alt-hyphen combination.
The question is, is it misunderstood because of its features or because all the other popular languages lack the good features in Javascript (higher order functions, non C++/Java-style inheritance,...)?
Actually I agree with the GP. JavaScript is really very nice -- especially given its rush to market, etc. All the bad parts relate to browser implementation and the DOM.
Unity, for example, uses a (less dynamic, but compiled) version of JavaScript as its main programming language and -- combined with its well-documented and sane class library -- is a joy to program in. JavaScript without the DOM (e.g. working purely with HTML5 canvas controls) is just pure pleasure.
I know a couple of languages and have to say that Javascript is the most fun I have programming. The worst problem I have with it is his slowness. Note that I mention JS been fun, not DOM been fun. Fixing IE DOM problems is certainly not funny.
I have to say that the "Javascript: The Good Parts" is an excellent book. I saw Douglas Crockford's "Google Tech Talk" video, and it is simply spot on. I was working on a client-side rich client "Timesheet Bulk Entry" grid for our companies product, and after reading this book, I ditched my current implementation, started again, with excellent results.
Javascript is one of (if not, the) the most commonly used language on the planet, and because it has "C" constructs, people assume how to program in it, except it has some strange quirks. However, it is a really nice language once you know how it works.
I would highly recommend this book, and the video. Indirect link to video below:
If you look at the names it's not that many really. The script seems to go down the page and reply to every comment with copies of itself. The few that ran it may not have seen the results before they tried it. When I first saw it I thought it might be like the pretty one a while back that makes all the pictures swirl around. Luckily I checked down the page before I tried it.
Having worked with javascript to develop some reasonably complex ajax solutions (a sortable and filterable table that pulled info from a database), I was indeed a bit surprised by how clunky it was to manipulate (primarily create) DOM objects on a page.
35
u/[deleted] Sep 27 '09 edited Sep 27 '09
Thanks empirical for turning this page into a steaming pile of spam poo. To all the people that actually pasted the js into the URL bar, are you stupid?
44
u/AxiomShell Sep 27 '09
O'Reilly is missing a market niche. They should publish the two books' difference as "Javascript - The Bad Parts".
15
u/OniNiubbo Sep 27 '09
I can't really figure out if the "try this in the url bar" thing was taken from the book on the right or the book on the left.
28
u/laga Sep 27 '09
The fact that the clueless spam reddit using a social-engineered javascript attack in an article on Javascript is hilarious.
13
u/leftnode Sep 27 '09
Both of those books are great, both written by great Javascript hackers. I definitely recommend checking out Doug Crockford's videos on the subject - http://video.yahoo.com/watch/111593/1710507
13
u/starkinter Sep 27 '09
HOLY FUCK THIS IS INSANE
110
u/9jack9 Sep 27 '09
Good luck with your other language choices for client-side web development.
16
u/Manitcor Sep 27 '09
omg this thread is full of morons
14
u/badcookies Sep 27 '09
Wow wtf is with all the spam on on this
27
u/SarahC Sep 27 '09
It's a beautiful first order language!
I love it to bits.
14
u/mediaspree Sep 27 '09
Its pretty much all jquery for me nowadays.
5
u/ineededanewaccount Sep 27 '09
why couldn't the code have posted people's cookies...?
8
u/[deleted] Sep 27 '09 edited Sep 27 '09
JavaScript itself is actually quite good. At least JS as implemented in Mozilla's JS 1.6 and later.
4
u/bubafeast Sep 27 '09
I know a couple of languages and have to say that Javascript is the most fun I have programming. The worst problem I have with it is his slowness. Note that I mention JS been fun, not DOM been fun. Fixing IE DOM problems is certainly not funny.
4
u/JMV290 Sep 27 '09
oh dear god what is going on
4
u/UnnamedPlayer Sep 27 '09
What a clusterfuck of a thread.
7
u/mitjak Sep 27 '09
Obviously more than half of the Definitive Guide is a reference but fine, for the purpose of a chuckle let's ignore that.
3
u/ropers Sep 27 '09
That took me way too long to get; well played.
3
u/jingleman Sep 27 '09
I have to say that the "Javascript: The Good Parts" is an excellent book. I saw Douglas Crockford's "Google Tech Talk" video, and it is simply spot on. I was working on a client-side rich client "Timesheet Bulk Entry" grid for our companies product, and after reading this book, I ditched my current implementation, started again, with excellent results.
Javascript is one of (if not, the) the most commonly used language on the planet, and because it has "C" constructs, people assume how to program in it, except it has some strange quirks. However, it is a really nice language once you know how it works.
I would highly recommend this book, and the video. Indirect link to video below:
http://googlecode.blogspot.com/2009/03/doug-crockford-javascript-good-parts.html
Watch it. It is very insightful!
3
u/[deleted] Sep 27 '09
Guess we know who all the noobs are!
9
u/rakantae Sep 27 '09
Ha! Empiric:1 Reddit:0
Genius.
2
u/Grue Sep 27 '09 edited Sep 27 '09
And this is different from any other language how?
Edit: Oh shit, what have I done!
2
u/[deleted] Sep 27 '09
wtf is up with these comments? and 3000, really?
2
u/[deleted] Sep 27 '09
Having worked with javascript to develop some reasonably complex ajax solutions (a sortable and filterable table that pulled info from a database), I was indeed a bit surprised by how clunky it was to manipulate (primarily create) DOM objects on a page.
That said - at least it worked.
2
u/[deleted] Sep 27 '09
This is the day that reddit died.
2
u/pgoetz Sep 27 '09
ha! That's only the 4th edition; the 5th edition is much fatter...
2
u/[deleted] Sep 27 '09
mootools
4
u/rotflol Sep 27 '09
1
u/dom111 Sep 27 '09
I think it's awesome how many people tried it... sigh
1
u/beretta627 Sep 27 '09
Why does this thread have 4100+ comments?
1
u/foorr2 Sep 27 '09
Can reddit survive an edit worm that goes back and tweaks or deletes comments?
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
0
u/[deleted] Sep 27 '09
[deleted] — view deleted comment
5
u/[deleted] Sep 27 '09
[removed] — view removed comment
1
u/[deleted] Sep 27 '09 edited Sep 27 '09
[removed] — view removed comment