JavaScript is one of the most popular programming languages in the world.

I believe it’s a great language to be your first programming language ever.

We mainly use JavaScript to create

  • websites
  • web applications
  • server-side applications using Node.js

but JavaScript is not limited to these things, and it can also be used to

  • create mobile applications using tools like React Native
  • create programs for microcontrollers and the internet of things
  • create smartwatch applications

It can basically do anything. It’s so popular that everything new that shows up is going to have some kind of JavaScript integration at some point.

The things you’ll learn in this course can be applied to all the things I mentioned.

A bit of history

Created 20 years ago, it’s gone a very long way since its humble beginnings.

Being the first - and the only - scripting language that was supported natively by web browsers, it stuck.

In the beginnings, it was not nearly powerful as it is today, and it was mainly used for fancy animations and the marvel known at the time as Dynamic HTML.

With the growing needs that the web platform demanded (and continues to demand), JavaScript had the responsibility to grow as well, to accommodate the needs of one of the most widely used ecosystems of the world.

JavaScript is now widely used also outside of the browser. The rise of Node.js in the last few years unlocked backend development, once the domain of Java, Ruby, Python, PHP and more traditional server-side languages.

JavaScript is now also the language powering databases and many more applications, and it’s even possible to develop embedded applications, mobile apps, TV sets apps and much more. What started as a tiny language inside the browser is now the most popular language in the world.

A basic definition of JavaScript

JavaScript is a programming language that is:

  • high level: it provides abstractions that allow you to ignore the details of the machine where it’s running on. It manages memory automatically with a garbage collector, so you can focus on the code instead of managing memory like other languages like C would need, and provides many constructs which allow you to deal with highly powerful variables and objects.
  • dynamic: opposed to static programming languages, a dynamic language executes at runtime many of the things that a static language does at compile time. This has pros and cons, and it gives us powerful features like dynamic typing, late binding, reflection, functional programming, object runtime alteration, closures and much more. Don’t worry if those things are unknown to you - you’ll know all of those at the end of the course.
  • dynamically typed: a variable does not enforce a type. You can reassign any type to a variable, for example, assigning an integer to a variable that holds a string.
  • weakly typed: as opposed to strong typing, weakly (or loosely) typed languages do not enforce the type of an object, allowing more flexibility but denying us type safety and type checking (something that TypeScript - which builds on top of JavaScript - provides)
  • interpreted: it’s commonly known as an interpreted language, which means that it does not need a compilation stage before a program can run, as opposed to C, Java or Go for example. In practice, browsers do compile JavaScript before executing it, for performance reasons, but this is transparent to you: there is no additional step involved.
  • multi-paradigm: the language does not enforce any particular programming paradigm, unlike Java for example, which forces the use of object-oriented programming, or C that forces imperative programming. You can write JavaScript using an object-oriented paradigm, using prototypes and the new (as of ES6) classes syntax. You can write JavaScript in a functional programming style, with its first-class functions, or even in an imperative style (C-like).

In case you’re wondering, JavaScript has nothing to do with Java, it’s a poor name choice but we have to live with it.

JavaScript is loosely typed

In programming, we call a language loosely typed when you don’t have to explicitly specify types of variables and objects.

A strongly typed language, on the contrary, wants types specified.

There are pros and cons, you can argue forever but the reality is that both approaches are great, in their intended context and usage.

JavaScript is loosely typed. You don’t have to tell that a string is a string, nor you can require a function to accepts an integer as its parameter.

This gives JavaScript a lot of flexibility. Flexibility lets you move faster, change things quickly, iterate at a faster velocity.

A strong type system instead gives much more structure to a program and it’s a great aid for example, when working in teams when one single programmer can’t really have all the codebase in mind when working on it, and having types helps keep the code manageable.

This is typical of compiled languages (while famous dynamic languages like JavaScript, Python, and Ruby are loosely typed).

You trade some of the flexibility that a loosely typed language gives you to get more security and trust in the codebase.

The compiler thanks to types can detect errors at compile time, rather than at runtime, making it simpler to write code that does what you want (and makes the testing phase slightly easier, although nothing can make your programs perfect).

TypeScript is a great example of a strongly typed language. It compiles to JavaScript, giving you the benefit of the JavaScript platform plus the intended advantages of types.

Being loosely typed doesn’t mean you don’t have types, of course. You just make use of types implicitly, as you’ll soon see.


Go to the next lesson