Follow me: @D_mitar

Most read posts recently



Feb 8th 2012 × Manage lazy-loading handlebars / mustache / other templates via MooTools

I have started using Backbone.js but with handlebars templates (like in Ember.js) that I parse through Underscore.js. Anyway, to cut a long story short – I did not want to have a bunch of flat script tags with HTML in the document body on page load so I thought of a way to lazyload and bring the templates from an external repository.

The result is Asset.templates – written in the style of MooTools more’s Asset.images/javascript or whatever. The idea is: it uses Request.HTML to fetch the template file; it then injects it as a script tag into the document.head; it sets the correct type (text/x-handlebars in the example but it’s an option) and a property that lets you use a selector engine to reference and load it (data-template-name in the example, but it can be anything, including id – if you like).

It loads the files asynchronously and firess onProgress and onComplete events – as well as onFailure. If any template is missing and onFailure fires, it won’t fire the onComplete so you can recover early.

Loading a template a second time will NOT inject a new script tag but will update the existing template instead.

Here’s a gist with the code and an example case:

Full gist here: https://gist.github.com/1768949


Nov 2nd 2011 × mooGrowl: a lightweight growl style class for mootools 1.4

There was notiMoo and I am sure there have been other javascript/mootools Growl notification solutions already. Yet, none of them were CSS3 and mootools 1.4 friendly, so I created a new Class instead.

Check out mooGrowl on GitHub
https://github.com/DimitarChristoff/mooGrowl

View the demo on jsfiddle:
Full screen or normal jsfiddle

Screenshot of some Growls:

no

Oct 18th 2011 × Working with dynamic Class names in MooTools

This is somewhat trivial but is also useful and is a common question that a lot of people ask. The problem is in 2 parts: How to instantiate a Class based upon a dynamic name/variable and how to identify the Class name that has created a MooTools Class instance (the prototype, really).

First of all, to make a dynamic instance based upon a variable name, you simply need to know the name and context of execution (scope) of the Class you want to instantiate.

// define the class in the current scope / global object
this.foo = new Class();

// define the class in a namespace
var namespace = {
    foo: new Class()
};

// get the variable class name we need to use from any source into a variable...
var dynamic = 'foo';

// make the instances
var instance1 = new this[dynamic]();
var instance2 = new namespace[dynamic]();

So far, so good. This is pretty standard javascript and is self explanatory.

The harder bit comes when you have an instance and you are trying to find what Class name it is an instance of. We will create a small function that can help:

function getClassNameOfInstance(mootoolsClassInstance, context) {
    // query the context (this or custom object) for the instance we are working with
    return Object.keyOf(context || this, mootoolsClassInstance.constructor);
}

// use it on the global object
console.log("instance1 is: ", getClassNameOfInstance(instance1)); // foo

// use it on the namespace object
console.log("instance2 is: ", getClassNameOfInstance(instance2, namespace)); // foo

This function will check the context object for the constructor of the instance and return the ‘key’ if it matches, which will be MooTools Class name.

I hope it helps someone out there. Check it on JSFIDDLE: http://jsfiddle.net/dimitar/S4rR6/2/


Jul 6th 2011 × Lazyloading multiple sequential javascript dependencies in MooTools

We all know and love Asset.js from MooTools-more. It affords you lazyloading by providing Asset.javascript, Asset.image, Asset.images and Asset.css. However, sometimes you need more precision when bringing in external scripts as dependencies.

Hence I created my own Asset.javascripts – based losely on a coupling of Asset.images and Asset.javascript but providing sequential asynchronous loading.

Asset.javascripts = function(sources, options) {
    // load an array of js dependencies and fire events as it walks through
    options = Object.merge({
        onComplete: Function.from,
        onProgress: Function.from
    }, options);
    var counter = 0, todo = sources.length;

    var loadNext = function() {
        if (sources[0])
            source = sources[0];

        Asset.javascript(source, {
            onload: function() {
                counter++;
                options.onProgress.call(this, counter, source);
                sources.erase(source);

                if (counter == todo)
                    options.onComplete.call(this, counter);
                else
                    loadNext();
            }
        });
    };

    loadNext();
};

Eg. usage with Arian’s DatePicker class, which uses multiple files that need to be loaded in their right order:

