: | Create an account
ARCHIVE TAGS ABOUT RSS

used to the noose they obey

Jul 18, 2008 17:08 EDT


You know what I want to see in a next-generation browser? The ability to create custom elements. I want to be able to write my own tag in xhtml and have the browser automatically load code, probably javascript, that would create and return that object to the browser so it could place it in the appropriate place in the dom.

It would be so easy to implement too. First you specify a path in the xhtml, say by doing the following

<link rel="elementpath"
      type="text/javascript"
      href="/elementjs/" />

Then anytime the browser found an element it didn't know of, it would try to load it via the path, for example.

Broswer finds element <combobox>
Browser tries to load /elementjs/combobox.js

Inside combobox.js there might be a function like,

function htmlCombobox(attributes, xml, text) {
    // Create input box
    el          = document.createElement('input');

    // Create div
    el.dropdown = document.createElement('div');

    for(i=0;i<xml.length;++i) {
        // Create lines in the div
        // That would act like <option>
        // tags. Then attach them to the
        // dropdown
    }

    // Attach callbacks to the element
    el.onclick  = htmlComboboxClick;

    // Return the element so the browser
    // can place it in the dom.
    return el;
}

function htmlComboboxClick(event) {
    // Do something on click, etc.
}

The arguments xml and text would work much like XMLHttpRequest's responseXML and responseText, allowing the code to create the child elements as well. Though for ease of use an additional core JavaScript function would be needed, one you could pass those child elements you don't want to create, or maybe not, I'd have to think about that.

Still, how f-ing cool would that be?

tags: programming, web

music: The Mars Volta - Miranda That Ghost Just Isn't Holy Anymore: A. Vade Mecum

mood: ok

comment | permanent link



I'm definitely a Stroustrup fanboy

Jun 25, 2008 13:59 EDT


Bjarne Stroustrup of C++ fame dissects the history of his famed programming language

Do you have any advice for up-and-coming programmers?

Know the foundations of computer science: algorithms, machine architectures, data structures, etc. Don't just blindly copy techniques from application to application. Know what you are doing, that it works, and why it works. Don't think you know what the industry will be in five years time or what you'll be doing then, so gather a portfolio of general and useful skills. Try to write better, more principled code. Work to make "programming" more of a professional activity and less of a low-level "hacking" activity (programming is also a craft, but not just a craft). Learn from the classics in the field and the better advanced textbooks; don't be satisfied with the easily digested "how to" guides and online documentation - it's shallow.

tags: c++, programming

music: The Prodigy - One Love (Original 12' Mix)

mood: contemplative

comment | permanent link