Since the beginning of the lockdown, many people have been looking forward to acquire new skills. And I have seen a lot of interest in learning programming languages. I was asked by a few of my junior colleagues, interns and students on which programming language should they invest their time in.
As long as their requirement was generic application development, my advice has been mostly to learn Javascript. That might seem a little strange to many, as Javascript has been long considered as a secondary skill. This is because Javascript was mostly used to develop client side experience for web applications, and as long as you are not working in a company that has the luxury to afford a separate UI development team, Javascript was just another skill that is good to have.
[ A screenshot of an application that I am working on using Javascript ]
In this blog post, I would try to explain why it is no longer the case, and investing time in Javascript is rewarding than never before. Let's discuss what are the different things that you could do with Javascript.
1. Client-side development for web applications
This is the most obvious of all. Javascript has been in use as the client-side scripting language for years and has easily sidelined others such as VB script and many others.For those who are not aware of what client side scripting is, it is used to build most of that you see while using web applications (or in common language, websites). For an example, you must have noticed that an advertisement popup was displayed almost immediately after the page was loaded, this was done through a client side scripting language - which in my case was Javascript.
Javascript in its original form is increasingly not used for client side development. Rather, it is replaced with a class of frameworks called Javascript Libraries. A few popular examples would be React, Angular, Vue.js etc. which recently emerged, and legacy JS frameworks like ExtJS, Dojo etc.
2. Developing mobile applications
A few of you must have been surprised, but Javascript for building mobile applications has been in use for quite some time. Apache Cordova (erstwhile PhoneGap) is a framework that wraps code written in HTML, CSS and Javascript into a mobile application using something called a native container. Various functionalities of the mobile devices are exposed to the JS application via this container APIs. And thus one could easily build an app that runs on almost all smartphones and tablets.
A new entry into this field is something called React Native. Cordova used to run web pages in what is called a web view, which can be thought of as similar to web browsers. This comes with a drawback that the apps lacked native experience. Through React Native, developers could create mobile to deliver native experience through apps that are developed mostly in Javascript and React, which is a best-in-class JS library developed by Facebook.
The common thing across both the frameworks that I mentioned here, and many more, is that you would not require much programming skills in anything other than Javascript and the corresponding frameworks to build an application from scratch. These frameworks are pretty easy to learn once you are familiar with Javascript and some HTML/CSS.
3. Server-side programming
So far we have seen the capabilities of Javascript as mostly a client-side programming language, be it web application UIs or mobile applications. Most of the solutions nowadays would require a part that runs on servers (remote machines), which were conventionally developed with programming languages such as Java, Python, .Net etc. This was until recently when a revolutionary programming environment called Node.js was released in 2009.
Node.js has quickly emerged as the world's largest open source library ecosystem, primarily due to it being very easy to learn, quick to develop with and very light weight. Many popular web applications like LinkedIn, PayPal, Uber etc. use Node.js for part of their services.
You could be surprised if I tell you that you can get a web application up and running with only this much of code.
const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => res.send('Hello World!')); app.listen(port, () => console.log(`Application running at http://localhost:${port}`));
All you need is Node.js and a Node.js web framework called Express to run this and display "Hello World!" in the browser when navigated to a link http://localhost:3000.
4. Desktop application development
This would be surprising for many. Never heard that you can build desktop applications with Javascript? And what if I say that many of the popular web applications like WhatsApp Desktop, Visual Studio Code, Slack etc. are all built with a Javascript framework? Yes, that framework is Electron JS.
Electron offers an easy way to build cross platform desktop applications with the help of HTML, CSS, Javascript and Node.js. Even I have personally used Electron extensively and I am writing this post through a desktop application that I developed with it. Although the application is in a usable form, I haven't published the app yet due to it being still under development.
[ The blogging application that I am developing with Electron. You can see the current post in its draft form. ]
5. Developing machine learning models
Machine learning is a technique in which machines are given training inputs and the outputs to tune the machine to predict outputs for future inputs. This is in contrast to the conventional programming where the developer programs the machine on "how" to compute the output, rather than the machine itself figuring out the how part.
Say if you want to build a system that recognises cars on a road, you would first develop a learning algorithm, then feed it with a huge number of images with cars and without cars. Against each of the images, would it be labelled if it is a car or not. Based on the training algorithm and the data, the machine would learn to recognise if there is a car in a new image given.
The tuned system is what is in general called a machine learning (ML) model. And you can develop such models with Javascript.
Uhh, no!! Seriously? I've heard you would have to learn python, R, Matlab etc. to do machine learning stuff. Are you joking?
If this was your response, its time to check for TensorFlow.js. The most popular framework out there to build machine learning models - TensorFlow - has a Javascript version as well. You could build ML models in javascript and use these models in your Node.js applications or run directly in the browser.
Thus with Tensorflow.js, you can build machine learning features and seamlessly integrate it with your web, mobile or desktop applications that you built with the Javascript libraries.
6. Myriad of other scripting tasks
Well, I know I said 5 things, but here is a 6th thing that Javascript was always being used for. From scripting websites, to automating test workflows, Javascript is used for numerous scripting purposed. You may be surprised if I say that JS is widely used for hacking into websites and networks as well due to its capability to be injected and executed. And hence Javascript is very crucial for cybersecurity as well.
With the rising popularity of Node.js, Javascript is taking over many conventional scripting applications which were otherwise performed using languages like VBScript, Python etc.
Conclusion
You would have already inferred from these 6 points that you can build most of what you would like to develop with Javascript, right? But in reality for building most of the practical application that would have a user interface, one would have to know basics of HTML and CSS as well. These are simpler languages with which user interface elements are built, and aesthetic and behavioural styles are applied.
Also, it is always good to have some familiarity with at least one javascript library that fits your requirement. That would help you save a lot of time by not re-inventing the wheel. But these are way lot easier than you think, once you have a strong foundation of Javascript.
Getting interested to learn Javascript now? The best place out there to learn Javascript would probably be w3schools. If you get started now, you would be able to attain a significant Javascript competency before the lockdown is over. You would not need any extra tools or resources other than your browser, at least for experimenting with the basics. W3Schools itself has an online editor to try out what you learn in there. Moreover there are various other online applications like JSFiddle that allows you to experiment with Javascript code online.
In case if you do not want to use any of the online tools, just head over to Google Chrome, and click on the "Developer Tools" menu item from Menu (three dots on top right) --> More Tools --> Developer Tools. In the window/panel that opens up, head on to the console tab. You can try out most of what you learn in this console, even when you are offline.
[ Chrome DevTools where you can experiment with JS commands ]
I am also working on a programming tutorial through javascript for absolute beginners. Please do let me know as comments below if you are interested. Also, please do let me know your opinion and suggestions on this blog post as comments below and help me reach a larger audience by sharing this post.
No comments
Post a Comment