Archive for April 13th, 2007

Advancing JavaScript with Libraries

Written by on Friday, April 13th, 2007 in Ajax News.

The Yahoo! UI team kindly invited me to listen to John Resig, of Mozilla and jQuery, talk to the team on “Advancing JavaScript with Libraries”.

John wanted to talk about his experiences developing a number of JavaScript libraries,

At Mozilla John is working on FUEL, a JavaScript library that should be shipping in Firefox 3, that will reduce the complexity for developers to create add-ons.

What is a library?

  • An abstraction away from an existing API
  • Give us new APIs to interface with

APIs breed patterns based on how the API is constructed. Libraries will develop new patterns on top of the existing APIs.

For example, compare the DOM API versus a library that makes the DOM easier to work with. This enables library authors to enhance The Way.

Why create a library?

There are many, many libraries out there. Why write a library?

  • Avoid repetition
  • In JavaScript: Distance from browser differences
  • In C: stdlib distances itself from the platform differences

What about the DOM API?

DOM is implemented in every modern browser, and is very stable and web documented. Even here libraries are useful.

This breaks in IE 7, and always returns an empty set:

HTML:

  1.  
  2. document.getElementById("obj").getElementsByTagName("param")
  3.  
  4. <object id=”obj”>
  5.   <param name=”src” value=”test.mov” />
  6.   <param name=”title” value=”My Video” />
  7. </object>
  8.  

This fails in Safari 2

HTML:

  1.  
  2. document.getElementById("opt").selected
  3.  
  4. <div style=”display: none;”>
  5.  <select><option id=”opt” alue=”test”/></select>
  6. </div>
  7.  

These are genuine bugs in a specific strange way.

These fail in Opera and IE (return the input where the name is q)

HTML:

  1.  
  2. document.getElementById("q")
  3.  
  4. <form action=”" method=”POST”>
  5.   <input type=”text” name=”q” />
  6.   <span id=”q”>Search</span>
  7. </form>
  8.  

And expandos mess you up if you use an id of length (in Opera and IE)

HTML:

  1.  
  2. var f = document.getElementsByTagName("input")
  3. for (var x = 0; x <f.length; f++) {
  4.  
  5. }
  6.  
  7. <form action=”" method=”POST”>
  8.   <input type=”text” id=”length” value=”22″ />
  9.  
  10.  

And these fail in all browsers (for valid reasons, but Joe User doesn’t get it):

HTML:

  1.  
  2. document.getElementById("name").setAttribute("disabled", false)
  3.  
  4. <input type=”text” id=”name” disabled=”disabled” />
  5.  

Reason: DOM doesn’t grok booleans.

HTML:

  1.  
  2. document.body.setAttribute("className", "home");
  3.  
  4. <body> … </body>
  5.  

Reason: class is reserved in JavaScript. Use className.

All of these differences cause libraries to be created.

  • IE has lots of well documented bugs.
  • Safari has less, but more obscure, bugs

Libraries break down issues into meta-problems

E.g.

  • Waiting for the document to load
  • Traversing the DOM
  • Injecting HTML into a page

Waiting for the document to load

A DOM document must be fully loaded before you can work with it, and most wait for the window to load which causes flashes of un-effected content.

What people often do:

HTML:

  1.  
  2. <input type=”text” id=”test” />
  3. <script>document.getElementById"test".docus();</script>
  4.  

jQuery example:

