If you're looking to get started with programming, there's a wide variety of languages to choose from and it can be paralyzing to try to make the "right" decision.

There isn't a single best choice for everyone, but there are a few languages that are more friendly than others.

JavaScript is one such language.

This article breaks down 3 reasons why JavaScript is a beginner friendly language. Let's jump in.

Reason 1: Dynamic Typing

The type system that surrounds a language influences different factors of learning.

Aspect 1: Not having to define types for your code significantly increases perceived velocity.

Statically typed languages require you to define the types of the references (e.g. variables, function arguments, etc.) you'll be using, and you are required to satisfy the compiler before your program will be built. For example:

let x: string = 'x';

x = 10; // ERROR: This won't compile because a variable that is
        // typed as a string can't be assigned a number value.

Dynamically typed languages don't require you to satisfy the compiler and you can do things like change a reference's inferred type like so:

let x = 'x';

x = 10; // reassigning x, which was a string, to a number.

The pace at which you progress is influenced by the learning curve of a language, and a statically typed language inhibits your initial coding speed because it requires more cognitive overhead to get the code to compile. (I say initial because I would argue it actually makes you quicker to produce resilient code, but there are more important aspects to consider as a beginner.)

The less complicated a language is to get to compile and run, the faster you'll pick up the basics and feel like you're making progress.

This in turns makes the language more fun and engaging, and ultimately gets you coding more which is your number one priority as a beginner: to keep coding.

Aspect 2: The type system also influences the kind of bugs you face.

More specifically, a dynamically typed language is more error prone because it's easy to assume that a reference will be a certain type, when it is actually given a different type. Take this example:

function add10(value) {
  return value + 10;   
}

add10('10'); // <-- uh oh, do you see what's wrong?

We accidentally passed in a string to a function called add10 which is expecting a number.

The return value of this function then becomes "1010" (the string) because of what happens when you "add" (use the + operator) on a string and a number in JavaScript.

This is an entire class of bugs (the expectation of incorrect types) that is removed by a statically typed language.

Statically typed languages are great for creating resilient code because it is less bug prone, but I make the case that dynamically typed languages are still a good starting language because:

  • Fixing bugs that occur due to type mismatches enforces good debugging habits. The more bugs = more practice debugging.
  • Compilation errors are often harder to understand than runtime errors. "Can't read x of undefined" with a line number is much more concrete than a big wall of error message text caused by a mismatched type on an object interface with lots of properties.

Reason 2: No need to learn more than one language for full-stack development

If you've heard the term, "Full-stack development", this essentially means that you can write client-side code (like a mobile app or website) as well as the server-side code (the services that are deployed on the cloud that processes data requests.)

A quick summary of client/server is:

  • Client-side code is typically code that is run on a user's device. In the case of a mobile app, the software package is downloaded and installed on the user's device. In the case of a website, the software is delivered over the internet on a web browser, where it's temporarily downloaded and executed.
  • Server-side code is code that is executed on servers that are accessible over the internet, and it functions to centralize the application data that is used across multiple clients (user devices.) For example, a todo list web application will sync the state of your todo list with a database in the cloud through a server so that it can be stored and accessed later from a different device.

JavaScript has one major advantage over all other programming languages. It is the only client-side scripting language that is understood by web browsers and also serves as a viable server-side language.

This means its possible to write JavaScript for your website, but also use JavaScript to write your servers that processes data for that website.

At a high level, whenever you're starting out with programming, you want to be productive so you can begin exercising your logical thinking skills as opposed to getting bogged down by technicalities. JavaScript allows you to do precisely this because you can begin creating full-fledged web applications with only one language.

No other language offers this ability as far as I know.

Reason 3: Ubiquity across the stack.

As an extension of reason 2, JavaScript has become an incredibly popular language to run server-side code over the last 10 years (and it is really the only choice for client-side code run in web browsers.)

Because of this ubiquity across the entire stack, learning JavaScript opens a world of front-end opportunities as well as a good number of back-end opportunities when seeking employment.

Simply said, it's just a great tool to have in your toolbox.

In conclusion, know that a language is ultimately just a tool as a software engineer, and your "first" language won't matter as much as how deeply you learn the languages you have to pick up to be effective on the job.

That said, JavaScript is beginner friendly because:

  • The learning curve is shallow. You can onboard onto the language quickly and start slinging code quickly.
  • It's bug prone due to dynamic typing, but that can actually help you exercise your debugging muscles.
  • You can use it both on the client-side and server-side.

All of these factors make it easy to build momentum by being productive with your code (actually create things that are useful,) which has the best byproduct of increasing your motivation to code.

3 Reasons For Learning JavaScript as a First Language