Using More Javascript Would Save Energy


Javascript is a very strange little language that has become very powerful. Building more classical client/server application based on a Javascript/PHP will provide a better user experience and better performance and those kind of applications will scale better and they need less server power.

I'm a PHP developer. I've been developing with PHP for probably 10 years. I love PHP because it's so simple and flexible yet very powerful. In those 10 years I've done some programming in Java, I've peeked into C/C++, I got in touch with Lisp and Prolog and I have also done quit some Javascript coding. I never liked Javascript.

JavaScript

Javascript has been around for years. I remember when back in the day it was considered to be a thread and when it was best practice to turn JavaScript off, because it was too dangerous. Those times are long gone.

Javascript to me seems like some freak programming language intransparent and just weird and unlogic. In Javascript objects are like arrays and functions are just like variables. There is multiple ways to define methods and objects. It's just confusing. Yes you can do some jQuery stuff, which is easy, but which is not really programming (hide elements, animate elements and so on). I would rather call that "High-end-CSS". What about those sofisticated applications built with JavaScript? Just look at JavaScript libraries (like jQuery). I don't even dare trying to understand what is going on.

Javascript applications actually have a state. You load that one page with the javascript and then you can do things. You can store objects, you can manipulate objects and you don't have to pay attention to the max page execution time. You can't rely on that redeeming page refresh that will clear everything. You actually need to carefully think what you do.

Javascript vs PHP trend

Using more Javascript would save lots of energy

Just recently I started writing a little web application (www.instalog.me). I started doing it very classical in PHP, because it's just so simple. It worked perfectly fine and it was actually fairly performant. It's only running on a cheap shared hosting. So I was thinking: "What will happen if that service would become popular?". The answer: "Caching and moving to a new bigger server."

Do I even need to use PHP? No. So I decided to build it again based on Javascript only. Taking a static HTML file and building all of the logic in Javascript. No PHP at all, as it's not needed. All of the computation will be done on the client. This will allow serving much more page requests. Looking at this globally. If people were using more Javascript running applications would need less server power and less bandwith, because you could be talking between client and server using JSON. Yes you would actually be talking about a client/server application (which in PHP only applications is not really the case). And less servers would also mean less electricity.

Is this realistic?

Maybe. But: PHP is just way too easy… Javascript just way too hard. With HTML 5 and CSS3 peaking around the corner and the mobile web becoming more and more attractive, this kind of application becomes more attractive. You have now even a local object store at your hands (way better than cookies!)! It takes though some software engineering skills to build this kind of application and you have to be an expert in Javascript! But then: You can save mother earth by saving electricity!

After all that kind of application will provide a better user experience, they are faster and they are cheaper to run, but it also takes some effort to develop.