I hate to risk starting a my-framework-is-better-than-your-framework
thread, but I'd really like to here people's opinions on / experiences
with the merits of prototype + lowpro over other frameworks such as
JQuery that seem to be gaining some mind-share.
We've been bundling lowpro with Hobo for a while and are intending to
move towards "lowpro style" for all the client-side behaviour that
comes with Hobo.
At the same time I've always got half an eye on JQuery, and have been
getting increasingly tempted to at least give that option a try.
One thing that occurs to me is that I'd miss the nice rubyisms that I
get with prototype (e.g. little things like String#gsub)
It would be awesome to port the low pro syntax to JQuery. Now the thing is, low pro is just a tiny abstraction layer above proto, in theory we should be able to port the same layer to JQuery.
> Here's my take from September: > http://meme-rocket.com/2007/09/07/agnostic-unobtrusive-javascript/ Short > of it is you need the livequery plugin if you want to do UJS on dynamic > content. And it is of course possible to use both prototype and JQuery > together.
On 1/21/08, Matt Aimonetti <mattaimone...@gmail.com> wrote:
> It would be awesome to port the low pro syntax to JQuery. Now the thing is, > low pro is just a tiny abstraction layer above proto, in theory we should be > able to port the same layer to JQuery.
I've considered doing this myself. Ive used both jquery and prototype heavily in the past. The reason I like prototype over jquery is that prototype offers more general programming tools where as jquery is just about dealing with the DOM. Secondarily, in my experience, the chaining idiom in jquery tempts people into writing some pretty unreadable code.
However, jquery is really compact, very well documented and does its job well so I can see the attraction so 10 minutes spend writing behaviours on top of it would be well spent. Ill see what I can come up with. Something like:
$('.date').attach(DatePicker, { opt1: 34 });
Would do the job, I can even bring over the inheritance stuff...and the DOM builder. I'll do it tomorrow morning if I have time.
> On 1/21/08, Matt Aimonetti <mattaimone...@gmail.com> wrote: > > It would be awesome to port the low pro syntax to JQuery. Now the thing > is, > > low pro is just a tiny abstraction layer above proto, in theory we > should be > > able to port the same layer to JQuery.
> I've considered doing this myself. Ive used both jquery and prototype > heavily in the past. The reason I like prototype over jquery is that > prototype offers more general programming tools where as jquery is > just about dealing with the DOM. Secondarily, in my experience, the > chaining idiom in jquery tempts people into writing some pretty > unreadable code.
> However, jquery is really compact, very well documented and does its > job well so I can see the attraction so 10 minutes spend writing > behaviours on top of it would be well spent. Ill see what I can come > up with. Something like:
> $('.date').attach(DatePicker, { opt1: 34 });
> Would do the job, I can even bring over the inheritance stuff...and > the DOM builder. I'll do it tomorrow morning if I have time.
That's a point. I'll make it use livequery if its present although these days I don't really favour those kinds of solutions. If I need to work with a changing DOM I use event delegation.
I'll see what I can put together.
On 1/26/08, Matt Aimonetti <mattaimone...@gmail.com> wrote:
> > On 1/21/08, Matt Aimonetti <mattaimone...@gmail.com> wrote: > > > It would be awesome to port the low pro syntax to JQuery. Now the thing > is, > > > low pro is just a tiny abstraction layer above proto, in theory we > should be > > > able to port the same layer to JQuery.
> > I've considered doing this myself. Ive used both jquery and prototype > > heavily in the past. The reason I like prototype over jquery is that > > prototype offers more general programming tools where as jquery is > > just about dealing with the DOM. Secondarily, in my experience, the > > chaining idiom in jquery tempts people into writing some pretty > > unreadable code.
> > However, jquery is really compact, very well documented and does its > > job well so I can see the attraction so 10 minutes spend writing > > behaviours on top of it would be well spent. Ill see what I can come > > up with. Something like:
> > $('.date').attach(DatePicker, { opt1: 34 });
> > Would do the job, I can even bring over the inheritance stuff...and > > the DOM builder. I'll do it tomorrow morning if I have time.
Testy = $.klass({ initialize: function(arg) { alert('ive just been attached with the arg ' + arg); }, onclick: function() { alert('ive been clicked'); }
});
Btw, $.klass is a full port of the Prototype Class.create stuff so you get that as a bonus and can use all the inheritance stuff in the same way.
Another little bonus is that if you are running livequery it does some magic and automagically attaches new instances of the behaviour whenever the DOM is changed so for the above example if you $(document.body).append('<p>Another para</p>') then it gets its own behavior instance as well.
So, I think it needs some more bashing (and some unit tests) and I think it would be good to ship with some behaviors like normal Low Pro does. Probably Remote and Observed...
What do ya'll think? After sitting and coding it Im actually really pleased with how it turned out. It's much simpler than the Prototype implementation and fits jquery's style a lot more. I might defect :)
I think it's awesome Dan. The last thing keeping me on the prototype stack was lowpro. I'll probably miss prototype but JQuery documentation is so much better and the add-ons are compelling enough. I'm moving. I'll write when I get there…
> What do ya'll think? After sitting and coding it Im actually really > pleased with how it turned out. It's much simpler than the Prototype > implementation and fits jquery's style a lot more. I might defect :)
Oh feck. I've only just got to grips with prototype... ;-)
I tried the implementation and its great! Kudos on whipping it out so
quickly.
Now, another question I have with all this framework talk.. and dare I
say it.. but Mootools 1.2 is always something that has caught my eye
with its efficiency, speed, clarity of code, and code/framework
philosophy. Any thoughts?
> Now, another question I have with all this framework talk.. and dare I > say it.. but Mootools 1.2 is always something that has caught my eye > with its efficiency, speed, clarity of code, and code/framework > philosophy. Any thoughts?
Heh...at this time, no. I don't think I want to support loads of versions of Low Pro and peronally I've never seen where Mootools fits into the puzzle as far as JS libraries are concerned. In my opinion, it doesn't really offer anything that Prototype or jQuery haven't got so I've never thought to use it myself. However, Im by no means saying it's not a good library.
I'd be totally happy for someone to do the port though. After using Low Pro's behavior classes quite heavily over the past year or so I'm really convinced that its the best way of writing components and managing the complexity of Ajax applications in general and the idea is totally transferable between libraries. I even considered trying to write Low Pro in a library independent way but after investigating it it definitely felt like it would end up very over-engineered.
To be honest, Low Pro has become quite a compact piece of code so it would only take me another 30 mins or so but I'm not sure I'd be qualified to support code that I wouldn't use myself and it would be better ran by someone from the Mootools camp.
> To be honest, Low Pro has become quite a compact piece of code so it
> would only take me another 30 mins or so but I'm not sure I'd be
> qualified to support code that I wouldn't use myself and it would be
> better ran by someone from the Mootools camp.
Right, that is understandable. However, my underlining objectives in
my applications are to achieve efficiency and performance, especially
over a browser executing JS where there are varying computers and
browsers. That usually lends itself to the people in charge of a
framework. Once I begin to adopt a framework and my applications
consume it, I hate having to port my code, so I always spend a lot of
time making a decision.. the hard part is to look ahead and consider
which framework will last.
Mootools has an interesting test suite comparing the various
frameworks: prototype, mootools and jquery right in your browser.
http://mootools.net/slickspeed/
These are older versions so I copied the test code and posted it on my
server with the latest versions of each framework: http://nulayer.com/~peter/jstest/
... I like jQuery, and I'd prefer to use it because of its adoption
and support, but from this small subset of a test, it does not perform
well at all. Reading the jQuery blog, they've taken on a developer to
optimize their code, I'm looking forward to seeing what they come up
with.