Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-02-2009, 06:22 PM   PM User | #1
bardonw
New Coder

 
Join Date: Dec 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
bardonw is an unknown quantity at this point
JXtension - JQuery's Little Brother

I recently created JXtension, a JavaScript library that is smaller than jQuery but provides many of the same features. These features include all of the following:
  • New Array object functions
  • New Function object functions
  • New String object functions
  • A $(...) CSS-like selector
  • A New Color object
I am working on including cookie handling, AJAX, and wildcard search capabilities. I currently have most of the extra object functions documented. Unfortunately, I will not have the CSS-like selector documented until after December 19 (because of my workload at school). All JXDocs (JXtension Documentation pages) and JXtension information can be found at http://jxtension.gotochriswest.com/. The complete (or full) version of JXtension can be found at http://jxtension.gotochriswest.com/J...atest(Full).js. My question for you is, what would you like to see in a JavaScript library?
bardonw is offline   Reply With Quote
Old 12-02-2009, 08:00 PM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
I like the features you have created, but i think getting anyone to use a general-purpose javascript library is a tough sell at this point.

Since a lot of your functionality is fairly common, or already avail on native JS, i would take your color part and port it to a dedicated color library.

Specialized libraries like those for color will likely have a greater appeal to more people.


one thing i hate about it (sorry) is it's re-use of standard prototype method names.
if i write a generic function (arguments unknown), and i duck-type the argument:
Code:
if(arg.map){ newRay=arg.map(logger);}
, you can see how messed-up passing a function would be ( after loading your library). To me, that's an instant deal-breaker, no appeal.

IMHO, one should NEVER replace an existing prototype method with a custom one, unless it does the EXACT same thing as the original, and one should never duplicate a non-competing property to a competing type. For example, adding mozilla's [].map to IE is fine, but making a new [].map that accepts 5 extra arguments is not acceptable.

you have to assume that people will run other libs alongside yours, so play nice with others!
same goes for globals: using "$" is going to sour a lot of grapes given the popularity of jQuery...

there is a utube/yahoo video of Resig giving a library-authoring presentation floating around, watch it.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%

Last edited by rnd me; 12-02-2009 at 08:05 PM..
rnd me is offline   Reply With Quote
Old 12-02-2009, 08:56 PM   PM User | #3
bardonw
New Coder

 
Join Date: Dec 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
bardonw is an unknown quantity at this point
Quote:
Originally Posted by rnd me View Post
I like the features you have created, but i think getting anyone to use a general-purpose javascript library is a tough sell at this point.

Since a lot of your functionality is fairly common, or already avail on native JS, i would take your color part and port it to a dedicated color library.

Specialized libraries like those for color will likely have a greater appeal to more people.


one thing i hate about it (sorry) is it's re-use of standard prototype method names.
if i write a generic function (arguments unknown), and i duck-type the argument:
Code:
if(arg.map){ newRay=arg.map(logger);}
, you can see how messed-up passing a function would be ( after loading your library). To me, that's an instant deal-breaker, no appeal.

IMHO, one should NEVER replace an existing prototype method with a custom one, unless it does the EXACT same thing as the original, and one should never duplicate a non-competing property to a competing type. For example, adding mozilla's [].map to IE is fine, but making a new [].map that accepts 5 extra arguments is not acceptable.

you have to assume that people will run other libs alongside yours, so play nice with others!
same goes for globals: using "$" is going to sour a lot of grapes given the popularity of jQuery...

there is a utube/yahoo video of Resig giving a library-authoring presentation floating around, watch it.
Thanks for the reply. I understand your concern but I am pretty sure that my library extensions (using object.prototype) offer the same functionality that was available prior to using JXtension. In other words, using the toString, indexOf, replace, and other such functions the way they are intended with regular JavaScript will produce the same results with JXtension. You will notice that the JXDocs indicate that all of the new arguments within these functions are optional. On the other hand, I will have to check to see if other browsers provide the map function for the Function object. If you have any other concerns, please reply.
bardonw is offline   Reply With Quote
Old 12-02-2009, 09:02 PM   PM User | #4
bardonw
New Coder

 
Join Date: Dec 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
bardonw is an unknown quantity at this point
JXtension Doesn't Break Code

Funny, I now see that there is already a map function for arrays provided by Firefox but my library doesn't overwrite this function (nor does it even use it). Perhaps the next version of my library will simply use the built-in map functionality if it is provided. If you find any problems with the documentation or code, please tell me.
bardonw is offline   Reply With Quote
Old 12-02-2009, 10:30 PM   PM User | #5
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by bardonw View Post
You will notice that the JXDocs indicate that all of the new arguments within these functions are optional. On the other hand, I will have to check to see if other browsers provide the map function for the Function object. If you have any other concerns, please reply.
i'm saying that Function.map is a problem to me, though I'd be fine with Function.each(), or Function.map2()...