if (!window.Picker) {
    new Asset.javascripts([
        "/js/mylibs/Locale.en-US.DatePicker.js",
        "/js/mylibs/Picker.js",
        "/js/mylibs/Picker.Attach.js",
        "/js/mylibs/Picker.Date.js"
    ], {
        onComplete: function() {
            new Asset.css("/js/mylibs/datepicker.css");
            new Asset.css("/js/mylibs/datepicker_dashboard/datepicker_dashboard.css");

            doDates();
        }
    });
}
else {
    doDates();
}

Have fun.


Jul 6th 2011 × MooTools pattern fun: Class Implements + Extends at the same time

Update: Thanks to @CarstenSchwede, who pointed out that the MooTools Class Constructor expects the Extends mutator __before__ the Implements one, meaning you don’t need to worry about any of the stuff I had to come up with (described in this post). Upon further investigation with Arian, it turns out that MooTools 2.0 will NOT be dependent on order of Extends and Implements declarations in classes, thanks to this change by Kamicane.

The neverending debacle of Extends vs Implements, which one to use and how to use them together – has been a source of discomfort for me in MooTools for a while so I thought I’d write up parts of my experiences with it in the hope it may help somebody else.

I came to have a need to write a class that serves as my new mixin and brings a new method ‘kill‘ – (say, Class ninja) to another class (Class badass) that extends Class human. Pretty crazy, right?

The problem is, the pattern of:

var ninja = new Class({
    kill: function() {
        alert("kill!");
    }
});

var human = new Class({
    initialize: function(){
        alert("i r human!");
    }
});

var badass = new Class({
    Implements: [ninja],
    Extends: human,
    initialize: function() {
        alert("i r badass and.. ");
        this.parent();
        this.kill();
    }
});

new badass(); // i r badass, i r human, this.kill is not a function exception.

… simply does not work. The Extend here means the human prototype is the base and it lacks the kill method. Wut?

The main practical difference in subclassing approaches is that the `Implements` (mixin) does not instantiate the subclass whereas `Extends` does, so there can be only one class that is extended whereas implemented ones just copy the methods from the prototypes. How to get around being able to extend a single class only? You need class human to implement ninja instead and class badass to simply extend human. Aside from the side-effect of humans getting a new kill method (which they may or may not know about), it will mean that badass will be able to use .kill as well as call upon his direct parent human.

The whole point is, you may not always be at liberty to rewrite / refactor classes the way you want them without creating complications with other parts of your web app. You could also be be extending a Mootools native class like Request.JSONP and then decide to mixin a new storage class into your extended one (true story!)…

An interesting pattern (or rather, the only pattern I have found to work… ) to overcome this goes something like this:

var ninja = new Class({
    kill: function() {
        alert("kill!");
    }
})

var human = new Class({
    initialize: function(){
        alert("i r human!");
    }
});

human.implement(new ninja);

var badass = new Class({
    Extends: human,
    initialize: function() {
        alert("i r badass and.. ");
        this.parent();
        this.kill();
    }
});

new badass(); // this.kill works.

You could even write this as:

Extends: human.implement(new ninja),

Obviously, you can simply modiy the prototype of the parent class and do:

human.implement({
    kill: function() {
        alert("kills!");
    }
});

But this means the code you already have in ninja needs to be duplicated and this will go for all methods or properties you want to gain access to.

A practical example with Request.JSONP and an example caching class, created to allow use of localStorage. Why would you want to do that? Well, having a class that can allow you to cache replies from Request or Request.JSONP or anything at all is handy. And doing things that fetch non-volatile data through a rate-limited API is expensive, you are encouraged to cache. In other words, if you read a particular user’s Twitter profile / timeline, you should not have to request it again on a reload within the session. Same applies if you are expanding tiny URLs like bit.ly – the URL won’t change for any given hash so there’s no point in continuously fetching it.

In the following example, we cache the response for a user profile JSONP request via the Twitter API:

View the full fiddle here: http://jsfiddle.net/dimitar/AjP5A/.

For a real detailed explanation of Extends vs Implements in MooTools, grab a copy of Pro Javascript with MooTools by keeto.


May 3rd 2011 × A powerful and simple mootools modal window class called “baseBox”

This was completely overhauled.