HTML:

  1.  
  2. <head><script src=”script.js”></script></head>
  3.  
  4. $(document).ready(Function() {
  5.   $("#test").focus();
  6. }
  7.  

Traversing the DOM

We all know it is ugly, tricky, and long-winded.

We are moving to DOM Selectors to improve the DOM Traversal API. We have looked to standards such as XPath selectors (//div/span[2]), and CSS 3 selectors (div > span:nth-of-type(2)).

Most web developers grok CSS more than XPath, however they are stuck in CSS 1-ish land due to IE.

Here are some one line solutions that would take a lot more in DOM:

JAVASCRIPT:

  1.  
  2. $(”#menu> li:not(:first-child)”).hide(); // CSS 3
  3.  
  4. $(”ul[ul]”).show(); // XPath
  5.  
  6. $(”tr:even”).addClass(”even”); // Users want it
  7.  

Injecting HTML

Many issues here, such as injecting table rows, select options, etc.

jQuery and others allow you to create HTML and insert into the DOM directly.

JAVASCRIPT:

  1.  
  2. $(”table tr”).append(”<td>test</td>”);
  3. $(”select”).prepend(”<option>test</option>”);
  4.  

Put them together and you get unobtrusive DOM scripting:

JAVASCRIPT:

  1.  
  2. $(document).ready(function() {
  3.   $(”select”).append(”<option>test</option>”);
  4. })
  5.  

and it sets up new expectations:

jQuery users have thought that this should work:

HTML:

  1.  
  2. $("ul> li").click(function(){
  3.   $(this).load("menu.html");
  4. });
  5.  
  6.   <li>item a</li>
  7.   <li>item b</li>
  8. </ul>
  9.  

The users expect these behaviours to not be running once on page load. It should be like CSS. You don’t re-run CSS rules.

function handleClick() {
$(”li”, this).click(loadMenu);
}

function loadMenu() {
$(this).load(”menu.html”, handleClick);
}

$(document).ready(function() {
$(document).each(handleClick);
});

and becomes the behaviour pattern:

$(document).ready(function() {
$(”li”).behaviour(”click”, function(){
$(this).load(”menu.html”, handleClick);
})

FUEL

JavaScript library for Firefox Extension development, designed to be used by Web Developers (not C++ centric folk).

XPCOM is very daunting, and John shows the code for setting a preference. Lots of lines, lots of ugly XPCOM.

With FUEL:

JAVASCRIPT:

  1.  
  2. Application.prefs.setValue(”some.pref”, “some non-ascii text”);
  3.  

This isn’t new to JavaScript

John compares our library development to other worlds.

E.g. SQL

SELECT * FROM users WHERE id = 5;

to Ruby on Rails ActiveRecord::Base

Conclusion

  • Libraries build new patterns on top of existing APIs
  • New library patterns advance development in meaningful considerable ways

And there is more… Meta-Libraries

John is excited about the DSL movement and what it can mean to the web.

He has been playing with jquery2 which isn’t version 2 of jquery, but rather a DSL for JavaScript.

Browsers ignore a script tag where the type isn’t know, which means that you can have your code go back and grok and run it.

This is how the LISP in Firefox works.

Here is how jquery2 is plugged in:

HTML:

  1.  
  2. <script type=”text/jquery”>
  3. pre.run:
  4.   append ‘<input type=”submit” value=”Run”/>‘
  5.   input: click
  6.     each this.parentNode.firstChild.nodeValue
  7.     remove ‘foo’
  8.  
  9. #download> div: oneclick
  10.   #form + li: slideDown
  11.   remove
  12. </script>
  13.  

Come on, time for:

HTML:

  1.  
  2. <script type=”text/ruby”>
  3.   document.ready do |dom|
  4.     dom["table tr"] <<”<td>test"
  5.   end
  6. </script>
  7.  

Could get to this via JRuby and the JVM?

Source: Ajaxian
Original Article: http://ajaxian.com/archives/advancing-javascript-with-libraries

Breaking: Google Spends $3.1 Billion For DoubleClick

Written by on Friday, April 13th, 2007 in Ajax News.

About 20 minutes ago Google announced that they have acquired DoubleClick for $3.1 billion in cash (nearly double the size of their YouTube Acquisition). Microsoft was reportedly in a bidding war with Google for the company. Google gets access to DoubleClicks advertising software and, perhaps more importantly, their customers and network.

DoubleClick was founded in 1996. DoubleClick was taken private in 2005 by Hellman & Friedman and JMI Equity for $1.1 billion. The New York Times is reporting that DoubleClicks revenues are about $300 million/year.

Crunch Network: CrunchGear drool over the sexiest new gadgets and hardware.

Source: TechCrunch
Original Article: http://feeds.feedburner.com/~r/Techcrunch/~3/108898567/

I just received the letter below by email, in reference to my previous post on Shannon Terry and Rivals.com. I’m not going to make a statement on this just yet - our lawyers are involved and have advised me to keep quiet for now.

I’ll say this much, though. Rivals is no longer my favorite sports news site.



Crunch Network: MobileCrunch Mobile Gadgets and Applications, Delivered Daily.

Source: TechCrunch
Original Article: http://feeds.feedburner.com/~r/Techcrunch/~3/108889384/

Dear No First Name

Written by on Friday, April 13th, 2007 in Ajax News.

A PR firm wrote us a letter to win our business. It was signed by their Director of Business Development.

The letter detailed the awards they’ve won, the placements they’ve achieved for their clients, and the number of clients they’ve had that have been acquired or gone public.

It sounds impressive, but it all started with “Dear <No First Name>.” The big picture is a bunch of little pictures. Get the basics wrong and you get everything wrong.

Source: Signal vs. Noise
Original Article: http://www.37signals.com/svn/posts/372-dear-no-first-name

[Sunspots] The Mammatus edition

Written by on Friday, April 13th, 2007 in Ajax News.

How to price a project

“I’ll say, ‘we worked on a project similar to yours and the final cost was [blank]’ I’ve had clients reply ‘that is [blank] times more than it would cost to do [blank]!’ The final blank often being some completely unrelated product relevant only to their business and impossible to compare other than on a pure cost basis. While other clients have said, ‘I don’t think you understand my project, because you are estimating far less than [blank].’ While this is very awkward part of the discussion it is almost always followed by candor. It’s as if once someone starts telling the truth, it opens a door that can’t be closed.”

Is there a secret that sets Stradivarius violins apart from the best instruments made today?

“Science has not provided any convincing evidence for the existence or otherwise of any measurable property that would set the Cremonese instruments apart from the finest violins made by skilled craftsman today. Indeed, some leading soloists do occasionally play on modern instruments. However, the really top soloists – and, not surprisingly, violin dealers, who have a vested interest in maintaining the Cremonese legend of intrinsic superiority – remain utterly unconvinced.”

John Lane: We have lost contact with the beautiful and our society is suffering as a result

“Why is so much modern architecture so nerve-janglingly awful, or just plain dull? What effect does this have on us? We live lives surrounded by functional objects bereft of beauty – when did you last see a house built by a mainstream construction company that was so beautiful that it took your breath away? Have you ever seen a mobile phone so exquisite that you will always treasure it? We have lost our way, and the effects of this separation are all too clear.”

Photos of breast-clouds (SFW)

“Mammatus Clouds, or ‘breast-clouds’, are fascinating formations in the sky, made mostly from the cumulus cloud base. Although they are not a sign that a tornado is about to form, they often accompany tornado-producing storms, or even may be direct byproduct of tornado activity – an aftermath of severe thunderstorms.”

Tim Gunn compares academia to working at Liz Claiborne

“I’ve been living in a rarefied bubble, really, for a total of 29 years. Because we were dealing with theory, we could write our own scenarios, where nothing ever fails and nothing is ever lost in the shipping process. It’s a very different universe.”

Simplicity: “The Ultimate Sophistication”

“Instead of focusing on adding features, design teams should focus on helping users find out what they really need before they purchase. When design teams understand that buyers want to avoid trade-offs, they can use this insight to their advantage…simplicity goes beyond the interface of the product to the decision process surrounding it. We want simple decisions as much as simple products.”

A much shorter code of conduct

The whole thing: “Say everything as if speaking to everyone (because you are). If you must be a jerk, don’t be an anonymous one (because that’s cowardly). Encourage others to abide by this code (because it’s neighborly, plus recursive rules are fun). When others don’t care to abide, ignore them (because they’re not worthy of your time).”

A stream of book covers

“Covers is dedicated to the appreciation of book cover design.”

Impressive recruiting pitch to prospective hires by Red 5

“The fifth opens like a book or a box of software and inside was an iPod Shuffle with my name engraved on it!” [via KH]

Gyre visual debugger

“There are many excellent components in the Rails developer toolchain: Ruby, RubyGems, Rails, Mongrel, Cerberus. But one thing that is missing is a visual debugger. Gyre is an attempt to fill that gap.”

Ryan McMinn speaks about how Unspace works

McMinn discusses why it’s better to hire developers who are musicians, how they give projects space by only working on them three days a week, and more.

Keynote address by Chad Fowler

From MountainWest Ruby Conference 2007. Re: McMinn’s point, Fowler used to be a classical composer.

Buskin’ Bruce Springsteen performs “The River” on a street in Copenhagen


Source: Signal vs. Noise
Original Article: http://www.37signals.com/svn/posts/369-sunspots-the-mammatus-edition

Fireclipse: Debug from FF straight into Eclipse

Written by on Friday, April 13th, 2007 in Ajax News.

John J. Barton has released a new open source framework named Fireclipse that enables nice coupling of Firefox and Eclipse for debugging purposes, working on top of Firebug.

  • Fireclipse routes error messages from Firefox’s
    Javascript Console to Eclipse’s console.
  • Fireclipse positions an Eclipse editor on the source line reported by Firefox.
  • Calls to dump() end up on the Eclipse console
  • Fireclipse adds an Eclipse panel to Firebug
  • Extensions to Firebug include:
  • debug eval() code.
  • debug event handlers
  • route error messages to eclipse
  • executable line numbers marked

Take a peak at the page of screenshots to see it setup in Firefox and Eclipse.

( via Dean Edwards )

Source: Ajaxian
Original Article: http://ajaxian.com/archives/fireclipse-debug-from-ff-straight-into-eclipse

It is appropriate that the answer to the toughest riddle since the Davinci Code has been solved on Friday the 13th.

John Eckman has written about Rich Internet Applications and Greek Mythology and uncovers the reasons why Adobe named their project Apollo, and Microsoft named theirs Atlas.

It even gets to the conclusion that Dionysus is next. Well, you got me. My sheparding of ajaxian.com is an act to bring back the great days of Dionysus, or Dion for short.

Ajax, in Greek mythology, was not a god, but a human hero and King. Interestingly, in the Illiad, he is the only major warrior who receives no assistance from the gods, suggesting “the virtues of hard work and perseverance.”

Microsoft called their Ajax platform (now more prosaicly known as ASP.NET AJAX) Atlas - a Titan and brother to Prometheus who held heaven and earth on his shoulders as a punishment from Zeus for leading the Titans in a revolt against the gods.

So why does Adobe choose Apollo? Well, the god Apollo unites art and reason, and is the god of beauty, the sun, music, light, truth - the ideal of beauty. Perhaps Apollo plays in both senses here - rather than holding up the earth (like Atlas) Adobe’s Apollo is taking us to the moon and back, and providing beauty. Ajax was merely human, Apollo divine. Atlas tried to usurp the gods and was punished; Apollo brought order, music, and poetry.

Perhaps it’s time for an open source web/desktop framework named after Dionysus? (See Apollonian and Dionysian)

True Apollo

Source: Ajaxian
Original Article: http://ajaxian.com/archives/the-true-meaning-behind-apollo-atlas-ajax-and-dionysius

CookieJar: JSON Cookies

Written by on Friday, April 13th, 2007 in Ajax News.

Lalit Patel has created a JavaScript Library to use JSON to store data in cookies.

JSON Cookies is built on top of Prototype and gives you a simple API to put and get JSON values into cookies:

JAVASCRIPT:

  1.  
  2. var jar = new CookieJar({ 
  3.      expires:3600,   // seconds   
  4.      path: ‘/’ 
  5. });   
  6.  
  7. var dog = {name: ‘Jacky’, breed: ‘Alsatian’, age:5}; 
  8.    
  9. jar.put(’mydog’, dog); 
  10. mydog = jar.get(’mydog’); 
  11.  
  12. alert(”My dog’s name is ” + mydog.name); 
  13. alert(”He is ” + mydog.age + ” years old”); 
  14. alert(”He is an ” + mydog.breed); 
  15.  

Source: Ajaxian
Original Article: http://ajaxian.com/archives/cookiejar-json-cookies

Scriptless Day: July 7th 2007

Written by on Friday, April 13th, 2007 in Ajax News.

Nater Kane pointed us to Scriptless Day, the Web 3.0 CSS Naked Day.

Some have found it ironic that the default banners for Scriptless Day are JavaScript banners, but they responded:

We have been catching a lot of heat lately on our decision to use JavaScript in our Badge to promote Scriptless Day!

However, we see it fit to use JavaScript to promote Scriptless Day because the overall point of SD is to illustrate the importance of Client-Side JavaScript on several popular “Web 2.0″ websites. The fact that we chose to use JavaScript only reinforces our positive attitude towards it.

I can’t wait to see HTMLless Day next year.

Source: Ajaxian
Original Article: http://ajaxian.com/archives/scriptless-day-july-7th-2007

Rumors about a possible $100 million acquisition by Yahoo of sports content site Rivals surfaced today. But two previous deals to acquire the company died once it was discovered that the CEO, Shannon Terry, was found to have been involved in a classic “pump and dump” scheme, and violated the anti-touting and antifraud provisions of U.S. securities laws in 1998.

Shannon was a principal of SGA Goldstar Research, Inc. In 1998, he and at least two others, Sheldon Kraft and Charles Huttoe, were accused of engaging in “a massive ongoing market manipulation” around touting shares of a company called Systems of Excellence, Inc. Kraft and Huttoe were sentenced to prison terms. Shannon, who reportedly “cooperated” with authorities, got off with a $828,000 fine. For background information, see here and here.

In 2005, sources say, Fox killed a deal to acquire Rivals at the 11th hour after a routine background check on Terry revealed the fraud. Terry had not previously disclosed the issue to Fox. Fox went on to acquire competitor Scout Media for $60 million in September 2005.

Shortly thereafter, AOL was supposedly close to acquiring Rivals as well, for as much as $90 million. Again, Terry reportedly failed to disclose the fraud, which was discovered during the due diligence phase of the negotiations. The deal was killed.

No word on whether Terry’s history has been disclosed to Yahoo as part of the current negotiations, and how it might affect the deal. My guess is that it could have an impact.

Crunch Network: CrunchBoard because it’s time for you to find a new Job2.0

Source: TechCrunch
Original Article: http://feeds.feedburner.com/~r/Techcrunch/~3/108725949/



Site Navigation