> JSAN.cwd allows the user to know what the working directory of the
> currently executing script is, as long as that script was passed by
> JSAN.require. For anything that is a moderately advanced script that
> has anything to do with the file system then this can be a really
> useful feature. Say for example you have some image files and css
> files that are related to a script then you can locate those files and
> use them.
Nice!
> I also managed to remove two useless private functions
> JSAN._convertPathToUrl and JSAN._convertPackageToPath so I didn't
> increase the file size in the process of adding JSAN.cwd to JSAN.js...
Did you clone the code on GitHub?
> Finally when I was testing JSAN.js I noticed that it did not work in
> Opera because AJAX requests for non-existant files return a blank
> string rather then null like in firefox.
>
> http://jsan.googlegroups.com/web/JSAN.js?gda=HekV0zkAAAD6kWaoCbCT94Ly_Otqo4xbQwMtIW-r17nBq2YXiGHhuiFtYEPVAfuxgrZ5rQJorQGECKgQbmraGdxlZulaYnsh
>
>
> Furthermore there is a lot of general improvements that could be made
> to the JSAN.js file:
>
> 1). Use caching in the for loops so that you do not recalculate things
> in every iteration.
> 2). Use mixin with an object literal to save space.
> 3). Do not make a private function just to use it once, instead make
> it inline to save space.
> 4). The whole file doesn't fit on one line right now.
+1
Note that we also decided, on IRC I think, to change the name from
"JSAN" to "Just". This is because, really, it has nothing to do with
JSAN itself, but is a library to add library loading to JavaScript.
Since you have the tuits to be doing this hacking, do you feel like
making that change, too?
> Expect another version of JSAN with a lot more improvements. I want it
> to be built to such a point that if anyone looks at it they think
> "this code couldn't possibly be any better."
Go go go!
Thanks,
David
I am also interested in writing a package manager for JSAN that runs as
a firefox extension, integrates with the openjsan site and can interact
with the system to install any file into any location on the user's hard
disk.
Christoph
[1] - https://wiki.mozilla.org/ServerJS/Modules/SecurableModules
[2] - https://wiki.mozilla.org/ServerJS
I think this is a great idea.
Christoph
> I am interested in contributing to Just to enable it to load securable
> modules [1] as being specified by the ServerJS [2] group. Is there an
> interest to support this capability?
The module description there sounds pretty close to what JSAN.use()
does, although use() doesn't return a function, it installs it into
the calling namespace. But I'd want to have the ability to tell a
module to export more than one function at a time, personally.
> I am also interested in writing a package manager for JSAN that runs
> as
> a firefox extension, integrates with the openjsan site and can
> interact
> with the system to install any file into any location on the user's
> hard
> disk.
Ooh, nice. +1
Best,
David
> I could easily throw together a 'Just.js' that is pretty much the same
> as the current 'JSAN.js'. The question we have to ask ourselves though
> is what do we do about CSS.Change, MochiKit, and all those other
> modules that depend on the JSAN JavaScript interface? It is going to
> be really hard to get rid of the JSAN.js file if that is what you guys
> are aiming for, and if we do create 'Just' we are probably just going
> to divide the community which isn't quite good either.
Yeah, it'd be tricky.
> I am thinking why can't we have JSAN.js be a standard interface for
> loading JavaScript modules regardless of what platform you are working
> with? That way if somebody comes around with a different file system
> interface other then AJAX such as: Titanium Appcelerator, Serverjs,
> and who knows how many others then we can just switch out the JSAN.js
> file as long as it implements JSAN.use and JSAN.require and it will
> immediately work correctly.
The reason we wanted to change the name of the JavaScript library is
because it has nothing to do with (Open)JSAN. The name is a misnomer.
I agree that it could be difficult to get other libraries to adjust to
the name; we'd obviously have to have some sort of deprecation policy
and provide backward compatibility for a while.
John, what did you have in mind here?
> Let me give a hypothetical situation: we move all the modules over to
> 'Just.js' but then the Titanium people make 'TitaniumLoader.js' well
> there is no hope of there interface ever working with all the modules
> because we use 'Just.js' but what if instead they created a different
> version of 'JSAN.js' then it would work correctly....
I don't see how the naming being JSAN or Just effects such situations.
They just rename the file to JSAN.js or Just.js, as appropriate. I
don't think that the interface will change much. Will it?
> Anyways if you can elaborate more on how you are going to deal with
> such issues as fragmenting the community and dealing with all those
> old modules then we can get started with building this new interface.
Yeah, it's not something I'm working on, I just wanted to bring it to
your attention.
Best,
David
Link for your revised version? Is it in GitHub?
—Theory
There isn't much of an excuse anymore not to use JSAN.js.
Also, I do not see why if (JSAN.includePath.length==1) there would be
more then one HTTP request.
Besides I have not seen a better option. I have not seen Dojo do any
better with dojo.require and JS.Class require is no better either.
If you have your own local installation then HTTP requests are not a
performance issue so grouped dependency loading should be an OPTIONAL
optimization after the fact, which can be done in JSAN if we combine
the statements. It only takes 3.8 kb for JSAN now so I do not think
more options will hurt.....
I would be glad though if Joose itself would be reduced to like a 5 kb
core with optional loading of the other modules, because I have a
working implementation of Classes and Roles in like 5 kb and that is
all I need.
The whole 41.8 kb is way too much for many people including myself,
when most of the things in there are not going to be used by the
average person. In fact, that is about the same size as the entire
JS.Class standard library.
Okay but there is no reason why you would need to make a separate
interface instead of doing that within JSAN as people already have
been doing.
I mean one of the biggest problems with the JavaScript
community is we do not have unity over anything, even the
implementation of the language itself is divided by Internet Explorer,
Firefox, Opera, Chrome, and Safari. Then for module loading there is
Dojo, JSAN, JS.Class, YUI 3, JSPAX, Joose.... In Perl there is just
one implementation used and there is just one module loading mechanism
and if it were any other way the language would be as dead as
Fortran.
In Perl6 there is no Moose there is just one way of creating Classes
and Roles and I like Perl6 but in JavaScript you have to look at
JS.Class, Joose, and all these different people competing and everyone
has a different interface. Sometimes I feel like just writing standard
JavaScript is the best way to go so that you do not alienate any
developer with a library.
Also since we are on this topic something that I think is a real waste
and that is really annoying is this:
Module("com.test.module", function (m) {
Class("Test", {
methods: { world: function () { return "hello" } }
});
});
I would much rather see this:
Class("com.test.module.Test", {
methods: {
world: function() {
return "hello";
}
}
});
There is now a browser platform [2] as well.
Christoph
[1] - https://wiki.mozilla.org/ServerJS
[2] - http://github.com/tlrobinson/narwhal/tree/master/platforms/browser
>> - it can't be extended (easily) to support dynamic css/images/
>> whatever
>> loading
>
> The point of the JSAN standard is not to load all your files for
> you!!! The point is to be a 4 kb extension to the JavaScript language
> that doesn't depend on any other library and which can be used to load
> other libraries.
Well put (and part of the reason I suggested changing its name to
"Just"). But development and marketing will need to be pushed forward
for any good to come of it.
Best,
David
> In Perl use() and require() are both are core part of the language,
> JSAN.js merely implements a few statements that should have been put
> in the core of the language A LONG TIME AGO.
Agreed. I think Brandon might agree, as well.
> I guess the name of the file doesn't really matter. I would just like
> people would are developing JavaScript libraries to continue to use
> JSAN.js because it is supported either way.
Well, it'd be `Just.use()` and `Just.require()`, so it's a class name,
as well.
> I am okay with the idea I am thinking about adding the following:
>
> window.Just = window.JSAN;
>
> But since nobody uses window.Just I do not know if it will do any
> good.
The idea is to then encourage people to use the loading functions from
Just rather than JSAN, since JSAN.js is not the same as JSAN
(openjsan.org).
Best,
David