Tuesday, November 3, 2015

Why I recommend Javascript to my wife? And to everybody

Almost everybody who born as human will think about their partners in advance. Only the depth and frequency of thinking might vary. When I graduated and joined first company, I was thinking about a girl who is working in a technology company but not related to software. The reason behind that is, if both of us are in software, we might talk about software development always which will affect some other developments. As I switched companies and when my parents really started searching bride for me, my thought process was different. (Non Indians may not understand what is arranged marriage.Its not at all forced marriage. In our arranged marriage, couples meet twice or thrice alone to talk before they decide to marry. Mostly parents screen the girls first and arrange meetings. More details see wiki).

I was thinking about a girl who knows how software development works or minimum graduated in computer science but not working in software development / coding! Can be computer science teacher in schools or colleges, working in software administration in other industries such as banking to a level of QA in software industry. The reason behind my change was the culture of the company I was working. Most of the days, need to work or I will say need to be in office for more than 12-14  hours. A normal girl who don't know the peculiarities of software development process will have tough time understanding, why I am staying late in the office.

Finally got one who just completed Masters in computer science and offered from Infosys, one of the well known companies for software development. But fortunately or unfortunately after the marriage, the decision has changed to try in teaching field. She got it quickly in a startup engineering college. That college doesn't have computer science dept. But in the first and second years, all the other departments have CS paper. She find it cool teaching C/C++ etc...

The college was far away from where we stayed and it became difficult to travel more than one and half hours when she conceived baby. She had to quit and became house maker. All went well and we now in US obviously she is in H4 jail. Getting into teaching position seemed tough, so she thought of coming again to development. The tough question came. Which language? Which technology & Platform?

When she asked the same to me, I had no confusion on saying 'Learn Javscript'. Not just learn, master it.

Why Javascript?

If we are passionate about software engineering and up to date with the industry this question will be already solved in our minds. For those who are still thinking about learning Javascript, below section s added which explains why to learn Javascript to secure in software development.

Javascript is everywhere

Yes this is the main one reason to learn Javascript. Lets see where all we can run Javascript.
  1. Javascript in web development
  2. With the arrival of faster and multi core processors browsers are now able to render html and process Javascript with very less time. This makes us write javascript driven applications which can run with high response. Another reason is the HTML5 which has more features targeting towards web site to web app transformation. Now we can leverage 3D capabilities via HTML APIs and javascript 3D libraries. It is real and there are many sites out there which uses it. It was not the case earlier. Now we can see lot of process heavy apps are getting written in Javascript and rendered in browser.
    All the mail apps such as gmail, outlook etc...runs smoothly in browser with heavy Javascript. Even there are Javascript based game available which runs smoothly in any average machine.
  3. Javascript in mobile development (cross platform)
  4. Everyone wants to run their application everywhere. But nobody wants to develop more than once. Especially in mobile platform where there are 3 clean leaders whose platforms are not at all compatible except rendering HTML. We can develop apps for mobile in html, but it may not take the capabilities of hardware especially sensors. So selection of mobile platform was very critical in early mobile development. People tried many solutions and one of the best solution is to develop in HTML and Javascript itself and compile into native form. Phonegap is one leading platform in this and there are many technologies in this area.
  5. Javascript in server side
  6. With the launch of Node.JS, Javascript gained popularity in server side as well. It works using chrome V8 Javascript engine and 2 simple C++ libraries for accomplishing event model. It has already proven its scaling abilities and many web apps are already running using it.
  7. Javascript for desktop application development
  8. This is another platform where software is running today and may run for some more years. Earlier there was no popular way to write desktop applications using Javascript. But as of my understanding Microsoft changed the model by bringing support for writing Windows 8 desktop apps using HTML5 and Javascript. They did it in very simple way. Extracted the browser rendering mechanism and hosted it in windows app container. They established binding of native resources / objects into Javascript so that Javascript which is running inside can manipulate anything in the machine. This is what any desktop application platform does.
    But is it not cross platform. We cannot run out Windows 8 application in Linux. It is been addressed by another similar technology named Electron came out from Github. Github used Chromium as their UI container. Chrome already knows how to render HTML and it has good Javascript engine as well. Connected the dots and we got a nice Javascript + HTML based desktop application development platform. Even Microsoft uses this new technology in their cross platform Visual Studio called VS Code.
  9. Javascript for Robotics & IoT / Micro controller boards
  10. Another area where software can run is micro controller boards which is expected to be the heart of IoT. Micro controller means a small computer which has input and out ports, memory and processor to  execute instructions read from memory. Details on what is IoT is available in wiki. In next 5-10 years with the help of IPv6 all the things / devices such as microwave oven, house doors, chairs, tables, fridge,car, medical devices will be connected to internet and all needed to be programmed. If those devices require different languages and tools, it would be difficult to survive both for us as well as companies. Companies needs to hire new people with high salary or spend on training. But the smart people are trying to unify the language and that language is going to be Javascript 99% of time. There are enough controller boards available now which out of the box supports Javascript. eg: Espruino. Even the famous boards such as RapberryPiArduino can also use Javascript. This pretty much shows that robotics programs can be written using Javascript.
  11. Javascript as DSL
  12. Domain Specific Language is everywhere and we use it knowingly or unknowingly. It is not a language by itself. Its the way we model our business domain and expose it to the users. Users can be our fellow team mates or actual users. Once we have our domain objects, the code to manipulate it can be written in any language such as Powershell, Javascript etc...provided there is DSL run-time to execute the DSL scripts from our host application. In fact if we think deep we can realize that in browser we are using Javascript as DSL and the domain objects are the HTML elements and web request. Similarly when it comes to Node.JS same Javascript and engine process different set of domain objects which are nothing but the server side resources such as files, databases etc...
