GNOME debates Javascript bindings
Which Javascript binding should the GNOME desktop support? This is a question that the GNOME desktop-devel was debating last week. Since GNOME-Shell, the foundation of next year's GNOME 3.0, is built on Javascript, the answer is a major policy decision. However, the difficulties of making the decision are compounded because the contenders, Seed and Gjs, are both in rapid development and their final form is difficult to predict. However, that does not stop the push for a decision from the Seed community.
Both Seed and Gjs are GNOME projects. They are interpreters that allow users to write code in Javascript and have the core GNOME code use it. One of the major differences between them is the flavor of Javascript that they use, with Seed designed to work with WebKit, a Javascript engine favored by Apple and KDE, and Gjs with SpiderMonkey,a Javascript engine designed for Mozilla's applications. Since GNOME-Shell is written in Javascript (currently with Gjs) the choice of engines is a decision with far-reaching consequences. Also at stake is the prospect of tying future GNOME development to a particular dialect of Javascript whose development and adoption is still uncertain.
What makes the decision particularly hard is that, with Seed at release 0.7 and Gjs at 0.2, both are likely to change considerably before their final releases, so judging the suitability of one over the other is next to impossible. All the same, an effort at objective comparison was written by Owen Taylor, the GNOME-Shell maintainer.
Taylor notes that only Gjs currently supports "let" statements, which create variables scoped to the local block, and "const," which is used to declare a constant variable. He also refers to the fact that switching to Seed would currently mean a loss of destructuring assignment, a more flexible, multiple-assignment syntax. But he is largely unconcerned about these losses, viewing them as only temporary. He is more concerned about the choice of the widely used SpiderMonkey as opposed to the more untried JavascriptCore module behind WebKit, although he notes that Epiphany, the default GNOME browser, and Yelp, the GNOME help system, already use WebKit. Without giving particulars, Taylor also characterizes Gjs as having a limited set of well-implemented features, as opposed to Seed, which has more features. In fact, Gjs seems to exist largely to serve the needs of GNOME-Shell as they arise, while Seed is more active and independent project.
At this stage, he is not concerned with the speed of either, reasoning that it will change in coming months, but he does express concern at garbage collection — the reclamation of memory by the removal of unused objects — arguing that both SpiderMonkey's and WebKit's garbage collection is more geared to web pages than desktops. In the end, Taylor seems to be relatively indifferent to which one is used by GNOME so long as it has the tools that GNOME-Shell will require. In other words, the choice is too uncertain for even those most closely affected to have strong opinions on it.
The most that Taylor can provide is a general criterion for making a
choice: "Javascript standardization is highly politicized and affected
by concerns like what Microsoft can implement in IE and in general by
considerations of cross-browser compatibility,
" Taylor
wrote. "We should use whatever dialect of Javascript is supported by
our engine that makes our life better.
"
The push for a choice
Nobody involved with Gjs has been active in this discussion, while those
involved with Seed have
been raising the possibility of choosing one over the other for six
months. Last November, Frederick Peters, in the GNOME Commit-Digest, summarized
some differences between Seed and Gjs as described by Robert Carr, Seed's
maintainer. According to Peters, Carr suggested that, for the time being,
"it's best for both projects to continue development at this
point.
"
By January, as plans for GNOME 2.26's March release were being finalized, Carr was ready to propose that GNOME standardize on Seed. The proposal sparked a discussion about the relative merits of Seed and Gjs as they existed then. But the majority opinion was that it was still too early to make a choice, and the proposal was not accepted.
Four releases of Seed later, with plans being discussed for the release of
GNOME 2.28 , the intended beta for GNOME 3.0 that is due for release in
November, Carr renewed
his proposal in May. He pointed out that Seed would require no new external
dependencies, since WebKit/GTK+ and GObject
Introspection, with which it interacts, are already scheduled to be
included in the upcoming release. Furthermore, Seed already uses standard
parts of GNOME, such as gnome-git and Bugzilla. Carr also cited the
flexibility of using Seed, arguing that "at this point, most Gjs code
could be prettily easily ported to Seed
" while porting the other way "might
be a bit more difficult
" and suggesting that "it would be
possible to port GNOME-Shell to Seed with no more than a few days'
work.
" Similarly, he suggested that writing an extension to support
Seed would be "around a day's work
" for most applications. In
passing, he also raised the possibility of a common module for both Gjs and
Seed, which would preserve flexibility.
In response to a direct question
from Hubert Figuiere about "what makes Seed more suitable than
Gjs?
" Carr admitted
that, "For 2.28,
it may make sense to have both Gjs and Seed as modules, and try and keep
code somewhat compatible. It's still not entirely clear which Javascript
engine is going to end up being better long term, so we might not want to
completely commit to one yet.
"
Still, Carr favored Seed for a number of technical reasons. He argued that Seed's use of WebKit and GObject was more in keeping with existing tendencies in GNOME, and the Seed C API is far more intuitive than the SpiderMonkey API used by Gjs. Moreover, he described Seed as having more example code and documentation, which would make it easier to use.
What would happen to Gjs if Carr's proposal is accepted is uncertain. However, with Seed officially endorsed, Gjs would undoubtedly become a side line within GNOME if it continued at all. So far as most developers are concerned, it would probably survive largely in the code that Seed borrowed from it.
The discussion
The initial response to Carr's proposal was that having two Javascript
engines was unnecessary. However, most people on the mailing list gradually
seemed to agree with Vincent Untz, who argued
that "we need both engines and we need them in our platform sooner
rather than later,
" on the grounds that which one was preferable was
still uncertain.
After a few remarks, the discussion turned to a question of whether
GNOME-Shell's developers were prepared to use Seed, and what effort that
decision would require. Carr replied
that he was prepared to write a patch that would allow Gnome-Shell to use
Seed. Others, though, such as Xan Lopez suggested
that he was underestimating the size of the task. "Do you have any idea of how
big a task adding 'let' [statements] support to JSC [Javascript Core] would
be?
" Lopez asked, referring to a one of Seed's greatest lacks, and
implying that the task would be a big one. To this question, Carr replied
that he was looking into the issue, and would report back when he had more
information.
After discussing the idea of adding let statements to Javascript with the
JSC project, Xan Lopez disagreed
with Taylor on the grounds that the upstream JSC team was opposed to
non-standard extensions. Instead, he urged that GNOME should "just stick to
a [Javascript] defined in some standard widely used for all GNOME code, in
order to avoid future headaches.
"
Carr offered to alleviate concerns by maintaining a Seed version of GNOME-Shell separately from the main branch for the next two releases. But, at this point, the unspoken consensus seems to have been that a decision could not be made.
Instead, talk turned to how to implement a common module for both Seed and
Gjs. In a long post, Havoc Pennington strongly advocated
this position. Pennington's "practical path
" was to have both
engines use the same modules and test suite, and to add support for let
statements. As he saw it, the common module would also need to support
disabling features that one or the other didn't support. This path was
extra work, Pennington acknowledged, but he thought that the common module
"could be the right decision even if GNOME includes only one of the
runtimes, just to get more people hacking on the suite of [Javascript]
modules.
"
For now, then, GNOME seems to have chosen to develop both modules together as much as possible, and to delay a final decision yet again. This approach may seem untidy and unsatisfying to many, but, it is hard to see what other decision could be made. Both the engines and Javascript itself are too unsettled for a clear choice to be made. Moreover, the undoubted pressure to advance GNOME 3.0 means that the time to make such decisions is minimal. By compromising, GNOME has allowed itself to progress while keeping as much flexibility as possible.
Index entries for this article | |
---|---|
GuestArticles | Byfield, Bruce |
Posted May 21, 2009 3:31 UTC (Thu)
by elanthis (guest, #6227)
[Link] (11 responses)
Why in $DEITY's name are they not using something like Lua, which has almost an identical feature set without the crazy 50 different implementations and non-standardized extensions on top of non-standardized bugs on top of an largely unimplemented standard?
I like JavaScript, but until a real standard (and implementations) come out that include the kinds of features necessary for large application development (e.g., the mentioned let keyword, among a few others), using it for desktop apps makes about as much sense as integrating Python 1.x as the scripting language of choice. Sure, it works, but it's crufty and the world has more to offer these days.
Posted May 21, 2009 10:40 UTC (Thu)
by nix (subscriber, #2304)
[Link] (5 responses)
lua's also got an excellently designed embedding API and FFI from Lua to the embedding host that makes JSC look baroque and SpiderMonkey look horrendous: in fact it's the first embedding API I've seen in years that I'd call pleasant to use. It was designed for embedding, and it shows.
Its only real problem is that some of its more recent features (e.g. modules) are only really documented in a dead-tree book (there's a publically-viewable reference manual, and a user guide for the previous version of lua, but a lot of Lua's power lies in nifty ways of using things, and *that* is only in the dead-tree book so far). Even here it beats JS, though, as all you have with JS is the standard, which is appallingly unreadable even by standards' standards, while the publically-available docs for lua are very well-written (as is the dead-tree book: recommended).
Posted May 21, 2009 12:19 UTC (Thu)
by knobunc (subscriber, #4678)
[Link] (1 responses)
Posted May 21, 2009 13:40 UTC (Thu)
by djerius (subscriber, #4489)
[Link]
ISBN 85-903798-2-5
Posted May 21, 2009 19:31 UTC (Thu)
by atai (subscriber, #10977)
[Link]
Posted May 28, 2009 3:05 UTC (Thu)
by deunan_knute (guest, #290)
[Link] (1 responses)
I won't argue Lua's inherent fitness for embedding, but what makes you think Lua has a greater userbase than JavaScript? A quick search for 'javascript programming' at amazon yields 2498 book results, whereas a search for 'lua programming' returns 138. the same search terms on google return 36,200,000 for javascript, 266,000 for lua.
Posted May 28, 2009 6:49 UTC (Thu)
by nix (subscriber, #2304)
[Link]
Posted May 21, 2009 10:51 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link] (3 responses)
I don't think (I am not involved in the larger debate, I just read the article) anyone is proposing to use Javascript to _write_ large applications. Adding a few hundred lines of JS here and a few hundred there as glue is quite different from implementing say Evolution or some other large app in JS.
Javascript is well suited as glue, and I don't think any amount of work on it will make it into an excellent application development language. If that's what GNOME is really proposing, well, it won't be the first time they (or KDE) have had a crazy idea I didn't agree with. Lua would also be a good candidate for writing glue, but I don't think it's much better than JS. Javascript has a major benefit of being very widely understood, this has the effect that even if it's technically not the ideal choice it may be a pragmatic choice because you don't have the option of waiting for a crop of expert Lua programmers to volunteer to work on GNOME.
Posted May 21, 2009 15:31 UTC (Thu)
by gerv (guest, #3376)
[Link] (2 responses)
I don't think (I am not involved in the larger debate, I just read the article) anyone is proposing to use Javascript to _write_ large applications.
<cough> Firefox <cough> (or large chunks of it, anyway)
Posted May 21, 2009 18:47 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link] (1 responses)
I recall (I am an old codger) fairly well the work to implement PAC in Mozilla, and basically 95% of the heavy lifting was C++ hacking, and then it needed some glue to connect it up and handle prefs and so on, and that was in Javascript.
And to get to the point where Javascript plays this role, Mozilla had to create XPCOM. So Javascript without XPCOM would be even less suited to writing a whole application.
Posted May 21, 2009 20:27 UTC (Thu)
by gerv (guest, #3376)
[Link]
gerv@otter:mozilla$ find . -name "*.cpp" -exec cat {} \; | wc -l
Seems to be about 65:35 at the moment. Hardly just "the glue".
Posted May 28, 2009 9:20 UTC (Thu)
by tdz (subscriber, #58733)
[Link]
The fact that there are several independent implementations of JavaScript was one of the reasons I choose it in the first place. So that if one implementation is ever becoming obsolete, I could switch easily; or at least without rewriting all scripts in another language.
As someone else wrote, SpiderMonkey's API is really no beauty. But it is well documented and a lot of people know JavaScript. So getting JS-related knowledge from experienced programmers isn't that hard.
Lua failed in these regards. When I was looking for scripting language, it was on the table but I dismissed it because of the small documentation (compared to JS) and the missing "backup implementation".
Best regards, Thomas
Posted May 21, 2009 4:21 UTC (Thu)
by dlang (guest, #313)
[Link] (5 responses)
with all the browsers having speed wars about their next generation javascript engine, one (or more) of those would be better than something developed for GNOME.
and if javascript is a defined language, it should not matter (as anything other than short-term bugs for missing features) WHICH engine is in use. the code should be portable enough to run across all of them.
the LAST thing that should happen is to end up with app#1 written in javscript for engine A, app#2 written in javascrpt for engine B, etc.
Posted May 21, 2009 7:13 UTC (Thu)
by jdub (guest, #27)
[Link] (4 responses)
The bits that GNOME developers are creating are the bindings between those engines and the GNOME platform, so you can actually create GNOME software with Javascript.
Posted May 21, 2009 12:39 UTC (Thu)
by dlang (guest, #313)
[Link] (3 responses)
Posted May 21, 2009 14:54 UTC (Thu)
by nybble41 (subscriber, #55106)
[Link] (2 responses)
Posted May 21, 2009 15:28 UTC (Thu)
by jdub (guest, #27)
[Link] (1 responses)
Here's an illustrative challenge for you: How do you write to stdout in Javascript, and if you can answer that, is your method a feature of the langauge or the runtime?
Posted May 21, 2009 15:29 UTC (Thu)
by jdub (guest, #27)
[Link]
Posted May 21, 2009 8:16 UTC (Thu)
by MisterIO (guest, #36192)
[Link] (6 responses)
Posted May 21, 2009 8:38 UTC (Thu)
by smurf (subscriber, #17840)
[Link] (4 responses)
Posted May 21, 2009 10:39 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link] (3 responses)
In theory this is fixed in a new enough Python. If you have a new enough Python, and if your Python programs were updated to take advantage. So mostly, not yet.
It was also way too easy to spot Python programs written at Red Hat to replace older C admin tools. The C admin tool might react to unexpected contents of a configuration file by segfaulting, but more likely it would ignore the unexpected element altogether. Ignoring unexpected things in C is really easy, it's often the default outcome. In Python you'd get a stacktrace, but of course only /after/ the program had truncated your file ready to write its output. The practical result was that the tools were now much less reliable, such tools ate my NTP configuration, printer settings and other useful stuff. Nice.
Posted May 21, 2009 13:43 UTC (Thu)
by zooko (guest, #2589)
[Link] (2 responses)
As to threading issues you mention, I take your word for it that you've observed such, but I haven't observed such problems in Python applications, although I have in C and Java applications on my Linux box. A good GUI application (in any language) should use event-based concurrency and incur lower risk of either of those two problems. Again, this probably has a lot more to do with the knowledge and choices of the authors than with the programming language.
Posted May 21, 2009 18:03 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link]
I actually think that Red Hat's decision to have this code in a higher level language was a good idea, and if I have something against Python, it's no more than I do against Ruby, Perl, or a dozen other choices. Familiarity breeds contempt, I think they say. If there'd been a thread about how all of GNOME should be written in C this grumpy old man would probably have criticised that viewpoint too.
As to event-based concurrency. It's a nice idea (though you lose the potential perf gain on modern hardware from simultaneous multiple threads of execution) but it's not always sufficient from a practical point of view. Suppose you do a name resolution (DNS lookup). If you're lucky your language / runtime/ stock library contains an asynchronous resolve function, and you need merely design the program around not being able to do synchronous lookups. If you're not lucky, you have to write this yourself (good luck, it's really nasty). So maybe you decide not to bother, and then the poor user whose DNS server is down wonders why your program freezes.
Posted Jun 3, 2009 10:29 UTC (Wed)
by renox (guest, #23785)
[Link]
I disagree: the most responsive applications/OS, I've ever used was BeOS which used threads (and this was on a monoCPU).
Posted May 28, 2009 16:29 UTC (Thu)
by sciurus (guest, #58832)
[Link]
Posted May 24, 2009 3:41 UTC (Sun)
by kov (subscriber, #7423)
[Link] (2 responses)
Posted May 25, 2009 13:57 UTC (Mon)
by samlh (subscriber, #56788)
[Link] (1 responses)
Posted May 25, 2009 17:29 UTC (Mon)
by kov (subscriber, #7423)
[Link]
GNOME debates Javascript bindings
GNOME debates Javascript bindings
GNOME debates Javascript bindings
GNOME debates Javascript bindings
Roberto Ierusalimschy
Lua and Javascript alternative: Squirrel
GNOME debates Javascript bindings
> to use it (to some degree) than JavaScript, thanks to Lua's use in major
> game platforms like WoW.
GNOME debates Javascript bindings
GNOME debates Javascript bindings
GNOME debates Javascript bindings
GNOME debates Javascript bindings
GNOME debates Javascript bindings
2211031
gerv@otter:mozilla$ find . -name "*.js" -exec cat {} \; | wc -l
1065187
gerv@otter:mozilla$
GNOME debates Javascript bindings
why should they pick a javascript engine?
why should they pick a javascript engine?
why should they pick a javascript engine?
why should they pick a javascript engine?
why should they pick a javascript engine?
why should they pick a javascript engine?
GNOME debates Javascript bindings
Why not Python?
Nobody notices?
Nobody notices?
Nobody notices?
Nobody notices?
And multicore CPU are now commons, so you'll loose performance with events.
Based on this this and this, it sounds like the direction GNOME is heading is "C/C++ core plus embeddable language". Python isn't a good embeddable language from their perspective because it comes with its own expansive set of libraries, whereas they want the embedded language to use GNOME libraries through GObject Introspection. Javascript, Guile, Lua, and Tcl are all mentioned as potentially good embeddable languages.
GNOME debates Javascript bindings
Saying that JavaScriptCore is 'untried' sounds weird to me. It's been a public "system framework"
on Mac OSX for a very long time now, and it's what both Epiphany/Webkit, Safari and even Chrome
use under the hood, so I wouldn't say it's untried.
GNOME debates Javascript bindings
GNOME debates Javascript bindings
GNOME debates Javascript bindings
the JavaScript infrastructure provided by JSC, but I indeed do not know to which extent the Chrome
guys replaced that infrastructure. But even if we consider Safari/MacOSX only, my point stands.