Basically, I just released a new mootools modalBox Class called ‘baseBox’. You can see it on jsfiddle and play with it some. Full details, documentation are available on the project github page.

mootools modal box class

Features:

  • Full CSS support – whatever you do, it assigns to the box.
  • Complete control – plenty of options, events and instance references for any scripting scenario
  • Window nesting / grouping
  • Auto toggle when called on the same parent element
  • Smart closing through delegation
  • CSS3 shadows, gradients out of the box.
  • degradation to solid colours and image urls as fallback via CSS
  • CSS2D transform support – scale for FireFox, WebKit, IE9, Opera(untested?) via standard Fx.morph!
  • degradation via a simple fade when not supported

__VERY_ flexible – should be used as a base to extend. For example, to make a class that Extends baseBox that deals with lightBox-like image only display, here’s all you need to do: baseBox.lightBox.js demo. The lightBox demo is also included in the package and is on GitHub.

Similarly, you can make your own sub-classes, for example, baseBox.Request can work asynchronously to get HTML fragments and show them to the user.

Requirements:
MooTools-core 1.3+
MooTools-more 1.3+ - you need Element.delegate and Drag.move

Feb 18th 2011 × How to clone element storage in mootools

Ever needed to clone an element and take your element storage with it? I have and it’s not easy. There’s Element.cloneEvents(), which takes the storage.events callbacks but any other storage you may have used remains unavailable behind the closure that MooTools uses for the storage object.

This bit of code tracks of any data you store (via the lstore method only) in the element’s native storage and then provides a new Element prototype Element.cloneStorage(srcElement).

(function() {
    var eliminateOrig = Element.prototype.eliminate;
    var localStorage = {};

    var get = function(uid){
        return (localStorage[uid] || (localStorage[uid] = [])); // converted to an array to store keys stored
    };

    Element.implement({
        lstore: function(property, value) {
            // use this instead of Element.store
            var storage = get(this.uid);
            // store the key so we can clone it after
            if (!storage[property])
                storage.push(property);
            return this.store.apply(this, arguments);
        },
        eliminate: function(property) {
            var storage = get(this.uid);
            storage.erase(property);
            return eliminateOrig.apply(this, arguments);
        },
        cloneStorage: function(from) {
            // new prototype to clone
            var other = get(from.uid);
            other.each(function(el) {
                this.lstore(el, from.retrieve(el));
            }, this);
            return this;
        }
    });
})();

Here is an example usage test:

document.id("bar").lstore("hello", "there");
document.id("foo").lstore("foo", "bar");
document.id("foo").cloneStorage(document.id("bar"));

// if clone works this should now say 'there':
console.log(document.id("foo").retrieve("hello"));

document.id("foo").store("ugly", "face");
console.log(document.id("foo").retrieve("ugly"));

// testing eliminate.
document.id("bar").lstore("eliminateTest", new Image());
document.id("bar").eliminate("eliminateTest");
document.id("foo").cloneStorage(document.id("bar"));
//should now be null
console.log(document.id("foo").retrieve("eliminateTest"));

To view this on jsfiddle: http://jsfiddle.net/dimitar/225HJ/

And the gist: https://gist.github.com/833584

Thanks to Tim Weink (Timmeh aka FunFactor) for the inspiration and also for pointing out that copying ALL storage is not a good idea due to class instances being stuffed there for things like Fx.Tween / Morph / Request etc, hence making me refactor it to only clone the storage that was passed through the lstore method.


Feb 11th 2011 × Feature detect base64 image support, revisited

Recently I had cause to revisit my old routine that checks if a browser can work with base64-encoded images. This is a test that modernizr does not offer so the only way to do so is to Feature-detect. To the rescue: an empty 1x1px gif image gets encoded and is then set as the src of a new Image element, then tested. If base64 is supported, the resulting image object will have width and height of exactly 1px.

Here’s the code, extending the MooTools Browser.Features object, NEARLY synchronous (best check with a 50ms delay though or loop while Browser.Featrues.base64 === null):

(function() {
    Browser.Features.base64 = null;
    var callback = function() {
        Browser.Features.base64 = this.width == 1 && this.height == 1;
        // alert(Browser.Features.base64); // true || false
    };

    var img = new Image(), img = document.id(img) || new Element("img");
    img.onload = img.onerror = img.onabort = callback;
    // 1x1 px gif to test with
    img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";

})();