Are there any other areas left where software runs?

Javascript language has less and rest done by frameworks & engines

The core language is always simple with functions as first class citizens. It can simply do manipulations and call methods on the objects which are passed into it during run-time. But its getting all things done and run everywhere with the help of libraries, frameworks and run-time engines.

If it is running in browser the objects passed to it are the DOM, XHR etc...If its running in server side as Node.JS the objects are http request, http response, database driver, file system object etc...If its in mobile the objects available are the sensors, phone calling and messaging system, file system inside mobile, network IO, display provider etc...finally if its running as DSL, the objects passed are the domain objects such as list of customers, employees which are specific to the business.

Why we need to be masters?

Anybody can write code in Javascript and people were surviving because javascript was mainly used to get some interactivity to the web pages. More than that, it was used to implement kind of 'nice to have' features such as client side validation where we already have a server side validation. Even if the Javascript is disabled at client side our web sites should work. In another words, as a second class citizen. The main reason was slow internet connectivity and even if someone tried to develop Javascript driven web site, the chances for a large crowd using it was very low. Because most of the public had no good connectivity. And due to that reason obviously nobody put attention to improve the Javascript language specs as well as the run-time engines. Big issue was, the rendering browsers were not standardized. If we wanted to make Javascript run in all the browsers, we had to work lot and often will miss deliveries.

But now as we seen earlier things are different. Internet connections became faster. People foreseen the change and they put effort in standardizing the browsers, improved the language specs and engine. Finally framework development started which ensured the compatibility among browsers. We got confidence that our code will work in all the browsers, if we use these frameworks such as jQuery . That enabled us to focus on the features instead of spending time on compatibility issues.

Web sites to web applications

Another important change which already seen is the shift from web sites to web apps. Earlier web development means creating bunch of web pages which will be delivered to browser in the form of HTML. Whether we use ASP.Net, PHP or Java all were just mechanism to generate pages dynamically. The business always remained in the server side. One of the belief was Javascript is not secure and we should never keep our business in it.

But now things changed. The server side slowly retired from its web page generation and business logic container duties and the new role is 'web service' or data provider. If the server just keep the data we can develop application in any client device provided there is a constant connectivity to the server and secure communication mechanism. Connectivity now is not at all a problem. Security is enforced via secure communication protocols such as TLS.

Need for writing good Javascript code

If we agree or not Javascript is everywhere. It is now becoming essential part of our application. In such a scenario, if we don't write the application well, it going to fail. As we all know we are paid to develop applications which works and scale. Due to lack of Javascript knowledge, in the earlier days  the failure may happen only to some nice to have client side validations. But in this new era, entire app will not work. If our app is not working, it leads to less revenue to the company and finally it threatens our job.

The natural selection allows only survival of the fittest species. Similarly if we don't know Javascript there are high chances that the software evolution may eliminate us from the industry.

I have seen many people sitting in HR and admin sections who were once programmers and they talk about their programming history with proud. Should they be proud of their programming history which they were not able to survive? Sometimes they might have left the software development due to other reasons. Whatever if we don't want to be in same place after 10 years, it is very much advisable to learn how to write quality Javascript code.

Of course if we are into system side programming using assembly,c or c++ or go languages, it may be slightly different.

Javascript has lot of garbage

Though the language is getting improved, lot of frameworks and standardized browsers, writing good Javascript is still hard. It is because the language contains lot of garbage from the past. It is not going to be removed from the language to maintain backward compatibility. ie There are lot of applications written using the existing / bad language features. They are all working because they are expecting the language to work in that specific way eg == and ===. All of a sudden if the language got breaking changes or remove bad features all those applications will stop working. In Javascript versioning is too not possible. If we had below features we could write better Javascript in new version. But unfortunately that is not possible and doesn't makes sense in Javascript world.

<script type='text/javascript' version='6.0'>
//Source which contains new clean Javascript language(where == acts like === and === is removed)
</script>

Due to backward compatibility, there are lot of ways to achieve same thing in Javascript. Some ways, we can simply avoid and some needs to be careful selected.

References

Books

Links


Disclaimer

This doesn't mean that JS will survive for ever. When a better new language is born or existing language is enhanced, we should focus on that. But be assured that at least for next 3-5 years, Javascript will survive. As everybody knows The only thing which don't change is CHANGE.

1 comment:

Blogger said...

Did you know that you can create short links with Shortest and make dollars for every visit to your short links.