News for hackers. Stuff that matters.

Ask HN: Javascript for desktop apps?

I've been wanting to learn Javascript lately, and I've become curious as to how Javascript/ECMAscript fares as a language for writing software to be ran on the desktop. Are there any ECMAscript implementations with good FFIs? Are the good libraries/bindings for writing GUI desktop apps in ECMAscript? Is it possible to get acceptable performance(comparable to Python or at least Ruby, perhaps?) from ECMAscript?

If you were writing a desktop app in ECMAscript, which implementation would you use? Would you actually consider using ECMAscript to write a desktop app?

Are there any good books or other resources you would recommend on writing desktop apps in ECMAscript?

( 24 comments | 13 points | on HN )
Re:Ask HN: Javascript for desktop apps? by jacquesm on Monday July 27, 2009 @05:26AM (#725621)
why not simply embed a web server and connect to the localhost ? That makes your application internet ready as well when the time is right as well as giving the user to connect to your application from other pcs on the same lan.

I've built a music management system along these lines and it works quite well. The internet ready part of it causes all kinds of unintended but useful side effects, stuff that I never thought of when building it.

Re:Ask HN: Javascript for desktop apps? by Tichy on Monday July 27, 2009 @06:21AM (#725652)
Not sure why you were downvoted. I don't think the idea so "out there". Apps embed their own sql servers, too, why not a web server.

I think it would be nice to have a launcher that launches both the client and the server then.

Re:Ask HN: Javascript for desktop apps? by mdg on Monday July 27, 2009 @08:31AM (#725736)
If you were referring to Firefox / sqlite3.. I wouldnt consider sqlite3 a server at all. Nonetheless, I agree with what you are saying
Re:Ask HN: Javascript for desktop apps? by Tichy on Monday July 27, 2009 @08:47AM (#725750)
Strictly speaking it's not a server, true.
Re:Ask HN: Javascript for desktop apps? by mdg on Monday July 27, 2009 @11:52AM (#726048)
sorry if i was being nitpicky
Re:Ask HN: Javascript for desktop apps? by hymanroth on Monday July 27, 2009 @06:43AM (#725663)
This is an excellent approach, and in my view will be common in the future. It can also elegantly solve the problem of offline access, with the local web server syncing with the remote server in the background.
Re:Ask HN: Javascript for desktop apps? by bdfh42 on Monday July 27, 2009 @05:14AM (#725615)
On the windows desktop platform you can use JScript and the .NET Framework to write just about any desktop application you can imagine.

This language (which is a good implementation of up-to-date ECMAScript) is somewhat light on texts however. There is a SAMS book by Justin Rogers which does cover the basics.

You might be better off looking at something like Adobe AIR which is an excellent approach to making a web style application run like a desktop application - well worth exploring and could be a good platform for developing portable (and applicable) JavaScript skills.

Re:Ask HN: Javascript for desktop apps? by roam on Monday July 27, 2009 @05:39AM (#725627)
Yep, I'd suggest giving Adobe Air a spin. With some plain HTML, CSS and JavaScript you can create a decent (enough) cross-platform application. If you need an idea to get started, have a look at http://github.com/roam/morse/tree/master.
Re:Ask HN: Javascript for desktop apps? by dantheman on Monday July 27, 2009 @05:42AM (#725630)
Actionscript 3 is very close to javascript. The Adobe Air framework allows you to deploy desktop apps.

Depending on what you're trying to do you might want to try XUL Runner https://developer.mozilla.org/en/XULRunner . It will allow you build an html/js app that can run as a desktop app.

Re:Ask HN: Javascript for desktop apps? by compay on Monday July 27, 2009 @08:26AM (#725730)
I love Javascript, but I think people who want to develop server-side or desktop apps with it might be better served by Lua. Lua has functions as first-class values like Javascript does, which allows you to approach problems similarly in both languages.

Lua has also already been in use as a server-side and desktop language for some time, and while the available toolkits pale in comparison to what's available, say, for Java, Python or Ruby, there are still more options than there are for Javascript right now. Lua is very fast; for most benchmarks at http://shootout.alioth.debian.org it's the fastest interpreted language.

Sorry this is doesn't exactly answer the question you're asking but I thought it might be worth mentioning as another possibility to consider.

Re:Ask HN: Javascript for desktop apps? by geuis on Monday July 27, 2009 @07:35AM (#725688)
Check out the Titanium Developer platform. It's exactly what you want. http://www.appcelerator.com
Re:Ask HN: Javascript for desktop apps? by scscsc on Monday July 27, 2009 @06:02AM (#725639)
You could try Rhino:

https://developer.mozilla.org/en/Rhino_documentation

Steve Yegge suggests it's the next big language.

Re:Ask HN: Javascript for desktop apps? by mcculley on Monday July 27, 2009 @09:33AM (#725797)
This is very convenient now that Java (as of 1.6) has JavaScript/Rhino built in as an implementation of the Scripting API: http://snipplr.com/view/17501/javascript-swing-application/

Execution is as simple as 'jrunscript app.js'.

Re:Ask HN: Javascript for desktop apps? by makmanalp on Monday July 27, 2009 @06:21AM (#725651)
The KDE desktop shell, Plasma, has js bindings so you can develop plasmoids (applets) with javascript.

http://techbase.kde.org/Development/Tutorials/Plasma/JavaScr...

Re:Ask HN: Javascript for desktop apps? by makmanalp on Monday July 27, 2009 @06:33AM (#725657)
Sorry, forgot: This stuff is quite new so you might find some stuff missing from the bindings, but it's growing speedily. For the curious, it uses QScript.
Re:Ask HN: Javascript for desktop apps? by davidw on Monday July 27, 2009 @06:02AM (#725638)
Performance wise, consider that people have been using scripting languages since the 90'ies (Tcl/Tk) with perfectly acceptable results, so that's not really your problem. The issue is going to be finding how to do a GUI.
Re:Ask HN: Javascript for desktop apps? by wingo on Monday July 27, 2009 @06:04AM (#725640)
http://live.gnome.org/GnomeShell

Written mostly in javascript, with dynamically-generated bindings to GTK+ et al.

Re:Ask HN: Javascript for desktop apps? by Tichy on Monday July 27, 2009 @08:08AM (#725715)
Interesting, though ultimately I would prefer to spend resources on cross platform stuff.
Re:Ask HN: Javascript for desktop apps? by wingo on Monday July 27, 2009 @11:05AM (#725960)
You might not want to hack on that project, but in all cases you have to install a runtime, be it a web server or xulrunner or whatever.

GTK+ can be a pita to install, but it's as cross-platform as anything else.

Re:Ask HN: Javascript for desktop apps? by Tichy on Monday July 27, 2009 @11:11AM (#725974)
Then I misunderstood, I thought it was a Gnome only project. GTK would be OK.
Re:Ask HN: Javascript for desktop apps? by limmeau on Monday July 27, 2009 @08:05AM (#725713)
You could use XUL for the GUI. The German car rental company Sixt did that in 2005 for their corporate apps. I don't know what became of it, though.
Re:Ask HN: Javascript for desktop apps? by anc2020 on Monday July 27, 2009 @07:56AM (#725703)
Adobe Air is a possibility
Re:Ask HN: Javascript for desktop apps? by abyssknight on Monday July 27, 2009 @09:25AM (#725787)
Not just a possibility, its an emerging method of taking the web technologies to the desktop. You can mix AS3 and HTML/JS for a very clean, and fast implementation of typical desktop UI features. Honestly, AIR is perhaps the easiest way to package these sorts of things.
Re:Ask HN: Javascript for desktop apps? by polos on Monday July 27, 2009 @08:38AM (#725744)
You could use the LGPL Qt4.5 (cross-platform), which includes an ECMAScript scripting engine (with debugger).