JavaScript Web Applications – Reasons to Avoid Client-Side Only Webapps

client-sidejavascriptweb-applications

I recently started writing a path-finding algorithm simulation application in python.

It takes user inputs, randomly generates a 2d graph, and shows displays the simulation via GUI.

Now, what I found was that Python, and stand-alone applications aren't very appropriate for sharing this kind of application, as you need to get people to run it on their own computer etc. It would be much more convienient to simply direct them to a website.

Obviously the display and control elements need to be written on the client side.

But the actual path finding algorithm could be written on either the client or server side.

Now, given that there's no need for a server side backend (ie. no database), it would be possible to do the entire webapp in client side HTML/JavaScript.

The question is, is there a good reason not to do this?

The way I see it, doing it client-side only would greatly reduce the complexity, because there's no need to handle on going interaction between the client and the server. The only thing the server is for, is to initially serve up the Javascript to the client.

On the other hand… I'd have to write the entire thing in Javascript…

Also, the idea of having a reusable model module appeals to me. Eg. If I want to later have a standalone application, I'd just need to write the View/Control modules.

I'm wondering what generally the accepted practise would be here.

Best Answer

You've outlined the pros of doing the app client side only. Here are some possible cons - if any or all of them apply, consider shifting to a server based solution:

  • Performance. Would a client based solution be noticeably slower than a server-based one (including traffic)? Javascript is fast nowadays, but a computationally expensive algorithm might require dedicated server-side hardware or HPC farms.
  • Productivity. If you're a Python dev with no JS background, the time required to learn a new language and its idioms might be prohibitive, or at least longer than implementing client/server logic. Additionally, there may be useful Python libraries you could use which are unavailable for JS, which would increase development time considerably.
  • Intellectual Property. If this algorithm is something you wish to protect, having the code available on client machines could be a problem.
  • Compatibility. More browser-based code means more browser compatibility issues. This is much easier these days, but could still be a concern, depending on your intended audience and reach.

In short, client-side Javascript is a perfectly viable platform for algorithmic computing, and can easily be deployed both to a browser and as a standalone app (using a browser engine like Awesomium), but it does have its caveats. Go over them to make an informed choice.