Reasons Why JavaScript is Awesome
October 02, 2021
Coding is one of the most valuable skills you can learn on your own. It can give you superpowers at your job, help you find a fulfilling career, and enrich your intellectual capabilities. You can use coding to:
- Automate various aspects of your job, such as the creation of spreadsheets, presentations, email templates.
- Build a coding-related career such as mobile app, game, web development, data analysis or science, machine learning.
- Pursue interests such as art, science, entertainment.
Whatever your reason for learning it is, coding is awesome. Coding with JavaScript is even more awesome since it enables you to do all those things listed above and more. This is thanks to the wide adaptation of the JavaScript language and its 3rd-party packages/libraries. This post will introduce some of the exciting and awesome JavaScript packages with simple code examples to demonstrate the wide range of things you can do by coding in JavaScript.
Natural Language Processing
Natural Language Processing (NLP) is a field that concerns itself with the analysis of human language. Using NLP techniques, you can programmatically detect the language of a given text, analyze its sentiment to understand if it holds a positive or a negative opinion, or extract entities such as names, places, etc. There are numerous NLP packages in the JavaScript ecosystem that allow you to perform these kinds of operations.
Language Detection
Franc is a JavaScript package that allows you to detect the language of a given text. I have included a small program to illustrate how it works. You can provide the program with a paragraph of text, and it will use the franc library to try to detect its language. Note that the functionality doesn't work great when provided with a shorter text.
Named Entity Recognition
Named Entity Extraction identifies entities like names, locations, or phone numbers inside a given text. Compromise is a JavaScript package that we can use that allows us to not only extract entities in a text but also identify what types of entities they are. Here is a sample program that allows you to enter a text file into the input field, and it would extract and identify any recognizable entities in that text.
Note that even though having these libraries is excellent, you might need to use an ML/AI-powered natural language service that would allow you to do all these things and even more!
Data Visualizations
Creating data visualizations is extremely useful when you want to quickly grasp the information contained in the data. Luckily JavaScript has several excellent packages that would help you create awesome data visualizations. Which package you choose depends on your business and technical requirements like the kind and complexity of graphs you will be creating, if you need animations or not, etc.
Chart.js is an easy-to-use package that can help you quickly create various kinds of charts and visualizations from your data. Here is an example of a line graph of some random data that is drawn using Chart.js.
You can quickly create different kinds of visualizations by changing few lines of code. Here is a pie chart using the same library:
Another strong option in this category that is important to mention is D3.js. D3.js is substantially harder to get started with than Chart.js, but it is great if you have complex and custom data visualization requirements. Take a look at the D3.js gallery to see the variety of things you can achieve with it.
Creating 3D Graphics
One of the fascinating things that you can do using JavaScript is to create 3D graphics that can run on a web browser. Creating these graphics used to require specialized software that was thousands of dollars to buy and required hours of computer power to generate. It is incredible how far technology has come and what can be achieved using JavaScript.
One awesome library that you might want to check out for creating 3D graphics is Three.js. Three.js is a widely adopted technology that is used to create all kinds of unique 3D content and experiences on the web. Here is an introductory 3D scene created using Three.js. It simply consists of a 2d plane and a 3d sphere and camera. It tries to capture a certain amount of realism by using interactive lighting, shadows, and textures.
If you would like to know how I created this scene above, you can look at this) detailed walkthrough I have created for it.
This is a relatively simple example and does not do any justice to the fascinating things you could do using Three.js! Make sure to check out their demos on the Three.js homepage to see the full spectrum of things you could do with this library.
Also worth mentioning is that you can use JavaScript to build 3D content for AR and VR scenes as well.
Creative Coding and Generative Art
So far, we have seen libraries that have a specific utility value. They are great for a particular purpose. There is a subfield of programming called creative coding, where the goal is to create something expressive rather than functional.
p5.js is a great library for creating visuals and animation and doing artistic explorations using code since it makes it easy to create visualizations.
Here is a fractal tree created using p5.js.
p5.js is not only suitable for creative coding purposes. You can create all kinds of interactive and animated works with it. Here is a simple number-guessing game built using p5.js. You can press the number that you have on the screen to try to guess the number. Three wrong guesses, and you lose!
Note that even though you can build animated works and even games using p5.js, you might want to use a dedicated game framework such as Phaser.js to build anything more involving
These examples I have introduced here scratches the surface of the things that you could do with JavaScript! Using JavaScript, you can build mobile and desktop applications, perform machine learning/AI-related tasks, program internet of things (IoT) devices. There is simply no other language as accessible and powerful as JavaScript, which makes it an awesome choice to start learning coding with!
Find me on Social Media