<p>With the increased power of JavaScript frameworks like YUI, JQuery, and Prototype, and debugging tools like Firebug, doing an application entirely in browser-side JavaScript looks like a great way to make simple applications like puzzle games and specialized calculators.</p>

<p>Is there any downside to this other than exposing your source code?  How should you handle data storage for this kind of program?</p>

<p>Edit: yes, Gears and cookies can be used for local storage, but you can't easily get access to files and other objects the user already has around.  You also can't save data to a file for a user without having them invoke some browser feature like printing to PDF or saving page as a file.</p>

[{'answer_id': 15145, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://gears.google.com" rel="nofollow noreferrer">Gears</a> might provide the client-side persistent data storage you need. There isn\'t a terribly good way of not exposing your source code, though. You could obfuscate it but that only helps somewhat.</p>\n\n<p>I\'ve done simple apps like this for stuff like a <a href="http://hewgill.com/sudoku/" rel="nofollow noreferrer">Sudoku solver</a>.</p>\n'}, {'answer_id': 15155, 'author': 'mk.', 'author_id': 1797, 'author_profile': 'https://Stackoverflow.com/users/1797', 'pm_score': 2, 'selected': False, 'text': "<p>The downside to this would be that you are at the mercy of them having js enabled. I'm not sure that this is a big deal now. Virtually every browser supports js and has it enabled by default.</p>\n\n<p>Of course the other downside would be performance. You are again at the mercy of the client handling all the intensive work. This also may not be that big of a deal, and would be dependent on the type of app you are building. </p>\n\n<p>I've never used Gears, but it looks like it is worth a shot. The backup plan would be to run some server side script through ajax that dumps your data somewhere. </p>\n\n<p>Not completely client side, but oh well. </p>\n"}, {'answer_id': 15167, 'author': 'Sören Kuklau', 'author_id': 1600, 'author_profile': 'https://Stackoverflow.com/users/1600', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://www.sproutcore.com/" rel="noreferrer">SproutCore</a> is a wholly JavaScript-hosted application framework, borrowing concepts particularly from Cocoa (such as KVO) and Ruby on Rails (such as using a CLI generator for your models, views and controllers). It includes Prototype, but builds plenty of stuff such as sophisticated controls on top of that. Its <a href="http://www.sproutcore.com/static/photos/" rel="noreferrer">Photos</a> demo is arguably impressive (especially in Safari 3.1).</p>\n\n<p>Greg already pointed you to Gears; in addition, HTML 5 will come with a standardized means of local storage. Safari 3.1 ships with an implementation where you have a per-site SQLite database with user-settable size maximums, as well as a <a href="http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage/" rel="noreferrer">built-in database browser with SQL querying</a>. Unfortunately, it will be a long time until we can expect broad browser support. Until then, Gears is indeed an alternative (but not for Safari…\xa0<a href="http://code.google.com/p/gears/wiki/BuildingGearsForSafari" rel="noreferrer">yet!</a>). For simpler storage, there is of course always cookies.</p>\n'}, {'answer_id': 15172, 'author': 'Ryan Fox', 'author_id': 55, 'author_profile': 'https://Stackoverflow.com/users/55', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://blog.nihilogic.dk/" rel="nofollow noreferrer">Nihilogic</a> (not my site) does a lot of stuff with Javascript. They even have several <a href="http://blog.nihilogic.dk/search/label/games" rel="nofollow noreferrer">games</a> that they\'ve made in Javascript.</p>\n\n<p>I\'ve also seen a neat roguelike game made in Javascript. Unfortunately, I can\'t remember what it was called...</p>\n'}, {'answer_id': 15186, 'author': 'conmulligan', 'author_id': 1467, 'author_profile': 'https://Stackoverflow.com/users/1467', 'pm_score': 1, 'selected': False, 'text': "<p>You might run into performance issues given that you're completely at the mercy of the client's Javascript interpreter. Gears would be a nice way of data storage, but I don't think it has penetrated the market that much. You could just use cookies if you're not fussy about that kind of thing.</p>\n"}, {'answer_id': 15205, 'author': 'Kevin', 'author_id': 40, 'author_profile': 'https://Stackoverflow.com/users/40', 'pm_score': 1, 'selected': False, 'text': '<p>Standalone games in GWT:</p>\n\n<ol>\n<li><a href="http://gpokr.com/" rel="nofollow noreferrer">http://gpokr.com/</a></li>\n<li><a href="http://kdice.com/" rel="nofollow noreferrer">http://kdice.com/</a></li>\n</ol>\n'}, {'answer_id': 15234, 'author': 'Avner', 'author_id': 1476, 'author_profile': 'https://Stackoverflow.com/users/1476', 'pm_score': 5, 'selected': True, 'text': "<p>I've written several application in JS including a spreadsheet.</p>\n\n<p>Upside:</p>\n\n<ul>\n<li>great language</li>\n<li>short code-run-review cycle</li>\n<li>DOM manipulation is great for UI design</li>\n<li>clients on every computer (and phone)</li>\n</ul>\n\n<p>Downside:</p>\n\n<ul>\n<li>differences between browsers (especially IE)</li>\n<li>code base scalability (with no intrinsic support for namespaces and classes)</li>\n<li>no good debuggers (especially, again, for IE)</li>\n<li>performance (even though great progress has been made with FireFox and Safari)</li>\n<li>You need to write some server code as well.</li>\n</ul>\n\n<p>Bottom line: Go for it. I did.</p>\n"}, {'answer_id': 15264, 'author': 'ScottKoon', 'author_id': 1538, 'author_profile': 'https://Stackoverflow.com/users/1538', 'pm_score': 3, 'selected': False, 'text': '<p>Another option for developing simple desktop like applications or games in JavaScript is <a href="http://www.adobe.com/devnet/air/" rel="noreferrer">Adobe AIR</a>. You can build your app code in either HTML + JavaScript or using Flash/Flex or a combination of both. It has the advantage of being cross-platform (actually cross-platform, Linux, OS X, and Windows. Not just Windows and OS X).</p>\n\n<p>Heck, it may be the only time in your career as a developer that you can write a web page and ONLY target ONE browser.</p>\n'}, {'answer_id': 16552, 'author': 'Ryan Fox', 'author_id': 55, 'author_profile': 'https://Stackoverflow.com/users/55', 'pm_score': 0, 'selected': False, 'text': '<p>My RSS feeds have served me well- I found that Javascript roguelike!</p>\n\n<p>It\'s called <a href="http://www.icculus.org/asciiroth/" rel="nofollow noreferrer">The Tombs of Asciiroth</a>.</p>\n'}, {'answer_id': 40020, 'author': 'AndrewBurton', 'author_id': 4252, 'author_profile': 'https://Stackoverflow.com/users/4252', 'pm_score': 1, 'selected': False, 'text': "<p>I'm with ScottKoon here, Adobe AIR is great.  I've really only made one really nice (imho) widget thus far, but I did so using jQuery and Prototype.js, which floored in such wonderful ways because I didn't have to learn a whole new event model.  Adobe AIR is really sweet, the memory foot print isn't too bad, upgrading to a new version is built into AIR so it's almost automatic, and best of all it's cross-platform...they even have an alpha-version for Linux, but it works pretty well already on my Eee.</p>\n"}, {'answer_id': 78173, 'author': 'Brian Cully', 'author_id': 10085, 'author_profile': 'https://Stackoverflow.com/users/10085', 'pm_score': 0, 'selected': False, 'text': "<p>Given that you're going to be writing some server code anyway, it makes sense to keep storage on the server for a lot of domains (address books, poker scores, gui configuration, etc.,.) For anything the size of what you'll get in Webkit or Gears, you can probably also keep it on your server.</p>\n\n<p>The advantage of keeping it on your server is two-fold:</p>\n\n<ol>\n<li>You can integrate it fairly simply as a Model layer in a typical MVC framework, and,</li>\n<li>Users get a consistent view without being tied to their browser/PC, or in a less-than-ideal environment (Internet Cafés).</li>\n</ol>\n\n<p>The server code for handling this can also be fairly trivial, particularly if it's written with this task in mind, so it's not a huge cognitive burden.</p>\n"}, {'answer_id': 241845, 'author': 'pc1oad1etter', 'author_id': 525, 'author_profile': 'https://Stackoverflow.com/users/525', 'pm_score': 2, 'selected': False, 'text': '<p>If you want to write a standalone JavaScript application, look at <a href="https://developer.mozilla.org/en/XULRunner" rel="nofollow noreferrer">XULrunner</a>.  It\'s what Firefox is built on, but it is also built so that you can distribute it as an application runtime.  You will write some of the interface in JavaScript and use JavaScript for your code.</p>\n'}, {'answer_id': 1774562, 'author': 'Doug Neiner', 'author_id': 152083, 'author_profile': 'https://Stackoverflow.com/users/152083', 'pm_score': 1, 'selected': False, 'text': '<p><em>In regard to saving files from a javascript application:</em></p>\n\n<p>I am really excited about the possibilities of client-side applications. Flash 10 introduced the ability to create files for save right in the browser. I thought it was super cool, so I built a javascript+flash component to wrap the saving feature. Right now it only works for creating text based files (vcard, ical, xml, html, css, etc.)</p>\n\n<ol>\n<li><a href="http://downloadify.info" rel="nofollow noreferrer"><strong>Downloadify Home Page</strong></a></li>\n<li><a href="http://github.com/dcneiner/Downloadify" rel="nofollow noreferrer"><strong>Source Code &amp; Documentation on Github</strong></a> </li>\n<li><a href="http://starter.pixelgraphics.us" rel="nofollow noreferrer"><strong>See It In Use at Starter for jQuery</strong></a></li>\n</ol>\n\n<p>I am looking to add support for non-text files soon, but this is a start. </p>\n'}, {'answer_id': 2409593, 'author': 'Me myself and I', 'author_id': 289719, 'author_profile': 'https://Stackoverflow.com/users/289719', 'pm_score': 0, 'selected': False, 'text': "<p>Go with qooxdoo. They recently realsed 1.0, although most users of it say it was ripe for 1.0 at least two versions ago.</p>\n\n<p>I compared qooxdoo with YUI and ext, and I think qooxdoo is the way to go for programmers - YUI isn't that polished as qooxdoo, from a programmer's point of view and ext has a not so friendly licensing model.</p>\n\n<p>A few of the strong points (for me) of qooxdoo are:</p>\n\n<ul>\n<li>extremely clean code</li>\n<li>the nicest OO programming model I've seen among Javascript frameworks</li>\n<li>an extremely rich UI widget library</li>\n</ul>\n\n<p>It also features a test runner for unit tests, an API doc generator and reader, a logging facility, and several useful features for debugging, grouped under something called Inspector.</p>\n\n<p>The only downside is that there aren't readymade themes (something like skins) for qooxdoo. But creating your own theme is quite easy.</p>\n"}]
['https://Stackoverflow.com/questions/15139', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1323/']