Why JavaScript should be your first Programming language

Why JavaScript should be your first Programming language

Image for post

Tell me, why the majority of people who decide to join the gym in January can?t continue till March?

Because they go too hard the very first day.

Similarly, when learning programming for first time, if you expose yourself to lots of new theoretical concepts before you even write your first code, then you automatically lose your interest within few days.

There are two key factors to learning any new skill:

  1. Low barrier to entry
  2. Instant feedback

JavaScript has both. It is very easy to get started with, and you can see visible results with the minimum amount of code compared to other languages.

But I don?t know HTML and CSS

Yes, you will have to learn HTML and CSS too, because that?s how you display things. JavaScript runs behind the scenes and interact with HTML and CSS to make changes on the screen.

You will have to code the GUI (Graphical User Interface) in HTML and CSS.

However, doing GUI in other languages is much more complex than doing it in HTML and CSS. For example, let?s create a square box with HTML:

<div style=”width: 100px; height: 100px; background-color: red; border: 1px solid gray;”></div>

This creates a 100×100 px box, with red background, and 1px solid gray colored border. And ?div? stands for division. Anything you don?t get there?

It?s easy, right?

To make this same box in any other language, you would have to import some GUI library first, then create a window, then handle that window, and then you get to code the box on that window.

Those first three extra steps can easily discourage you and destroy your interest in coding.

When learning a new skill or cultivating a new habit, a low barrier to entry is vital for maintaining the consistency.

I hate it when I have to explain 13 complex concepts to students before teaching them to print ?Hi!? in GUI.

But why am I putting a lot of weight on GUI? Because the GUI results feel more tangible.

Creating a calculator to add numbers in a black and white console is really a boring shit for beginners. Moving boxes on screen when we click on it feels awesome. It encourages the beginners to learn more, instead of giving up early.

Okay, back to our question:

Will you need to learn HTML and CSS to learn JavaScript?

Yes.

And that?s not a disadvantage, it?s actually an advantage.

It?s a good idea to make the GUI in HTML and CSS, that way you learn two more technologies, that can be applied to web and mobile.

In fact, HTML and CSS are so good and easy for creating GUI, that many other languages are starting to adopt it as their way of creating GUI.

So, learning HTML and CSS is not only easy compared to learning GUI in other languages, it is more useful too.

If you have never coded any HTML and CSS, then this tutorial will get you started: Batman?s Love Letter in HTML ? your first HTML code

Things to avoid when learning JavaScript

When I say JavaScript should be your first programming language, I mean plain vanilla JavaScript that works in your browser out of the box.

No Nodejs, no React, no TypeScript, no jQuery ? only plain JavaScript.

Also, many new features are introduced to JavaScript every year. If you can?t decide if you should learn it or not, here?s a shortcut for you: if your browser doesn?t support it, don?t dive into it. Period.

I want to repeat one specific thing ? no jQuery.

I started my journey into JavaScript with jQuery, like many self-taught beginners do, and I regret it. I wish I would have invested a little more effort in learning plain JavaScript first.

A brief background of JavaScript and where it?s heading towards

I believe before learning a language, you must know why it exists at first place, and where it is going.

So here?s a brief journey of JavaScript.

When the earliest Web browsers were released, people soon realized that they needed a scripting language to make the websites more interactive. Web developers badly wanted these functionalities:

  • Logic handling: HTML and CSS only define the look of a website, they don?t handle any logic. Example use: To show an error message if the user forgets to fill a mandatory field in a form. Here we need to handle the logic that checks if a field is mandatory and is left empty.
  • Data handling: Before JavaScript, you had to send the data to server, then process it in server, and then send it back, because there was no way to process data inside browser. Example use: Show preview of a post before saving it. Here we need to update the preview with the data a user entered without sending it to server.
  • HTML & CSS manipulation: Web developers badly needed some way to programmatically access and manipulate HTML elements and their CSS styles. Example use: To give the empty form field a red boundary, showing that the user must enter the required data in the field. Here we need to give a red boundary to an element from script.
  • Event Handling: Any scripting language will not be of much use if it can?t capture and handle user and browser events. Example use: Add an item to cart when ?Add to cart? button is clicked. Here we need to handle the ?click? event on the ?Add to Cart? button.
  • Communication: Before JavaScript, the only way to send data to server from a website was through ?forms?. This imposed a big constraint on web developers. Example use: when you want to communicate with server but don?t want the user to submit a form for it.

These five major reasons gave birth to JavaScript. JavaScript has all these features.

Now let?s look at where JavaScript is going towards:

  • Server-side development: NodeJS opened a big platform for JavaScript developers. Now you can make desktop and server application in JavaScript, without any need of a browser. Yes, JavaScript outside browsers.
  • Mobile development: There are a number of player in this field which allows you to make mobile apps with HTML, CSS, and JavaScript. React Native allows you to write native mobile apps in JavaScript. That?s so cool!
  • Faster JavaScript engines: The big fishes in the market ? Mozilla, Google, and Apple ? they are all competing to build the fastest JavaScript interpreters inside your browsers making the web apps almost as fast as native apps.

So, if you know JavaScript, you can make Web Apps, Server Backends, Desktop Apps, and Mobile Apps. There?s hardly any language that covers such wide range of applications.

But JavaScript is not a Programming language. It?s a scripting language!

Yes, I can already hear a lot of people who?ve read a couple of wiki articles shouting the above sentence.

The thing is, does it matter?

With the wide varieties of applications that you can make, plus the enormous amount of career opportunities it opens, there is no reason for categorizing it as a scripting language or a programming language.

The important thing is ? it gets shit done bro!

Career Opportunities with JavaScript

It?s no surprise that majority of success stories posted on Reddit and other forums are about how a self-taught programmer got a Frontend Development job in a big IT firm or a local Startup.

Because Frontend development (HTML + CSS + JS) is the easiest and fastest path to get a career in programming.

Here are some advantages if you are starting your journey with HTML, CSS and JavaScript:

  • Frontend Developer: Avg Salary: $76,200
  • Node Developer: Avg Salary: $91,668
  • Full Stack Developer: Avg Salary: $110,597
  • Remote job opportunities: work from any corner of the world
  • Easy to get freelance work compared to other languages
  • Easy to build portfolio compared to other languages

Problem with most online Tutorials and Courses

I believe the fastest way to teach someone a new skill is to start with the fun stuff, and teach the boring things later down the road.

Unfortunately, most of the online tutorials and courses do the opposite. They teach the boring concepts first, and the student lose their interest and willpower before the fun stuff begin.

If your JavaScript course has first chapter on variables, second on functions, and third on arrays, then guess what, 90% of students won?t even make till 4th chapter.

I am on my journey to change this. I am writing tutorials that teach you to build things first, and learn the theory later. This way you don?t lose your interest and keep learning.

Do subscribe at supersarkar.com for new tutorials every week.

Keep Rocking m/

22