Programming with Javascript in a big picture

This tutorial is a part of the Learn everything about Javascript in one course.

What is computing?

Computing can be thought collectively as a 3-phase process that happens as:

  1. Input some raw information (numbers, characters ..., usually not useful but has to represent real life objects and things)
  2. Process the information
  3. Output some useful information

IPO

Computer role in computing Human's (your) role in computing
1 Stupid but fast Intelligent but slow
2 Do exactly what's told Can come up with complex and efficient solution
3 Very fast and consistent Slow and sometime inconsistent

Computing = Human + Computer. Human provides efficient solution, computer repeats what human provides fast.

square.js
// function to square up any number (the process #2)
function square(x) {
  return x*x
}

const input = 2 // #1 input - information we already have
const output = square(input) // #3 output - the desired information we want

// print out output to terminal
console.log('output:', output) // output: 4
$ node square.js
output: 4

Simple idea? Yes, but powerful. You can easily get lost during the learning. Use this concept to guide yourself. Output useful information is key. Remember this throughout the course!

Another more realistic example: find the shortest path from Start to End in two different scenarios:

path

The role of a programming language in computing is to:

  1. Give everyone a tool to tell computer to do what you want it to do (it's important to understand that you are the one who do the information processing not the computer)
  2. Standardize this tool with its lexicon (vocabulary) and syntax (grammar)

Without this tool and standardization, people will write code in their own ways. No computer nor human can understand others' code.

// ----- example of chaos programming with no language or standard

// coder1, defining a function
coder1 way to define function my way square (x) {
  return x*x
}

// coder2, defining a function
coder2 way to define function square [x] {
  return x*x
}

// no computer nor human can understand either coder1 or coder2 way

// ----- Javascript (standard) way to define a function

function square(x) {
  return x*x
}

// now computer and everyone can understand

What does it mean to learn a programming language?

Very much like learning any other human's language. Learning a programming language means that we learn the lexicon (vocabulary) and the syntax (grammar) of that language in order to do computing (express our thought in a way computer understand and repeat).

square2.js
// my thought: I want to square up any number
// express my thought in Javascript language
function square(x) {
  return x*x
}

// now the computer can do the square job for me whenever I tell it to
console.log('output:', square(2)) // output: 4
console.log('output:', square(3)) // output: 9
$ node square2.js
output: 4
output: 9

Learning Javascript simply means learning programming language named Javascript. As opposed to different languages such as: Python, Java, Go, ... which are for slightly different computing purposes.

What kind of applications can be programmed with Javascript?

There's a huge range of applications can be developed with Javascript. That's why it's the most popular programming language with available job openings. It's also worth to note that with Javascript, you have a tremendous ready-to-use number of libraries and frameworks to achieve the work you need. Pretty much everything you think of implementing, people already thought of and done it.

  • Browser application (web apps)
  • Mobile application (iOS, Android apps)
  • Backend application (server apps)

Javascript can be used (but not optimized) to develop the following kinds of application, although with the current development of Node.js and in-browser machine learning, these can be changed in the near future.

  • CPU intensive applications
  • AI, Machine Learning applications

Why programming job is paying so well?

Almost everything can be represented in form of information, for examples: audio, video, text, graph, ... Extracting useful information from them is proven to be valuable. For example, predicting cancer from CT scans, recognizing human identity via a photo, organize the best optimal way to travel from A to B ...

Scalability: build once, everyone can use it. If you build something useful and the whole world needs to use it, everyone can. If each person pays you $1, you will be a $7,000,000,000 billionaire. Your work scales at unimaginable rate.

Impress your friend: latest iPhone model on sale for $99

Go to any website that is selling the latest model of iPhone, then:

  • Right click on iphone price, select inspect.
  • In Element tab, right click on highlighted price, select Copy then copy JS path.
  • Switch to Console tab, type in let el = and paste then enter/return.
  • type el.innerText = "$99" then enter/return -> iphone new price is now $99

99 iphone (This is what happens on your browser only. Information from the original website server is not altered in anyway, meaning you won't be able to buy that iPhone for $99.)

Powerful, Yes? And it's just a simple taste of what you can do with Javascript. You can command your browser to do whatever you have seen (and more) with Javascript.

Summary

  1. Computing is to process raw information and get useful information.
  2. A programming language is a tool to do computing.
  3. Learning a programming language is to learn its vocabulary and grammar to be able to do computing.
  4. Javascript is great to build everything but not CPU intensive and AI application (yet).
  5. Programming job is paying so well because: useful information is valuable and the outcome result is unimaginably scalable.
  6. Go tell all your friends (a good joke) the whole internet is on sale.

Ready for work? Practice these real life interview questions

  1. What do you think computing is and what is your role in it?
  2. You want to join our company as a frontend/backend software engineer, what do you want to contribute to us to fulfill your job position?
  3. What does it mean to learn a programing language?
  4. What types of application can and can't be developed with Javascript? Give some examples.
  5. I give you a web browser connected with the internet. Can you demonstrate that JavaScript can do something meaningful?