I'm sorry I didn't respond earlier. Of course we'd love collaborators!
I think the Prototype dependency issue is a little more complicated. I'm
personally not a fan of littering the code with for-in loops and
hasOwnProperty checks, and performance has not been an issue.
Underscore.js provides some uniform iteration functions that could hold
us over until the next version of JavaScript. As a dependency, it is
much smaller and less invasive than Prototype.
However, Underscore.js provides minimal support for inheritance and
class mixins (IIRC just an "extend" function), which we do use
extensively for our controllers.
I hadn't seen that Google Code started supporting Git. I'll work on
uploading our source this weekend.
Thank you,
John
ok - looking at the controllers now i see how inheritance will play a bigger role. maybe something like https://github.com/kriszyp/compose would be suitable. its only 3kb minified (1kb with gzip). also, maybe using something like https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js would be a good idea rather than underscore. by using es5-shim, you make it an "optional" dependency. for example, if someone knew that they were deploying to an environment that already supported es5, they would not need the shim. whereas if you use underscore, you always have to include it. eg: // works without needing es5-shim if running in an es5 environment Object.keys(someObj).forEach(function(key) { var value = someObj[key]; process(value); }); // always needs underscore _.each(someObj, function (value, key) { process(value); }); both es5-shim and underscore use native implementations when available and comparing minified size, the combination of composejs (3kb) and es5-shim (8kb) are similar to underscore (12kb) except that if someone was deploying to an es5 environment (eg mobile devices) they don't need to include es5-shim so then the 8kb saving could be a significant win for them. for full disclosure, i'm a committer for dojo and composejs is developed by another dojo committer (kris zyp) and is being discussed as a candidate for replacing dojo.declare in dojo 2.0 and possibly being introduced as an optional alternative to dojo.declare in a release before 2.0 thanks, ben...
Did this not go to the group originally because you weren't a member
yet, or do I need to change some settings to allow CC messages through?
> ok - looking at the controllers now i see how inheritance will play a bigger role. maybe something likehttps://github.com/kriszyp/compose would be suitable. its only 3kb minified (1kb with gzip).
I'll take a look at this when we revisit controllers (probably next week
or later this week if I work fast enough).
> Object.keys(someObj).forEach(function(key) {
Does this work by modifying the Object protoype, like PrototypeJS? Right
now, it appears in my tests that the methods PrototypeJS adds to Arrays
show up in for-in loops, even with a hasOwnProperty check.
Thank you for the information and advice!
- John
On 1/30/2012 12:22 PM, neonstalwart wrote:
> i posted this directly to john - posting here for visibilityDid this not go to the group originally because you weren't a member
yet, or do I need to change some settings to allow CC messages through?
Does this work by modifying the Object protoype, like PrototypeJS? Right
now, it appears in my tests that the methods PrototypeJS adds to Arrays
show up in for-in loops, even with a hasOwnProperty check.
This results in two loops, correct?
I'm not too hip with the JavaScript community. Is this how everyone does
it these days, or is it more popular to use a hand-written for-in loop
with a hasOwnProperty check?
What I would give for a clean, concise, efficient for-loop...
- John
This creates an anonymous function each time this loop comes up. Is that
efficient in modern engines yet? I know I did the same thing with
Prototype, but if I'm going to be refactoring loops (and setting new
habits), I figure I should try to find the best option.
- John
Thank you for linking this. I think this is enough evidence for me to
proceed. Performance hasn't been a problem with HotDrink in our
experience, but I wanted to know the state of the art.
> modern engines are fairly
> good at optimizing these anonymous functions
That is good to hear.
> my opinion is that hotdrink can probably afford to lean towards more
> modern browsers and it shouldn't be an issue to anyone wanting to adopt
> this library. if you already had a large user base then it might be a
> different story.
I agree. Legacy browsers are not a priority for HotDrink.
> ideally, you should add some performance tests (maybe they already
> exist) so that you can profile these changes.
This is definitely an ideal. HotDrink doesn't have any right now. In our
manual testing experience, performance has not been an issue, so we
haven't invested the time and effort for a performance testsuite.
Our biggest hurdle is devising large test cases based on real
applications. In our experience, large multi-way constraint systems just
do not appear in real-world interfaces. Even small systems are rare. I
speculate that factors may include lack of support in existing
frameworks, complexity, or habit (developers used to thinking in terms
of single-way constraint systems).
Thank you,
John
- John