And to see it in action:
http://www.jsfiddle.net/dimitar/5JT45/13/show/ or editable jsfiddle

Gist: https://gist.github.com/821370

An encoding tool that can help you convert your images: binary to base64 translator.

In reality, IE7 upwards supports it fine so all this “Feature Detect” can be skipped but it’s somewhat nicer that way.


Dec 17th 2010 × Intermoos part 5: Ryan “rpflo” Florence. On moo4q and ninjas

Here’s the next instalment in our Intermoos series: we sit and talk with Ryan Florence, one of the most extraordinary and well respected coders, the man behind moo4q, SlideShow, mooDocs and the MooTools magazine. I thought he was Italian (or at least French) for a long time. I was wrong…

Name: Ryan Florence
Nickname: rpflo
Country: USA
MooTools team: none / occasional contributor
Age: 29
Company / Occupation: Clock Four / Senior Technical Consultant
Blog: http://ryanflorence.com/
Website(s): http://moodocs.net
Twitter: @ryanflorence
GitHub: https://github.com/rpflorence
Famous for: The blog, the magazine, moo4q, SlideShow, MooDocs
A little bit about yourself and your background…
I live in Salt Lake City, UT with my wife and two kids (a 3 year-old iPad addict daughter, and a chubby 3 month old boy). I work from home for the bay area creative agency, Clock Four doing mostly front-end development.
How and when did you get involved with JavaScript and MooTools?
My first real job was back in the 90′s cranking out websites as a teenager for a local ISP. I tried to learn C++ in 21 days but couldn’t get past the second chapter. About the time Java applets started popping up on websites the ISP went broke. I had no interest in programming and started selling decals I made at school online (people actually mailed me hand-written checks!)

After college I was in sales, and eventually ended up working as an implementation consultant for PolicyTech, renewing my interest in web development. Dissatisfied with quickbooks on my Mac I decided I’d learn how to write a web application in PHP and JavaScript to handle my invoicing and accounting. I found scriptaculous first, but couldn’t get some animations to quit bumping into each other; then I found MooTools and its genius Fx module. I was still clueless though, mind you.

Shortly after this, MooTools 1.2 came out. The new documentation flipped a switch in my brain or something. Suddenly the concepts of objects and classes made sense. I rewrote my invoicing application as a single page, desktop-esque, ajax heavy, ridiculously awesome tool that I still use today. As I dug deeper into MooTools I accidentally uncovered a pot of golden, vanilla JavaScript knowledge.

Being self-taught, I put a high value on documentation. I wrote MooDocs to document and release my scripts and provide a way for others to share theirs (no forge yet). That site earned me an invitation into the MooTools developers circle and I’ve held the “MooTools FTW” banner ever since.
You seem to have an apprehension of MooTools that is very hard to beat and champion it daily. Why MooTools though, was it love at first sight or did you jump over from another framework?
Oddly enough, MooTools was my first programming “language”. It was my programming university–it taught me to focus on the API, test my code, and program patterns rather than implementations. Now I view everything else with that bias, whether it’s jQuery, Ruby, or Objective-C.

I stick with MooTools for two reasons. First, I love JavaScript. The Type extensions allow me to write clean, natural JavaScript–no screwing around with namespaces and abstractions that hide the language: arr.include(item) versus ns.utils.array.include(arr, item). Second, I love classical inheritance, and object templates. My brain is naturally wired to think that way. The world around me is designed that way–dogs inherit from mammals. The end goal is to reuse code, which I can’t seem to do as well with differential inheritance–which is like, Siamese twins can share the same legs, right?
I know you’re also a bit of a jQuery user (cough) and in trying to make it more usable and scalable, you created moo4 – a project that brings MooTools Class to jQuery. How is that going and do you think it can ever be considered stable and reliable enough to be used as the basis of serious Web App development under jQuery?
Moo4q definitely elevated my reputation in the JavaScript community and was a lot of fun to figure out. It’s certainly stable, I’ve used it several times in production (it’s just a custom build of MooTools plus a small Class mutator). The site gets about 100 visits a day, mostly to the tutorial page, so I think there are a few folks actually using it.