Also, even if your new method's arguments are optional, they are present. this means that your methods could grab, for example, the 3rd argument of a [].map'd function, whereas the native method would discard it. Given the spec's instance that most of Array's and String's native methods be generic, this implies your code is not 100% compatible with native methods, and why i mentioned it as a problem.

I didn't notice anything on Object.prototype, but if you are using it, that's another major no-go for a lot of coders. True, it's arguably their fault they don't know how to iterate an array, but at the same time, libraries should strive for interoperability with the lowest of denominators...

also, try to limit the lib to just one global variable. you're pretty close to 1 already; good job not polluting the entire namespace!

Don't get me wrong, and i apologize for being a bummer; 90% of your code is solid, but the "last mile" problems might keep folks from adopting it, and that's a bummer in itself...
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%

Last edited by rnd me; 12-02-2009 at 10:32 PM..
rnd me is offline   Reply With Quote
Old 12-03-2009, 12:38 AM   PM User | #6
bardonw
New Coder

 
Join Date: Dec 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
bardonw is an unknown quantity at this point
JXtension

Quote:
Originally Posted by rnd me View Post
i'm saying that Function.map is a problem to me, though I'd be fine with Function.each(), or Function.map2()...

Also, even if your new method's arguments are optional, they are present. this means that your methods could grab, for example, the 3rd argument of a [].map'd function, whereas the native method would discard it. Given the spec's instance that most of Array's and String's native methods be generic, this implies your code is not 100% compatible with native methods, and why i mentioned it as a problem.

I didn't notice anything on Object.prototype, but if you are using it, that's another major no-go for a lot of coders. True, it's arguably their fault they don't know how to iterate an array, but at the same time, libraries should strive for interoperability with the lowest of denominators...

also, try to limit the lib to just one global variable. you're pretty close to 1 already; good job not polluting the entire namespace!

Don't get me wrong, and i apologize for being a bummer; 90% of your code is solid, but the "last mile" problems might keep folks from adopting it, and that's a bummer in itself...
Thank you for carifying about the ambiguous map function, but I can not find a browser which provides one for the Function object. Can you tell me ASAP which browser type and version you are using so that I can try to come up with a solution for this problem.

I have to agree with you about using my modified prototype functions with extra parameters. If a newbie uses extra parameters by accident for functions that are native to JavaScript, he or she may receive unwanted results.

You are right about there being no Object.prototype functions. I did not add any because IE doesn't work as expected when creating functions for this object. What I mean't to say in one of my previous posts was object.prototype.

I do realize that there can be some disadvantages to using a JavaScript library, but I figured that I would still give people a chance to use it anyway. I originally made it for a school project (a transcript viewer) but now I am finding it useful for all of my web pages and HTAs.

In response to using this with another JavaScript library, I would advise using the StdLib version. The StdLib version doesn't overwrite the "$" selector function presented in jQuery and other popular JavaScript libraries. On the other hand, using the StdLib will still give the user the ability to use the additional Array, Function, Color and String methods available in JXtension.

The last thing is, I don't play on adding any more variable names. Once again, I agree with you 100% that JavaScript libraries should not reserve too many variable names for themselves. This is why I have tried to limit it to the following:
  1. JXtension
  2. $
  3. Color
  4. parseArray
  5. xor
  6. $_GET

I may change parseArray, xor and $_GET so that they are members of the JXtension object in the future. The problem with doing this is any code that I or others may write using JXtension v1.0 will not be compatible with higher versions. Do you have any suggestions rnd me?

Thanks,
Chris West
bardonw is offline   Reply With Quote
Old 12-03-2009, 01:47 AM   PM User | #7
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by bardonw View Post
I may change parseArray, xor and $_GET so that they are members of the JXtension object in the future. The problem with doing this is any code that I or others may write using JXtension v1.0 will not be compatible with higher versions. Do you have any suggestions rnd me?
Thanks,
Chris West

yes, a few.
firstly, nobody wants to type "JXtension", make it "jx" or something (fewer buttons the better)

suggestions:

1. create a backwards-compatible trigger mode which appends window.x with each prop of jx.

2. wrap "with(jx){" (...) "};" around code authored for the old lib

3. write a textarea-based conversion kit for your old library's programmers that replaces the old string names with new property paths.

