JavaScript for Dummies — Part 1

El Niño
6 min readSep 18, 2017

“JavaScript (/ˈdʒɑːvəˌskrɪpt/), often abbreviated as JS, is a high-level, dynamic, weakly typed, object-based, multi-paradigm, and interpreted programming language.” — Wikipedia. Let me translate this for you: JavaScript is a programming language that allows web developers to create an interactive website or app and the characteristics listed by Wikipedia define how programmers can use this language to do so. As I recently started to learn JavaScript, I dived into Wikipedia’s definition in order to understand what JavaScript actually is.

What is this miraculous JavaScript?

As said before, JavaScript is used to create interactive (web)applications and websites. Let’s examine the confusing but interesting explanation found on Wikipedia by looking at it step by step:

High-level

High-level programming languages allow a programmer to write code independent of a particular type of computer. This is very convenient, especially when you are just a regular person trying to type a functioning program. High-level programming languages come closer to human languages in contrast to low-level programming languages, which have more in common with machine languages. This makes it possible for programmers to focus on the functionality of their code instead of translating machine language into human language first. This allows people to learn JavaScript relatively quick and easy.

Dynamic

Dynamic programming languages execute many tasks at runtime, while a static language would do that at compile-time (read: before runtime). This means, for example, that variable types of a dynamic language can be changed throughout the code, while that would be impossible in a static programming language. You can think of a real-life example here. A static programming language would be a man putting on pants. A dynamic programming language would be a woman changing from pants, to dress, to skirt, and back to dress throughout the day. Dynamic programming (DP) has both advantages as well as disadvantages. First of all, it allows for more flexibility because types do not have to be spelled out, which makes code more compact as well. DP also allows programs to generate types (and functionality) based on run-time data, which is useful when you want to use user-input in your code. Lastly, DP ensures a better interaction with systems with unpredictable data output, which is convenient for large projects. However, dynamic programming is very runtime inefficient since a type checker must check all classes during runtime. Also, DP allows a variable to be assigned any type and incorrect types are not detected as errors, which makes troubleshooting harder.

Weakly typed

Variables in programming languages all have types like number, string or Boolean. There are many, slightly different opinions on the definition of weakly typed, but here I go: weakly typed means that type mismatches may sometimes slip through without errors and produce unpredictable results, while strongly typed languages would just refuse to compile. Note: the difference between dynamic and weakly typed is that dynamic typing is about when type information is acquired, whereas weakly typed is about how strictly types are distinguished. Let’s look at an example where ‘1’ has type string and 1 is a number:

'1'==1

In a weakly typed language, the result of this line of code would be true because it states that 1 is 1, which is true. However, in a strongly typed language, the result would be false, since ‘1’ has type string and 1 has type number which clearly does not match. So, weakly typed languages can produce unexpected results which can give programmers a really hard time debugging their code, because a lot of its behaviour is hidden in implicit type conversions. But, an advantage of weakly typed programming is that you need to write less code.

Object-based (or object-oriented)

JavaScript allows us to store variables and methods inside objects, because it is an object-based programming language. This means that we can create multiple objects of the same class (= blueprint). For example, we can build multiple houses of the same class, all containing the basic elements defined in that class. Every object (read: house) will have windows, doors and a roof. However, tenants may change a few things themselves, like the colour of the walls. These changes are then stored in the object itself. So, object-oriented programming allows us to reuse variables/methods defined in a class as well as adding specific characteristics to a single object. The advantage of object-based programming is that we can reuse code and improve maintainability. Besides better maintainability, code reuse also enables faster development. However, it takes a while before a beginner will understand how to write object-oriented programs. These programs also typically involve more lines of code and more instructions, which causes them to be slower.

Multi-paradigm

A multi-paradigm programming language can support more than just one programming paradigm, where a paradigm characterises the style of programming. The goal of multi-paradigm programming languages is to give programmers the right toolbox with which they are able to complete every job efficiently. Look at it as if it’s an actual toolbox: a hammer would be the perfect tool to hit a nail in the wall, however, using a hammer to put a screw in the correct position would be very inefficient. Therefore, it is convenient to have multiple tools, or programming paradigms.

Interpreted

A programming language is either interpreted or compiled, which defines the way in which a piece of code is executed. A compiled program, as the name suggests, is compiled into machine-language instructions before execution. An interpreted language like JavaScript is interpreted on the go, during execution. A compiled language can be compared to a kid reading a book, where the book would be the code and the kid the target machine. Before the child even starts reading, the book has already been translated into a simple, easy to understand language which makes it possible for the kid to read the book by himself. An interpreted language can be compared to a mom reading a book to her kid, where the book would again be the code and the kid the target machine. Now, the mother needs to replace difficult words into simpler, child-friendly words such that her kid can understand the story. Taking this back to actual code, an interpreted language has a few advantages. It is easier to implement and more convenient for dynamic languages (A writer can write his book without thinking about whether or not a child can understand it, depending on the parents translating it in such a way that every kid will enjoy it). However, since all statements have to be translated into machine code during every execution, the execution time of interpreted languages is relatively slow. (If the mother reads the book to her other kid as well, she needs to replace all difficult words and sentences again.)

So, what have we actually learned here?

We saw that JavaScript comes close to the human language, which makes it easy to read. It allows for compact, flexible code and great interaction between modules in larger projects. Also, we can reuse code and improve maintainability and development time because of object oriented programming. As JavaScript is multi-paradigm language, it provides a great toolbox to improve efficiency. However, it is runtime inefficient due to its dynamic behaviour and it being an interpreted language, troubleshooting is hard and due to object-oriented programming the program might be slower.

Now that it is clear that JavaScript has quite a number of disadvantages, why are programmers still using it so much?

This topic will be discussed in part 2 of this blog topic, so stay tuned!

By Felicia. Felicia is a front-end developer at El Niño. She builds the visible parts of websites and applications and makes sure the user experience is optimal.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

El Niño
El Niño

Written by El Niño

http://www.elnino.tech. Digital Development Agency building tailor made solutions, ensuring success by making it measurable.

Responses (1)

Write a response

Hello!
I’ve loved this Post and found the explanations are easy to grasp as a new comer to the JS programming!
Keep up and I'm eager to read the 2nd part :)