Why I choose Javascript

This is my first attempt at blogging, so I thought about starting with a topic that’s been in my head these days. Please excuse my English, it’s not my native language, but I’ll do my best.

Why do I choose to program in Javascript? Well, there are many reasons but before I go there, I’d like to tell you a bit about my experience as a programmer:

I taught myself how to program and always enjoyed interpreted languages, part to the fact that I could go easily from an idea, to a running app quickly, and also because I like to ‘see’ the program as it evolves, running it quickly each time as I add more code. I also like them because you usually don’t need to worry about memory pointers or other low-level stuff that I couldn’t care less. I just wanted to make a program that does some stuff, and make it quickly so I can use it and play with it.

Back in the Amiga days, before I knew how to program anything, I got myself a copy of AMOS, from an Amiga magazine, and I was so excited. AMOS was a BASIC-dialect language written by François Lionet, with built in extensions for programming games, so everything was figured out for you already. You could just paint an animated sprite in DPaint, pull it from AMOS, and tell it to move. That’s it. No fuss, nothing to worry about. Everything was easy and soon I was able to create games that were fun and playable (remember I didn’t knew any programming before this).

Soon after learning the basics of programming by making a few games, I stumbled upon ARexx. ARexx was a scripting macro-like language, based on REXX which was created by IBM. The cool thing about ARexx, is that it was adopted as the native Amiga macro language, and most of Amiga applications exposed an ARexx API so they can communicate with each other. That was so incredible and useful, I’m surprised there isn’t anything similar right now anywhere. Apps could talk to each other using ARexx, and users could easily program ARexx scripts to automate stuff in those apps. Besides this fantastic thing, ARexx had its own libraries to do all sorts of stuff and someone could program entire applications with it.

I was stuck with ARexx since then, programming stuff from web servers, to text adventures and anything I could think of. Up until Amiga died and I was out of the computer land for a long period of time. After returning from the military (it’s still mandatory in Greece), I bought a PC (yes, it sucks, I know…), and somehow got into programming again. This time it was Euphoria (why did I choose those strange languages?). Anyway, Euphoria is also an interpreted language, but it can compile to exe also. It is fast, has a nice documentation, and is easy to learn. It has a community that contributes all kind of stuff to the Archive so I was able to pick up stuff from there and look at the code. I learned it fast and made a few little apps, tried to make a game but I soon got bored and looked elsewhere.

Then came the Web! Oh, so much fun! Programs that are ‘social’, they run online, and the tutorials and examples you can find are millions, because everybody uses it. No need to tell you I finally found what I really wanted to do. Programming on the Web. I had done some HTML in the past but didn’t pay much attention as it isn’t really a language, rather more like a document format. But combining CSS, Javascript and Php, magic happened. Everything became dynamic (rather than static .html files), people could interact, things could move, it is a giant playground for programmers. Plus you can make a living out of it.

So I went on learning all those neat stuff and I was happy doing it. But there was a problem. My mind was unable to process 4+ languages switching back and forth, especially switching from Php to Javascript was a real pain but I struggled to live with that (what else could I do?). And soon I found more problems. Everybody programs Php in a different style. Code gets ugly and it takes me a lot of time looking at other people’s code and searching for errors. Also, Php was slow, didn’t scale well unless you were prepared to pay lots of money on servers which I didn’t (and most people I think) have. The idea is: send a request > spawn a new Apache thread > spawn a new Php thread > compute result > generate output > send it back to the client. And that’s slow. Don’t get me wrong, I still think Php is a great language, and I still use it and I’ll continue to. But I don’t like the flow, and don’t like searching through hundreds of files in hundreds directories to find what I’m looking for. Something just isn’t right about it. It’s great for smaller apps but gets ugly when you try and build or maintain something larger.

And then came Node.js. A server implementation in Javascript. I don’t need to explain what Node.js is, there are better articles out there describing it well. It’s extremely fast, as it’s based on the V8 engine of Chrome. It’s main advantage? You get to use the same language in the client side, as well as on the server side. No need to switch between languages anymore. And it’s also extremely fast. It goes beyond fast. It’s realtime. Node.js is single-threaded. It’s a single app that runs all the time, serving results as soon as they’re ready using an asynchronous evented system. The community around it is evolving at a rapid rhythm and everyone is excited. And so am I. My mind can finally relax and focus on a single language and just code.

Maybe there are other languages that can do all that stuff better, or have more features, but none has the simplicity, and the ease of use of Javascript. And it’s a language everybody that has done web development has used before. Javascript is a standard in the web land, it’s here to stay, and with the growth of cloud based applications, cloud operating systems, and web apps in general, I believe it’s just a matter of time before everyone starts coding in Javascript, creating all sort of realtime apps that can communicate with each other and do all kind of crazy stuff. And that will trully change the Web as we know it.