As for using it in a serious application, I dunno. From a MooTool’s perspective you’re really just swapping out the Element, Fx and Request modules for jQuery–which doesn’t really offer you anything new or better than what MooTools already has. From a jQuery perspective, you have to learn so much about MooTools’ patterns, you might as well jump all the way in.

So you’re probably asking why it exists. I use it in two cases. 1) I’m stuck with jQuery and need to do something that I’ve already done in MooTools. I’ve found that usually 10% or less of my classes have to be adjusted to become moo4q classes. 2) I’m delivering templates to a client who only knows jQuery. I can still structure my stuff the way I like to, and they can do whatever they want with jQuery after delivery.
Do you think that having something like moo4q “out there” may dissuade users from swapping over to MooTools for more involved app building? It’s as if you have just taken away one of its biggest advantages and brought light to the blind (I am only half-joking, heh)…
Haha, yeah. Originally I had hopes of it being a gateway drug for jQuery users to eventually fully convert. But in the end, moo4q is mostly appealing as moo4-devs-stuck-with-q. I don’t think it hurts MooTools adoption, probably helps by showing outsiders quite plainly what it can do. It also serves as a solid demonstration of the scope difference between the two.
What are you working on at the moment (on the framework itself or related)?
Man, I think I have development ADD. Outside of outlining more articles for my site, I’ve been working on a lot of stuff. SlideShow 2.0 is a few commits away, which brings with it a handful of (awesome) improvements and performance gains, including CSS transitions.


Speaking of which, I just released CSSAnimation, a vanilla JavaScript implementation of CSS transforms and transitions–complete with MooTools and jQuery API extensions. It powers the new transitions in SlideShow.

Two new scripts I’ve been giving a lot of attention to are Channels and Element.Behaviors. Channels is an extended pub-sub pattern that allows you to completely decouple your objects from each other. Element.Behaviors lets you separate your JavaScript from the DOM. The two together have been a lot of fun to work with.


On the SSJS front, CrypticSwarm and I just started porting packager to packager-node. I’ve also recently written an alternative MooTools documentation browser as my first node project that I hope to make a whole lot better now that I’m learning more.
Are there any other Open Source technologies or projects you are involved with?
My website is built with nanoc, a static site generator built with Ruby. It’s surprisingly powerful, and has sped up my development process at work for building micro-sites and similar projects. Haven’t had the time to give back to the project, but I have some stuff I’d like to contribute.
If time and resources were not an issue, what new features or changes would you like to see most come into the framework or the website?
Core – MooTools Core has had the same API for 2 years (!), it was done right. But I’d love an ES5 shim with no dependencies and more modularity with the Type extensions. There’s a lot of those extensions in Core that are rarely used (string.hyphenate?). At least $chk is gone, which was useful for allowing 0.

UI – I’d love to have a UI library comparable to Dojo dijit.

Website – I think a node version of the forge will get a lot more interest and contributions from the community and packager support would be awesome. Also, I’ve been promising Darren my time to write a whole boat load demos to help the sorry demos page out.
If you had not been involved in MooTools, what do you think you’d be doing instead?
I’d still be flying around the country consulting people on how to manage their policies and procedures, making a whole lot less money. I owe just about everything about my current employment to the MooTools community. David Walsh is responsible for 50% of my twitter followers and website visitors, and is always a great sounding board for APIs I’m trying to develop for my plugins. I’ve learned almost everything I know about web development from everybody who hangs out in IRC (and Aaron Newton, who doesn’t). I owe a special thanks to Thomas Aylott, who got me my current job and has helped me understand JavaScript and web development more than he probably realizes. So yeah, without MooTools, I probably wouldn’t be a developer at all.

Dimitar: Yes, I need to get SubtleGradient to say a few words here too…
So, jQuery is the biggest framework out there but MooTools is sat prettily at the #2 spot. How do you envisage library evolution and the ‘scene’ in the future?
jQuery will remain #1. Like I said on twitter a while ago, most everything about jQuery is an implementation, making it ridiculously easy to learn. Even with the recent rebirth of JavaScript, most people making websites still don’t know, or care to know, the language. For them, jQuery is the obvious choice, and rightly so.

