DEV Community

Jason Shelley
Jason Shelley

Posted on

3 Reason Why Javascript Should be your First Language

There are many languages to choose as your first language, i.e. Python, JavaScript, Go, and Ruby. All these languages have been heralded as easy languages to learn. There are good reasons to call these languages “easy”.

  1. They are easy to set up and relatively easy to start creating projects.
  2. They have easy syntax and concepts that a beginner would find easy to understand right away.
  3. They have vibrant communities around them.
  4. There are a ton of libraries to help you build robust programs.
  5. There are many tutorials, books, videos, courses and other resources to learn these languages.

Another reason to learn one of these languages is there are many companies looking for developers who know these languages and they are willing to pay a decent wage. For example, the average JavaScript developer with experience can make over $100,000.

But which one of these languages should be your first language?

There are three reasons why Javascript should be your first language.

1) Language

The actual Javascript language, ignoring the platform i.e. browser or Nodejs, has been a matter of controversy for years. Many people love it, others hate it. It is a widely used language with a long history. But the language has gone through so many revisions, that now we are stuck in this hybrid state, where some developers write JavaScript one way and other developers write it another way. This could be very intimidating and down right annoying at times. But in reality, it created a world where a developer can learn how to code in different mindsets.

JavaScript is a multi-paradigm scripting language. It supports object-oriented, imperative, and functional programming styles. Even though it’s a dynamic language, you can use strongly typed languages that are built on top of JavaScript, like Typescript.

The flexibility of the language allows you to write in all these different paradigms. Mastering these paradigms can benefit you later on when you want to learn another language that emphasizes one of these paradigms, i.e. an object oriented language.

2) Platform

JavaScript started in the web browser. It’s one of the core technologies of the web. Learning JavaScript allows you to understand how the web works. The amazing thing about Javascript is you literally have access to thousands and thousands of websites at your fingertips. That means you have access to all these websites’ Javascript code. You can read other people’s code, learn, and practice.

Getting started with JavaScript is relatively easy. Open a browser and start playing with code in the console, or open up any text editor and start writing some code inside of html tags and then open the file in your browser, no setup required.

Now, JavaScript engines are common components of both server-side website deployments and non-browser applications. With the creation of Nodejs, React Native, Cordova, Electron and other application frameworks, you can build mobile applications, desktop applications, games and server side applications and services.

JavaScript has even appeared in some embedded systems.

To be honest though, depending on your requirements and needs, JavaScript may not always be the best solution for non website apps.

The fact that you can learn JavaScript and transfer that knowledge to a different platform is very powerful and a great incentive for learning the language.

Even though many languages, like Python, can be used across different platforms, Javascript still dominates the web.

3) Concepts & Design Patterns

The third reason why you should learn JavaScript is that there are concepts and design patterns that are openly exposed to you while learning the language on different platforms.
For example, if you write server side JavaScript using Nodejs, you are introduced to principles and design patterns that are at the core of the Nodejs ecosystem. For example, you will learn the following concepts and design patterns:

  1. Modules
  2. Event Loop
  3. Callbacks
  4. Event Emitter

1) Modules
The concept of modules teaches you how to structure your code in small well defined components. Each module should focus on one thing and it should do it well. This helps you keep your code simple and understandable. This also helps with testing. This concept is seen throughout all of Nodejs APIs. This is good training for new developers.

2) Event Loop
When you learn about Nodejs asynchronous nature and it’s Event Loop, you are actually seeing the reactor pattern in use. This design pattern is an event handling pattern. Each I/O operation/event, i.e. file access, network operation, etc, is associated with a handler (see callbacks below). When an operation is done, its result is passed to the handler and the handler is invoked. The event loop handles all of this.

3) Callbacks
Because of Nodejs asynchronous nature, it uses a unique design pattern at its core called the callback pattern.When an operation is done, it sends the result to another function.

This pattern has pros and cons. But you are exposed to another design pattern, so it is still good for new developers to see how design patterns are used.

4) Event Emitter
The event emitter class is at the core of Nodejs. This shows the observer pattern in use. An object can notify listeners when its state changes, i.e. when a button is clicked, when user input text in a text box, etc. This is a common design pattern used in many programming frameworks and platforms.

Seeing how it is used in a production grade framework like Nodejs is good training for new developers.

Every platform has its own pros and cons and design principles. These are just a few I wanted to mention that are associated with Nodejs.

;TLDR;
Javascript is used in many places and it can be fun to write and use in personal projects as well as professional projects. After learning JavaScript you can definitely find a developer job to get experience as a developer. Then you can learn other languages to advance your career.

Top comments (0)