h1

Science Smithereens for Venusday, 20100312

Posted in Science Etcetera on March 12th, 2010
  • National Geographic has posted a photoalbum of space photos for the week, including an “inverted crater” on Mars caused when an ancient impact site fills with sediment and the surrounding territory erodes away.
  • Inverted Crater on Mars
    Inverted Crater on Mars
    Credit: NASA
  • The NIH has determined that women should be allowed to give birth vaginally if they’ve had a Caesarean section, which many hospitals don’t allow.
  • Analysis of death rates by the American Cancer Society has found a decline in deaths from cancer since 1990 following a decline in smoking and increase in early detection.
  • A small business in New York has trained dogs to detect bed bugs, which requires the dogs’ owner to live with bed bugs and feed them with his blood.
  • Chemistry Extra Credit Rap – Lio Kang:
  • h1

    Science Spectaculars for Jupiterday, 20100311

    Posted in Science Etcetera on March 11th, 2010
  • Researchers at the Society of Toxicology’s annual meeting have brought out brain images depicting Gulf War Syndrome, which the federal government has yet to accept as a legitimate illness.
  • Healthy brain (left) shows response to pain from heat on the forearm. Different regions (right) respond to that heat in vets with Gulf War syndrome two.
    Healthy brain (left) shows response to pain from heat on the forearm. Different regions (right) respond to that heat in vets with Gulf War syndrome two.
    Credit: UT Southwestern Med. Ctr.
  • Fluorescent lights in supermarkets keep vegetables photosynthesizing, making them more nutritious than vegetables stored in the dark.
  • Scientists are overreacting to poll data suggesting American’s are less concerned about Global Warming, thinking its the minor IPCC mistake about the Himalayas and over-hyped “climategate” e-mails, but really, public confidence in scientists is still strong, it’s the jobs market that has pushed scientific concerns away as a populist concern.
  • “Where’s my jetpack?” jokes are now officially overcome by events, as for $75,000 it’s right here.
  • Ray flys Martin Jetpack for a VIP:
  • h1

    Science Roads for Mercuryday, 20100310

    Posted in Science Etcetera on March 10th, 2010
  • The Chilean city of Concepció moved 10 feet to the West as a result of the recent earthquake.

  • Credit: University of Hawaii
  • Ray Kurzweil has written a fairly critical review of Avatar for being unimaginative with its portrayal of alien life and underwhelming in its depictions of technology a century from now.
  • Because the courts have ruled criticism of evolution in public schools amounts to a state endorsement of religion, creationists are trying a new tact by uniting with climate change skeptics to get their message into American classrooms.
  • Quantifying what China has been saying for awhile now: nearly a quarter of China’s emissions are the result of exporting goods to the West.
  • PSA: Plastics Kill 1.5 Million Marine Animals Each Year:
  • h1

    Science Zingers for Marsday, 20100309

    Posted in Science Etcetera on March 9th, 2010
  • Naegleria gruberi is an amoeba that, when subjected to stress, goes from an oozy-moving organism to an organism that sprouts arms and swims a breaststroke through its muddy environment under eucalyptus trees.
  • Naegleria gruberi
    Naegleria gruberi
    Credit: Lillian Fritz-Laylan
  • In addition to sweet, salty, sour, bitter and umami, the human tongue can also taste fat, with our ability to taste fat linked to our weight, the more sensitive to its flavor, the lower the weight.
  • Cool animated gif of two icebergs colliding as seen from space.
  • In 1996 Dr. Frances Gulland discovered that “18 percent of deaths in stranded adult sea lions were the result of tumors in the reproductive and urinary tracts” with other species of mammals getting cancer, scientists need to find out what combination of industrial pollutants is causing them.
  • Naegleria gruberi Genome Sequencing:
  • h1

    Science Stuff for Moonday, 20100308

    Posted in Science Etcetera on March 8th, 2010
  • Scientists are “cautiously excited” that Bruce Hudson, from Ontario in Canada, has identified interstellar dust from the Stardust spacecraft using the Stardust@Home internet application.
  • Aerogel Tray Used to Collect Particles
    Aerogel Tray Used to Collect Particles
    Credit: NASA
  • The “big mean drunk” stereotype gets some weight, as an experiment finds that large males become more aggressive when drunk, administering shocks to pretend opponents in a laboratory contest.
  • Ritalin appears to increase brain plasticity, increasing the activity of the neurotransmitter dopamine to enhance the speed of learning.
  • Survey finds large differences in opinion as to what constitutes sex, with the oldest and youngest male age groups the least likely to consider certain behaviors qualifying.
  • Stardust satellite thru Comet’s Jets:
  • h1

    Science Paths for Venusday, 20100305

    Posted in Science Etcetera on March 5th, 2010
  • Fossil find in Tanzania pushes back the origin of dinosaurs another 10 million years to 245 million years ago.
  • Phylogenetic postion of Asilisaurus among bird-line archosaurs
    Phylogenetic postion of Asilisaurus among bird-line archosaurs
    Credit: S. Nesbitt
  • For better health, school districts are turning kids onto water from sodas, but bottled-water can carry industrial chemicals and is hard on the environment, while, in older school districts, tap water can carry lead.
  • We humans are extremely bad at the Monty Hall problem, where after choosing one of three doors for a hidden prize, and then having one of the other two doors eliminated, you should always switch your choice because your first choice was 1 out of 3, while the second is 50/50. It appears pigeons are better than us figuring this out, going from switching their choices “36 percent of the time on day one to some 96 percent of the time on day 30.” Meaning pigeons are more empirical than we are with our preconceptions.
  • w00t!!! Popular Science has put its entire archives online for free. That’s 137 years of Popular Science!!!
  • Diver removes Frisbee from shark:
  • Visit msnbc.com for breaking news, world news, and news about the economy

    h1

    Science Wonders for Jupiterday, 20100304

    Posted in Science Etcetera on March 4th, 2010
  • Out of sight, out of mind. The danger of extinction is that, once a species disappears from the Earth, we quickly forget it about it.
  • Yangtze River Dolphin
    Yangtze River Dolphin
  • A comparison of the sinking of the Titanic and the Lusitania found that women and children go first if there’s time for it, as the Titanic’s women and children were saved because the boat sank slowly, and the men went down with the ship, but the Lusitania sank quickly, leaving it a free-for-all to get to the lifeboats.
  • Discovery has a beautiful slideshow of cuttlefish glowing through the power of bacteria accompanied with the fantastic story of symbiosis between squid and the microscopic culture.
  • Contaminated food results in 5,000 deaths and 325,000 hospitalizations a year, costing America $152 billion annually. The article goes on to detail the complex regulatory system that monitors food safety and the increasingly complex system that brings food to our grocery stores, where a bag of salad can involve multiple farms.
  • Timelapse of swarming monster worms and sea stars eating a dead seal:
  • h1

    What’s the Right JavaScript Framework, If Any?

    Posted in Geeking Out on March 3rd, 2010
    JavaScript Frameworks
    JavaScript Frameworks

    I recently checked out Google’s AJAX Libraries, which, aside from being inaccurately titled, provides a means for web developers to access functionality in a wide variety of popular JavaScript frameworks and toolkits without having to host the libraries themselves. Simply include the base Google library, and then use it to load whatever framework you want to access in you code. It’s not for me, as I’m a total control-freak when it comes to production implementations of my code, and I don’t like having my web pages hang up trying to access URIs on outside domains, which definitely happens to the code I run locally using this tool; however, it does provide a convenient playground for testing out different JavaScript frameworks and toolkits.

    You can do anything with JavaScript, but you have to program around its shortcomings. How JavaScript functions depends on the ECMAScript engine running it, with Firefox running TraceMonkey, Chrome running V8, and Internet Explorer running Trident, it makes it difficult to write code that runs the same in all browsers. Then there’s JavaScripts’ object-orientation strategy, which uses prototype chains for inheritance, confusing most OO programmers. Finally, there’s some major oversights in JavaScript functionality, like the fact that it lacks a trim() function.

    There are two types of JS Frameworks, those that extend JS functionality for the advanced programmer and those that simplify coding for the novice. If you’re an advanced programmer, it’s nice to have true object-orientation in your JavaScript. If you’re a novice, it’s nice to be able to whip out some fancy special effects with just a few lines of code. What follows is my understanding and impressions of these frameworks as I used Google’s Libraries to play with them.

    Beginner Toolkits

    The Dojo Toolkit, Yahoo! User Interface Library, jQuery UI, and Script.aculo.us are three toolkits brimming with easy-to-implement effects to enhance a webpage without resorting to plugins like Flash or Silverlight. Underneath these toolkits are frameworks. For instance, Scriptaculous is built on the Protoype framework, and jQuery UI on the jQuery framework. Aaron Newton’s jQuery vs MooTools has a great explanation of the difference between a toolkit and a framework:

    Part of this consideration is the notion of a framework vs a toolkit. MooTools is a framework that attempts to implement JavaScript as it should be (according to MooTools’ authors). The aim is to implement an API that feels like JavaScript and enhances everything; not just the DOM. jQuery is a toolkit that gives you an easy to use collection of methods in a self-contained system designed to make the DOM itself more pleasant. It just so happens that the DOM is where most people focus their effort when writing JavaScript, so in many cases, jQuery is all you need.

    Each of these toolkits provide their own unique features. For instance, YUI provides sophisticated event timing, categorized into “available,” “contentready,” and “domready,” allowing for executing JavaScript functions when document objects become available, when the object and its children become available, and when the entire document is available to improve the performance of your web page. Nifty, but also a bit esoteric, a reminder that, when we buy into a framework, we are also buying into a development methodology.

    One problem I have with all of the larger, bells-and-whistles JavaScript toolkits is that I find myself browsing their libraries of plugins, trying to find some way to work their dazzling features into my web pages; when, in reality, the way I develop, the features I need to implement simply emerge, and I go looking for scripts as I need them. If I adopt a feature-rich framework, then I’m going to be out of luck the moment I need functionality it doesn’t include.

    Another thing to consider is how intrusive the toolkit is. If you’re planning on including 50 to 100 kilobytes of framework code in every web page on your site, how much more code is needed to exercise its functions?

    Here’s Dojo’s fade-out effect:


    dojo.require("dijit.form.Button");
    function basicFadeoutSetup() {
    function fadeIt() {
    dojo.style("SomeElementId", "opacity", "1");
    var fadeArgs = {
    node: "SomeElementId"
    };
    dojo.fadeOut(fadeArgs).play();
    }
    dojo.connect(dijit.byId("basicFadeButton"), "onClick", fadeIt);
    }
    dojo.addOnLoad(basicFadeoutSetup);

    Here’s the YUI version of the fade-out effect:


    YUI().use('anim-base', function(Y) {
    var anim = new Y.Anim({
    node: 'SomeElementId',
    to: { opacity: 0 }
    });
    var onClick = function(e) {
    e.preventDefault();
    anim.run();
    };
    Y.get('SomeElementId .yui-remove').on('click', onClick);
    });

    Here’s the jQuery UI version of the fade-out effect:


    $("SomeElementId").hide('highlight');

    Finally, we have Scriptaculous’ fade effect:


    $('SomeElementId').fade();

    On the one hand, the Dojo and YUI examples appear to offer much more customization in the implementation of their features, while the jQuery UI and Scriptaculous examples offer simplicity and ease of implementation. If you need something customized with the latter two toolkits, you’ll need to code around them. While with the former two toolkits you’ll need to customize them their way.

    And that can be a real problem. If you are a novice JS developer and you adopt Dojo or YUI, you will never become an advanced JS programmer. You might become an advanced Dojo or YUI programmer, but those are much more narrowly defined skill sets, which are less marketable to companies with established development environments.

    Advanced Frameworks

    Sam Stephenson’s Prototype framework and the MIT Licensed MooTools are true JavaScript frameworks intended for advanced programmers. Both frameworks overcome the awkwardness of JavaScript’s prototypal inheritance by enabling class-based inheritance to make it function more like a mainstream object oriented language.

    You won’t find fade() functions in these frameworks, but you will find enhanced means of accessing the objects in a web page (DOM) (jQuery goes so far as to provide a means to query the DOM for arrays of objects). You will also find useful functions such as trim() and cross-browser, streamlined methods for making AJAX calls. With Prototype and MooTools, you’ll still need to write your functions, but with the adoption of the methodologies within these frameworks, you should find your coding streamlined and more robust.

    As thin and streamlined as these frameworks are, they still include much more functionality than most JavaScript developers need in their average web page. If I need a trim() function, I’ll go get one somewhere online. If I need mainstream object-orientation, I’ll use Prototype on the page where I need it. The problem with these frameworks is that, if you’re smart enough to be using them, you’re probably smart enough to not be using them.

    Conclusions

    Here’s an example of what it takes to roll your own fade-out effect:


    var TimeToFade = 1000.0;

    function fade(eid)
    {
    var element = document.getElementById(eid);
    if(element == null)
    return;

    if(element.FadeState == null)
    {
    if(element.style.opacity == null
    || element.style.opacity == ''
    || element.style.opacity == '1')
    {
    element.FadeState = 2;
    }
    else
    {
    element.FadeState = -2;
    }
    }

    if(element.FadeState == 1 || element.FadeState == -1)
    {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }
    else
    {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
    }
    }

    function animateFade(lastTick, eid)
    {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;

    var element = document.getElementById(eid);

    if(element.FadeTimeLeft <= elapsedTicks)
    {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = '
    + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
    }

    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft/TimeToFade;
    if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

    element.style.opacity = newOpVal;
    element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';

    setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
    }

    Of course, you would hide the above code away in an include file, and invoking the fade effect would simply require:


    fade('SomeElementId');

    But including the above code, even uncondensed, would require only a small fraction of what including any of these frameworks would necessitate in condensed form. Plus you have the strength of understanding your code and how it works. You don't always have the time to spend a week rewriting someone else's script to fit the specifics of your situation or writing your own from scratch, but if you do, you will be rewarded for it. The script will become your own.

    Frameworks and toolkits have their uses, and I don't want to disparage them; however, two rules come out of this analysis for me. First, developers who are novice enough to use a feature-rich toolkit will hurt themselves by adopting one, because they won't be learning mainstream JavaScript. Second, developers who are skilled enough to make use of an advanced framework probably don't need one, but could benefit from analyzing them for techniques to use in their own code.

    I'll continue to play with these frameworks from time to time in order to learn new techniques and best practices, but I'll stick to my current strategy of copy-and-pasting code from a wide variety of online sources. The best JavaScript framework, to my mind, remains the World Wide Web.


    Further Reading:

  • Dustin Diaz Top 10 JavaScript Functions: possibly the best post ever on functions you can include in your script vice including an entire library.
  • In my research for this post, I came across the incredibly useful $ Function, which replaces getElementById, allowing developers to type "$('SomeElementId')" instead of "document.getElementById('SomeElementId')" everywhere. There is also a Variation on the $ Function, which allows querying the DOM for arrays of objects to modify a group of similar objects with one call.
  • h1

    Science Snippets for Mercuryday, 20100303

    Posted in Science Etcetera on March 3rd, 2010
  • A 67 million-year-old mudslide fossilized a snake in the act of eating a dinosaur.
  • Snake Eating Dinosaur
    Snake Eating Dinosaur
    Credit: PLoS Biology
  • Genetic analysis of polar bears show they have adapted to climate change in the past, challenging a USGS prediction that they will go extinct if the arctic sea ice is lost.
  • The earthquake in Chile probably shifted the Earth’s axis, permanently making days shorter by 1.26 microseconds.
  • On today’s Internet, a large portion of the traffic no longer travels through the backbone networks of large Internet companies, and instead travels around the edges of the network, much of it through peer-to-peer sharing, video has become the Internet’s predominant data type, we measure traffic in terms of yottabytes up from petabytes, and researchers are struggling to keep up with its ever-changing shape.
  • The State of the Internet:
  • JESS3 / The State of The Internet from Jesse Thomas on Vimeo.