However, people are writing more JavaScript than ever and need more than just a DOM library. Alex Sexton has an awesome talk called jQuery’s best friends. He’s a smart, influential guy. I think his approach to pull in other tools outside of the jQuery scope is totally appropriate. We are already seeing the advanced jQuery users adopt this strategy.

On the flip side, you’ve got bright developers like Rebecca Murphey turning away from jQuery for their bigger projects. When jQuery users start feeling that “holy crap, what have I done?” feeling with their JavaScript, Dojo is the natural place to go. Just search and replace $ to dojo and you’re more than half way there. Nearly every jQuery method has a Dojo cognate. Also, both hang everything from a namespace. This makes it an easier transition than jQuery to MooTools. Add to that its incredible UI library and support and I’m quite sure Dojo will become the top library for non-trivial websites, if it isn’t already.


So what about MooTools? MooTools doesn’t seem to care a whole lot about adoption (look at our demos page), so I don’t see us making any sort of huge leap in market share. It’s a completely different paradigm. When all the books freak people out about extending the prototypes of Array and String, etc. or that “JavaScript doesn’t have classes” it adds a level of FUD that some just can’t get over. I do think, however, that our user base will continue to grow with really talented people.
This is a thorny subject but since you are a versatile programmer that can and does use multiple frameworks, how do you decide which one to include in your projects? What is your criteria/checklist?
Good question. Developers switch projects, contracts, and companies so often my motivation is mostly for the person stuck with my code a year from now, which boils down to support and documentation. MooTools is of course my default choice so I tend to ask myself these questions to justify not using it.

Who is going to maintain this code?
I write a lot of front-end templates for clients to implement into their CMS (or whatever). Once delivered, I’ll probably never see it again. Most of the time the client’s developers have little JavaScript experience outside of jQuery, so I use jQuery in these situations. If there are some really sophisticated specs, however, I’ll push the client to use MooTools, or just slip moo4q in the back door.
Do I need a UI library?
One word: dijit. It’s a part of the Dojo toolkit, well documented, and therefore likely to be supported well into the future. Everybody ought to spend an afternoon playing with Dojo dijit.

jQuery UI has a miserable API, so I’d never choose it.
MooTools doesn’t have an official UI library so you’re on your own to write and document an API, or you have to rely on plugins that may or may not have good support and documentation now or in the future. If it’s a personal project, however, MooTools, regardless.

Which browsers are supported?
Occasionally I get to work on something that only has to work in the newest browsers. In these cases I shed all the libraries and go commando with vanilla JavaScript.
What does the client dictate?
Sometimes I have to use jQuery, even if another choice would be better, because the client says so (ASP.NET, cough, shipswithit, cough). It’s not worth the fight and I like getting paid :D
If you could give one tip to new MooTools developers, what would it be? Aside from “Learn javascript”, that is?
Actually, I wouldn’t say “learn JavaScript.” When you learn MooTools, one day you’ll wake up and realize you’ve learned JavaScript.

That aside, I think my single tip would be read the source to the plugins in Core, More and the Forge (Core has some crazy JavaScript, but Fx.Tween is easy to understand). When you’re writing something that feels similar to something else, go read the source, see how they did it.
Your favourite MooTools website or plugin:
Website – jsFiddle. Plugin – SlideShow. I know it’s my own, but it is so useful for content that shares the same space (not just slideshows) I often forget that I wrote it.
Your top 5 resources for web developers (can be websites like jsFiddle, IDEs, tutorials, CSS frameworks like boilerplate, etc)
  1. Google
  2. Your editor’s documentation
  3. People, mentors, mailing lists, IRC
  4. Modernizr
  5. Early morning hacking–your mind solves the problems in your sleep, dead serious
Do you have any example sites you want to share / show off? I saw you mention the launch of new one the other day?
We just launched a new site for Capital One, advertising their student credit card, Journey. I had some extra time so I screwed around with 3D transforms and CSS transitions on the credit-101 page (safari only). It’s this project that led to Element.Behaviors and CSSAnimation.
You’ve certainly hacked a few interesting solutions recently and I am still searching for the first MooTools self-confessed ninja, is that you?
No, not me, although I did create this. All of my code is pretty much beginner’s luck, which is not the way of the ninja.

Is that your ostridge there? Thanks for your time!


Dec 15th 2010 × Intermoos Part 4: Mark Obcena. Keetology, a book and more

