I think there are a lot of people thinking along these lines. Tom
Robinson, from yesterday:
http://groups.google.com/group/jack-js/msg/02df426d23679623
"Even if the implementation depends on Java, we should try to
coordinate the user facing APIs."
I figured it's time to funnel all of that energy and thought into
*creating* the world we all want.
> In a recent mail discussion, I suggested that we try to list the areas
> that need to be implemented, see if they already _are_ implemented on
> a high level in some existing Ajax toolkit (I'm thinking very much
> Dojo here, of course..) and then see which parts we rally have to
> implement 'on the metal'. That will then form the necessary API for
> all SSJS platforms. Easy as cake, eh? :)
Before joining Mozilla this month, I was working at SitePen alongside
the Dojo folks and that gave me a good chance to experience Dojo
firsthand. Prior to that, I was the founder of the TurboGears project
in Python.
I really think that the needs of server side code are different enough
than the needs of client side code that we're better off drawing from
Python and Ruby than from Dojo and jQuery. That said, with solid
"medium level" (JDBC-style APIs, a decent File API, etc.) APIs as a
given, there will be all sorts of fertile ground for exploration of
the client/server boundary.
I do think there are server side implementations of most everything
we'd need already, but they are indeed isolated little islands and the
goal is to break off that isolation.
Kevin
I think there are a lot of people thinking along these lines. Tom
On Thu, Jan 29, 2009 at 11:12 AM, psvensson <psve...@gmail.com> wrote:
>
> Reading Kevin's article at http://www.blueskyonmars.com/2009/01/29/what-server-side-javascript-needs/
> I felt a shock of recognition. I've heard this once before, from
> Márion Valente (http://mv.asterisco.pt/) when we met a couple of
> months ago during the SAPO Codebits conference in Lisbon.
Robinson, from yesterday:
http://groups.google.com/group/jack-js/msg/02df426d23679623
"Even if the implementation depends on Java, we should try to
coordinate the user facing APIs."
I figured it's time to funnel all of that energy and thought into
*creating* the world we all want.
Before joining Mozilla this month, I was working at SitePen alongside
> In a recent mail discussion, I suggested that we try to list the areas
> that need to be implemented, see if they already _are_ implemented on
> a high level in some existing Ajax toolkit (I'm thinking very much
> Dojo here, of course..) and then see which parts we rally have to
> implement 'on the metal'. That will then form the necessary API for
> all SSJS platforms. Easy as cake, eh? :)
the Dojo folks and that gave me a good chance to experience Dojo
firsthand. Prior to that, I was the founder of the TurboGears project
in Python.
I really think that the needs of server side code are different enough
than the needs of client side code that we're better off drawing from
Python and Ruby than from Dojo and jQuery. That said, with solid
"medium level" (JDBC-style APIs, a decent File API, etc.) APIs as a
given, there will be all sorts of fertile ground for exploration of
the client/server boundary.
I do think there are server side implementations of most everything
we'd need already, but they are indeed isolated little islands and the
goal is to break off that isolation.
Kevin
Dion Almaer wrote:
> Good points Kris. I totally agree. I don't want to copy from the like
> of JDBC, but rather copy from what JavaScript frameworks are already
> doing (e.g. Perserve and others).
>
> There are a LOT of JavaScript libraries out there than do the same
> thing slightly differently (e.g. toml talking about 15 different
> "File" APIs). How about looking at what has been done and codifying
> it, NOT trying to set new ground such as Enterprise JavaScript Beans? :)
I agree, standardization and interoperability efforts can be at their
best when it converges and brings harmony to what existing
implementations are doing. And I assume not many SSJS impls are trying
to create Enterprise JavaScript Beans :). But there is probably a lot of
areas where there are opportunities for convergence in very beneficial ways.
Thanks,
Kris
I both agree and disagree.
> I would love to
> have Persevere be able to support a common API with SSJS envs, but I
> wouldn't want it to have to degrade to old request-response/HTML
> generation paradigms and JDBC style APIs.
IIRC, Persevere has a way to store its data in a relational database,
doesn't it? Am I correct in assuming that you use JDBC to talk to the
database, rather than offering your own drivers for each database
engine?
That is precisely my point... Something like JDBC or Python's DBAPI is
certainly lower level than one would ideally want to work these days.
However, JavaScript environments don't even have that low level
standard to build upon!
Ideally Persevere would work in Rhino and Spidermonkey equally well
without you having to change a line of code.
> As far as data interaction
> (which does seem completely orthogonal to the HTTP interaction to me), I
> think we have mostly evolved past JDBC interaction, so I would certainly
> be a supporter of some standardized ORM-style API.
A "standardized ORM" is a harder sale than a "standardized RDBMS
access layer". There are those who have more object-oriented engines
like Persevere, there's the Active Record pattern popularized by Rails
and there's the Data Mapper pattern used by SQLAlchemy and Hibernate.
Trying to get people to agree at that level of application
architecture may be a bit premature.
> Dojo has made efforts
> in that area (although it has greater expectation for async than would
> be needed in the server), and I have attempted to create an API in
> Persevere that could be used by other systems in
> http://docs.persvr.org/documentation/server-side-js (load, commit,
> rollback, remove, getAccessLevel, getId, isPersisted, authenticate,
> ...). Or perhaps you are simply interested in defining APIs for lower
> level servers (and I guess it would simply not apply for Persevere).
My personal hope (and I should note that I'm not in charge here...
just facilitating) is that we can start by providing better low level
infrastructure that allows for more high level experimentation. As
mentioned above, I see no reason why Persevere couldn't just be
launched on v8, if the libraries were there.
> Anyway, there is *a lot* (virtually limitless) areas out there that one
> could tackle, not sure how much of the world you are wanting to take on
> here, and what scope you had in mind here.
I gave some notion of my thoughts on scope in my blog post. I want to
see JS reach the state where it's on par (or better, because we avoid
some of the acknowledged mistakes) with Python and Ruby.
Start by providing better infrastructure for server side JS and then
seeing where we can collaboratively build up from there.
Kevin
Yes (and auxiliary tooling like a package repository, etc.)
> A standardized 'File' interface for working with files on disk.
> One for working with relational databases.
> Another for working with parsing XML.
>
> What if we tackled the problem backwards.
>
> Say it's 20 years in the future and you need to write some code that
> parses some XML from a file on the disk and then inserts entries into
> a relational database.
> What would be the PERFECT API you could envision to use.
> The simplest, cleanest, most straightforward JavaScript API to
> accomplish the tasks mentioned above.
Yes.
> I think it's really important to not be influenced too much by past
> efforts.
> As JavaScript programmers we have a lot of awesome flexibility in the
> language itself.
> Some truly great things we can do in terms of dynamic typing,
> closures, event oriented approaches, etc.
Agreed, but I also think it's worth taking the ideas that work well.
For example, WSGI has been very successful in Python land (in much the
same way that the Servlet spec has been successful for Java), as a way
to connect servers and applications. WSGI is lower level than people
would typically want to work. But that's okay... it's existence as a
low level spec has enabled all kinds of interoperable servers, apps
and middleware components that can be plugged in.
So, I agree that we want great APIs, but we want great APIs that allow
for experimentation on all kinds of other ideas that we're not going
to think of right now.
> I've been thinking about server side javascript for a few months now,
> even started some code myself with Spidermonkey and another project
> with V8 to try some things out.
Great! And this is one of the reasons that I set this group up. It
turns out that there are quite a few people out there building
independently who could all benefit from a bit of shared
infrastructure.
Kevin
In this particular case, JS has an unusual position in that it doesn't
really need a single blessed interpreter... there are several good
ones available and a spec they need to conform to. They're just really
missing a fleshed out stdlib and the ecosystem that comes along with
that.
JS is actually getting a lot of benefit from having competing interpreters.
Kevin
Kevin Dangoor wrote:
> On Thu, Jan 29, 2009 at 11:53 AM, Kris Zyp <kri...@gmail.com> wrote:
>
>> I am certainly a supporter of finding paths for interoperability. My
>> biggest concern here is that we would take a progressive idea like SSJS
>> and try to apply antiquated server-side API concepts.
>>
>
> I both agree and disagree.
>
>
>> I would love to
>> have Persevere be able to support a common API with SSJS envs, but I
>> wouldn't want it to have to degrade to old request-response/HTML
>> generation paradigms and JDBC style APIs.
>>
>
> IIRC, Persevere has a way to store its data in a relational database,
> doesn't it? Am I correct in assuming that you use JDBC to talk to the
> database, rather than offering your own drivers for each database
> engine?
>
> That is precisely my point... Something like JDBC or Python's DBAPI is
> certainly lower level than one would ideally want to work these days.
> However, JavaScript environments don't even have that low level
> standard to build upon!
>
> Ideally Persevere would work in Rhino and Spidermonkey equally well
> without you having to change a line of code.
>
That's fine, good to know exactly what you were looking for. However, in
Persevere, one of the benefits is that the code paths are so short
between querys/JS property accesses and database queries. Adding more
layers of abstractions always sounds like a nice idea, but it's naive to
think that you can maintain the same performance, and I wouldn't be
likely to run Persevere's object mapping system on top of JS DBAPI. This
partly due to performance but also because the leakiness of the ORM
abstraction when in implemented in JS vs at the VM level. However, I
would probably willing to implement a DBAPI on top of the ORM layer
though ;).
Kris
Why do you think one would need a compatibility lib? To access the
underlying API?
In my experience the actual implementations are amazingly compatible
when it comes to the language and it's edges.
I don't think that's needed even for "marketing" reasons. People will
get the one that best fits their needs (e.g. a Java one if they want
to integrate with Java, or the one that is easiest to install for
their platform) and failing that they'll get the one they find when
Googling. It's not a big issue in itself.
What we do need is interoperability between those multiple
implementations. For that I think we need three things:
- a clear specification of what constitutes CoreJS (or however we
call it). This can be like documentation but it might be worth making
it tighter than documentation usually is trading readability for
strictness;
- a thorough test suite;
- a well-defined extension mechanism to add third-party libraries.
The latter may seem superfluous for interoperability but it's not. If
there is no well-defined way of adding a library then vendors will be
very tempted to build extensions straight into their implementations.
And once that happens, you're going down the browser wars again.
> This does raise an interesting question. What's the best way to make a
> standard library that's
> usable across multiple JS engines? The way I see it, we have two
> options.
>
> 1) Create a single library then provide adapters for each of the JS
> engines.
> 2) Make an airtight spec, then implement the library for each JS
> engine
You need both. You write (2) and use feedback from (1) (preferably
multiple instances of 1) to interatively fix the spec until everyone
is happy.
> The big complication, of course is the fact that some JS interpreters
> are written in Java and
> some in C.
That's an issue if we want to integrate libraries from C (well, the
system) or Java (or various other languages). I don't think that's an
issue for the core standard (i.e. the *small* part that produces a
useful platform). But it's going to be an issue for extensions. I
think that people should be allowed to bridge to whatever other
language they want, and we need to deal with that. One way I think
this could work is by making it clear in the extensions packaging
(using some metadata) that an extension requires a given library and
of what type, or if it's pure JS. That way people would know which
extensions they can install on which implementation, and also a
package manager (I'm thinking something like cpan, pear, or gem) could
pick the right extension if there are multiple implementations of it.
--
Robin Berjon
Robineko (http://robineko.com/)
I know a fair bunch of people, myself included, who played a bit with
Python in its earlier days but didn't go farther because it didn't
have a package repository. When done right (like CPAN) it's a killer
feature.
> But I think that if its to be
> done, it should
> be done by Mozilla. There's already some basis for it (FF .xpi files
> and the extensions
> repository)
I think it should be done by whoever does it well enough first :) I
pinged the OpenJSAN folks to see if they might be interested.
mvalente wrote:
>
> On Jan 29, 4:53 pm, Kris Zyp <kris...@gmail.com> wrote:
>
>> I am certainly a supporter of finding paths for interoperability. My
>> biggest concern here is that we would take a progressive idea like SSJS
>> and try to apply antiquated server-side API concepts. I would love to
>> have Persevere be able to support a common API with SSJS envs,
>>
>>
>
> Yes, I think that this should be the goal. Not to define any old
> ideas
> or any high level stuff but just put enough in place that one could
> take
> the source to Persevere and run it on any one of the JS interpreters
> (C based, Rhino based, etc)
>
>
FWIW, I would envision Persevere probably being more on the side of an
implementor of the APIs than a consumer, but it would probably be on
both sides to some degree.
>
>
>> As far as data interaction
>> (which does seem completely orthogonal to the HTTP interaction to me), I
>> think we have mostly evolved past JDBC interaction, so I would certainly
>> be a supporter of some standardized ORM-style API.
>>
>
> I do not agree with this one. I think that any ORM-style interaction
> should
> be left for people to build with the JS basics. If some standardized
> way of
> doing data interaction is to be standardized upon then I would most
> definitely propose that it be a REST-based JSON-formatted way. Let
> the
> RDBMSs and ORMs and whatnot provide that sort of interface (either
> native or through a gateway/adapter)
>
I think you are right that it would be best for this group to avoid
tacking ORM standardization, or RDBMS standardization probably. It looks
like there are more than enough issues to tackle at the moment.
And in regards to ORM, unfortunately you can't create an ORM in JS that
is anywhere near the quality of what you can do at the JS VM level. The
whole point of an ORM is to provide a means for objects to be bound to
data, such that they actually look like objects. If you take the
conservative approach of avoiding getters and setters you can't even
close, anything that would take some interaction with a data store
requires an API. If you do you getters and setters you are better off,
but still have very leaky abstractions and poor performance (getters and
setters in most JS VMs are about 10-50x slower, whereas writing native
code can actually be faster). The high performance air-tight
abstractions are one of the key benefits of Persevere, this level of
quality simply could not be achieved as a JS library.
Kris
> - I dont think that an ORM should be our worry; our worry should be
> the ability of people to write an ORM using Javascript
Agreed!
Peter
I think the repository is very important. My guess is Perl would
likely have died by now without CPAN. When someone asks "why Perl?"
most of the time the answer is "CPAN". So it isn't the Perl language
that is so persuasively wonderful, it is the community around it.
> But I think that if its to be
> done, it should
> be done by Mozilla. There's already some basis for it (FF .xpi files
> and the extensions
> repository)
I think think that a brand name like Mozilla hosting a repository
would give JavaScript a big boost and would ease the minds of
developers wanting to use JavaScript more but looking for a canonical
community. The developer would feel as though he is using something
that is not just a one-person side project that might die and leave
him hanging.
Peter
Something interesting to consider here, though, is that while it may
seem like using a JS DBAPI would hamper performance, if you can move
JSPersevere from Rhino to Spidermonkey or v8 or jscore and then get
JITted JavaScript, the performance might actually improve. (Note: I
just made up "JSPersevere" because Persevere itself is written in
Java, not JavaScript, right? So, I'm just making up an example of a
JavaScript package that may previously have been using JDBC directly
but changes to using the JS DBAPI.)
Kevin
--
Kevin Dangoor
email: k...@blazingthings.com
blog: http://www.BlueSkyOnMars.com
That would be nice, but like I mentioned on another thread, really one
of the core benefits of Persevere is to provide true object-data
bindings, (with dynamic property mapping to storage and even type
checking) so that people can interact with data simply using JavaScript,
without any APIs needed. Persevere users can interact with objects and
data is loaded and saved as needed. This simply can't be done as a JS
library (short of having catch-all getters and setters, but that is a
long ways off).
It's also worth noting that even the king of JS performance, V8, with
all it's amazing JITing is still vastly slower than Java (about 4-5x on
some of my tests). The JVM has seen years of intense optimizations by
Sun. The fact that I can run the workhorse cycle-intensive low-level
operations in Java means that Persevere would still be vastly faster
than a pure JS solution running on the fastest JS engine. I love
front-to-back JS. Not sold on top-to-bottom JS :).
That being said, I would still be happy to see a standardized JS DBAPI
even if Persevere doesn't necessarily utilize it for it's object-data
bindings.
Kris
> Kevin
>
>
It's also worth noting that even though Rhino is really really slow,
probably as much as an order of magnitude slower than JavaScriptCore
or V8, it's still faster than Ruby. In fact, running Jack on Jetty is
faster than running Rack on Mongrel.
Raw speed, at the end of the day, doesn't have to be the primary
concern. Just look at how popular Ruby has already become as a server
language. So, I'm skeptic when I hear people say that JavaScript is
too slow to do X and a lower level API is needed. At the very least, I
think its important to start with the basics, and only once those have
been agreed upon, move to more complex things.