4. use a local-scope wrapper to dupe jx.x into vars:
Code:
(function(){
 var parseArray=jx.parseArray, Color=jx.Color;
}());
5. forget about backwards compat and move forward with a perfect design and implementation.

Just to clarify, no browser offers Function.map, but adding it will foil duck-typers like myself...
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
rnd me is offline   Reply With Quote
Users who have thanked rnd me for this post:
bardonw (12-04-2009)
Old 12-04-2009, 03:47 PM   PM User | #8
barkermn01
Regular Coder

 
Join Date: Nov 2007
Location: Leeds, UK
Posts: 514
Thanks: 24
Thanked 19 Times in 19 Posts
barkermn01 can only hope to improve
No Offence but Boo,

There is Already YUI, JQuery, Prototype, Moo-tools and lots more out there and there is not allot of point only idiots or lazy people use them,

Coz they are JavaScript coded which means any thing they do you can do in javascript so you learn how to that way your not using a library and downloading more then required to the users browser
__________________
Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)
barkermn01 is offline   Reply With Quote
Old 12-04-2009, 07:41 PM   PM User | #9
bardonw
New Coder

 
Join Date: Dec 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
bardonw is an unknown quantity at this point
JXtension and Other JavaScript Libraries Aren't Useless

Quote:
Originally Posted by barkermn01 View Post
No Offence but Boo,

There is Already YUI, JQuery, Prototype, Moo-tools and lots more out there and there is not allot of point only idiots or lazy people use them,

Coz they are JavaScript coded which means any thing they do you can do in javascript so you learn how to that way your not using a library and downloading more then required to the users browser
I agree that there is no need for a JavaScript library in some cases if you are well versed in JavaScript. On the other hand, there are a number times when libraries can be very useful, even for the advanced users such as yourself. I will be using JXtension for now on when developing new web content because I would like to easily obtain references to HTML objects based on certain criteria. This way, I will be able to style my pages in ways that are not available by using CSS (unless you decide to reference each element by class, tag name, or id).

Another thing that you need to remember is that not all web programmers are well versed in JavaScript. Therefore, these people would also like to use JavaScript libraries such as jQuery. Even if they do not choose to use JXtension, I want people to know that there are other options which provide similar functionality and have a smaller footprint.
bardonw is offline   Reply With Quote
Old 12-09-2009, 12:40 PM   PM User | #10
barkermn01
Regular Coder

 
Join Date: Nov 2007
Location: Leeds, UK
Posts: 514
Thanks: 24
Thanked 19 Times in 19 Posts
barkermn01 can only hope to improve
Quote:
Originally Posted by bardonw View Post
I agree that there is no need for a JavaScript library in some cases if you are well versed in JavaScript. On the other hand, there are a number times when libraries can be very useful, even for the advanced users such as yourself. I will be using JXtension for now on when developing new web content because I would like to easily obtain references to HTML objects based on certain criteria. This way, I will be able to style my pages in ways that are not available by using CSS (unless you decide to reference each element by class, tag name, or id).

Another thing that you need to remember is that not all web programmers are well versed in JavaScript. Therefore, these people would also like to use JavaScript libraries such as jQuery. Even if they do not choose to use JXtension, I want people to know that there are other options which provide similar functionality and have a smaller footprint.
I know this but it becomes a problem i work for a company where the staff know Jquery but not JavaScript this then creates problems,

If some thing cant be done in JQuery then i have program a JQuery Addon to do it for them,

Also the Selector is easy to do
get the string split on space if first char is "." or "#" do you finders E.G if its #

document.getElementById(*String with out #*)

And Class is a bit harder but none the less quite easy
__________________
Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)
barkermn01 is offline   Reply With Quote
Old 12-09-2009, 05:37 PM   PM User | #11
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by barkermn01 View Post
I know this but it becomes a problem i work for a company where the staff know Jquery but not JavaScript this then creates problems,

If some thing cant be done in JQuery then i have program a JQuery Addon to do it for them,
they pay people who know jquery but don't know javascript? tell me more about this, but post please in the geek and humor forum,
forget about geek,

best regards
oesxyl is offline   Reply With Quote
Old 12-09-2009, 08:27 PM   PM User | #12
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by oesxyl View Post
they pay people who know jquery but don't know javascript?
yeah, under the guise of "designers" and "administrators"...

bardonw: keep up the good fight. Perhaps nobody will ever use JXtension, but they might use the next one you make, or the one after that; you never know what will takeoff...
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
rnd me is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:18 AM.


Advertisement
Log in to turn off these ads.