Great timing is essential to great interviews (cough) but this one really is a cracker. Mark Obcena only had the official announcement / release of his new book “Pro JavaScript with MooTools” earlier today (after great anticipation, if I may add).

So, what better time to get a few answers from the man of the moment than right now? I present to you the “Dr. Keeto” intermoo. Brush up on your “keetology” and start reading!

Name: Mark Obcena
Nickname: Keeto
Country: Philippines
Age: 23
Blog: http://www.keetology.com/
Twitter: @keeto
GitHub: http://github.com/keeto/
Famous for: Up The Moo herd series, Pro Javascript with MooTools book
A little bit about yourself, your background…
I’m a software developer and graphic designer from Manila, Philippines.
How and when did you get involved with MooTools?
MooTools has always been my framework of choice, but I actually got involved with the community later than most of the early adopters. It was mid-2008 when I started hanging out in the official IRC channels, and that was mostly an accident. I was doing early contributions to Appcelerator Titanium back then, and I had the idea of porting Snippely (an old MooTools project from Valerio and Tom) to Titanium. So I went to the IRC channel to ask for permission to port.

Around the same time as my appearance, Jan was working on a project called Fire, which was a MooTools extension framework for Adobe Air. Since I had some experience with Adobe Air, Jan asked me if I would like to contribute to the project, to which I agreed. We worked on the project for a few weeks but we abandoned it at the end due to being too busy with other stuff. However, the project forced me to be constantly online in the channels, and I’ve never been away for more than a few days since then.

Eventually, I got the idea of writing a series of advance MooTools articles for my blog, and that eventually became the Up the MooTools Herd series which really started my community work.

Why MooTools, what makes it special?
There are two kinds of JavaScript frameworks available today: those that rely on abstraction and those that rely on extension. Frameworks that rely on abstraction are very easy to spot, since they produce code that look nothing like native JavaScript. They stick out like a Java class declaration in the middle of an Erlang source file. Extension frameworks, on the other hand, are subtle; they blend in with the language and appear like part of the standard library.

MooTools is one of those frameworks that fall into the extension category. I really don’t see MooTools as a framework but rather as an extension to the language itself. MooTools is to JavaScript what Objective-C is to C: it’s not a new language per se, but a thin layer that adds features to the language itself. The fact that it implements both a Type and a Class system–both language level features–is a testament to this extension nature of MooTools.

This difference between abstraction-based and extension-based frameworks is important for people who actually love the languages they use. The more you like a language, the more you’ll tend to lean towards frameworks that magnify rather than mask it. You’ll want to work more closely with the language in terms of syntax and philosophy–and burying it under heavy (and often leaky) abstractions would simply be daft.

What are you working on at the moment (on the framework itself, related or otherwise)?
I’m working on a lot of stuff, most of them related to MooTools and CommonJS. Perhaps the most exciting of them is Meso, which is a cross-engine MooTools library for CommonJS. Another thing that’s keeping me busy is Deck, which is an HTTP Server layer that runs on top of Meso.
Are there any other Open Source technologies or projects you are involved with?
I’m quite involved in a lot of things, at varying extents. I used to be very active with Appcelerator’s Titanium platform, but my involvement tappered off a bit because of work. I’m also experimenting a lot with Apache’s CouchDB and Steve Dekorte’s VertexDB, and I plan on hacking the latter in the coming weeks for a project I’m building. And of course there are my own projects that I’m working on together with other MooTools devs.
I know you are working very hard on your book, “Pro JavaScript with MooTools”. How is that going, when is it coming out and are you happy with it? Do you think less advanced MooTools users will benefit from reading it and be able to improve their coding standard and practices?

Depending on when this interview is published, the book would either be coming out in a few days or has already been released. I’m quite happy with it, although I would really like to expand some chapters in the future. Print publishing places very big constraints when it comes to writing time and publishing dates, and that really affected the book. I do think it turned out good, although–like many authors–I do believe that there is a big room for improvement.

Whether or not “less advanced” MooTools users will benefit from reading the book is totally up to them. After all, the MooTools source code has been open-source from the start, and there’s nothing about MooTools in this book that you won’t learn just by reading and examing the source code. If someone really wants to learn MooTools from the inside, all they have to do is look through the source code–they don’t need my book.

It’s also not my intention to promote coding standards and best practices in this book, since it’s not a book about how to develop with MooTools. It’s a JavaScript book that examines MooTools internals to help people understand what’s going on inside the framework. The goal then is to give people a starting point in exploring the capabilities of MooTools. How they apply what they learn from the book is totally up to them.

Would you share your thoughts on what the future holds in terms of HTML5, CSS3, V8, next gen browsers, server-side javascript, the role of frameworks and MooTools in web application development?
I believe that things are just gonna get better. Even though HTML5 is uttered like a buzzword these days, the attention its been getting represents a very real acceptance of the technology from the people–not just from the web community. It’s reflective of the excitement everyone has for a better web ecosystem.

JavaScript will remain the de facto language of the web. You might think that I’m happy about this, since I like JavaScript, but it also saddens me a bit. I do want to see something like Native Client to succeed, if only to add some healthy competition on the client-side. But I don’t think that this will happen any time soon, as most browser vendors have disregarded the technology–explicitly and implicitly by not commenting on it.

Server-side JavaScript will continue to grow, but it won’t take over anything. In as much as we JavaScript people would love to think that SSJS would conquer the whole of the server-side, the truth is there are already a lot of established languages that have been offering what SSJS is selling–and a lot of them are way better at this. Fans of the popular SSJS engines like to think that they’re using something novel, but most of the ideas that these new engines are touting are simply JavaScript rehashes of things already included (by default or by extension) in other languages. JavaScript is only playing catch-up.

One advantage of SSJS, though, is the fact that JavaScript reigns supreme (for now) on the client-side, and it’s the only language that can actually claim to be *realistically* usable for both the client-side and server-side. This is why I support CommonJS as a whole rather than individual engines, because CommonJS represents an ideal rather than a solid API. Getting bound to a new-fangled engine’s APIs is dangerous once the hype dies down.

If time and resources were not an issue, what new features or changes would you like to see most come into the framework or the website?
For MooTools Core, I’d personally want to see it split up into two main projects: one for ECMAScript and one for JavaScript. This is needed if MooTools branches out into the CommonJS space in the future, since CommonJS by default is more concerned about the ECMAScript rather than the JavaScript part.

I’d also like to see some additional metaprogramming APIs for Core. The biggest strength of MooTools is its extensibility, and I’d love to see some of the internals exposed via safe APIs. This will benefit those who’d like to extend MooTools without touching Core.

If you had not been involved in MooTools, what do you think you’d be doing instead?
I’d probably be running around the office right now looking for my editor to get him to approve my story for next morning’s paper.
MooTools is now officially the 2nd largest framework / library out there, how do you think it will grow from here?
There are a lot of factors, really. For one, it still depends on the people. As more and more developers start building more complex applications, the bigger the need is to use the proper tools for the job. MooTools is a very good framework to work with, since it can actually scale pretty well–but even that depends on the person using it. Not everyone who touches a paint produces a Picasso.

And even if people start flocking towards better frameworks, it does not mean that they’ll automatically choose MooTools. MooTools is awesome, but it’s not the only awesome framework. There are other scalable and well designed JavaScript frameworks competing in the space, and MooTools is simply one of the choices.

If you could give one tip to new MooTools / javascript developers, what would it be?
Be a scientist. The developers I respect and admire the most are those who always feed their curiosity, are always hungry for new information and are always exploring. They don’t sit around and wait for someone to answer their questions; they find out the answers for themselves. They experiment, they observe, and they share their results to the world.
Your favourite MooTools website:
The official one.
Your top 5 resources for web developers (can be websites like jsFiddle, IDEs, tutorials, CSS frameworks like boilerplate, etc)
- Google (with proper search keywords).
- Reddit and Hacker News, or basically any site that aggregates a lot of stuff.
- The documentation for the technologies you use, and their source code.
- The documentation for your text editor.
- Your creativity.
If you want to share some examples of your work…
All my public code are available on Github (http://github.com/keeto/)

Thank you for your time!

P.S. Now that the book is hot off the press, I should mention Keeto is available to pester with _interesting_ problems on IRC (just like most other teams in the MooTools community) – freenode.net #mootools. Go and say “hi” and say Dimitar sent you :)