DEV Community

loading...
Cover image for Reviewing Eloquent Javascript #IntroChpt

Reviewing Eloquent Javascript #IntroChpt

Prerana Nawar
Web Dev | Geek | Flutter
・5 min read

In this blog, I will write on my learnings from the Eloquent Javascript Book's Introduction Chapter.

Here's the PDF for Eloquent Javascript Book's Chapter 1

TOC:

  1. What's a Progarm ?
  2. What are Higher and Lower Level Programming Languages ?
  3. What is Javascript ?
  4. Java vs JavaScript 
  5. JavaScript back in the days
  6. Where is Javascript used ?

What’s a Program?

  • A computer is a machine whose role is to execute quickly a series of actions given to it. Computers can take in and process certain kinds of information much faster than we can.
  • “Today, computers can learn faster than humans, e.g., (IBM’s) Watson can read and remember all the research on cancer, no human could.”
  • A programming language is a way to give orders to our computer. It’s a bit like a human language! Each programming language has its own vocabulary (keywords that each play a specific role) and grammar (rules defining how to write programs in that language).
  • Programming and Problem Solving increases our Abstract Thinking. Abstract thinking is related to thinking in depth. Abstract thinking makes it possible for people to exercise creativity. As the Author says "A program is a building of thought. It is costless to build, it is weightless, and it grows easily under our typing hands."
  • In the Book its written that "A program can ingeniously combine an enormous number of these simple actions to do very complicated things." So it means a complex problem is generally more managable when broken down into simpler subproblems. Then the program will be easier to understand and update.

What are Higher and Lower Level Programming Languages ?

Higher level languages can be easily understood or interpreted or compiled by us (Programmers) in comparison to the machine. As well as they Memory efficiency is less.

Examples of Higher Level Programming Languages:

  • Python
  • Java
  • JavaScript
  • C++

Alt Text

On the other hand, Machine can easily understand the lower level languages in comparison of Programmers. Here, they are more Memory efficient.

Examples of Lower Level Programming Languages:

  • assembly language
  • machine language

Alt Text

So, I don't know how to write Machine Code but the closet language I know to Machine is the Assembly Langauge 8086µ (learned in my College).

So, here's a program to find a factorial of a number.

For those who don't know what is a factorial of a number.

  • To find the factorial of a number we have to repeatedly multiply the numbers from 1 to the given number.
  • For Example: Factorial of 5 is : 5 * 4 * 3 * 2 * 1 = 120
.model small
.code
.startup
main: MOV CX, [0500]
MOV AX, 0001
MOV DX, 0000
MUL CX
LOOP 040A   
MOV [0600], AX  
MOV [0601], DX  
HLT
Enter fullscreen mode Exit fullscreen mode

Code Explanation:

  1. MOV CX, [0500] loads the number to CX Register
  2. MOV AX, Initialize AX with 0001H
  3. MOV DX, 0000 lInitialize DX with 0000H
  4. MUL CX  will multiply AX with CX. "MUL" is the instruction to multiple 2 numbers.
  5. LOOP 040A runs loop till CX not equal to Zero
  6. MOV [0600], AX says store lower 16 bit (0600) into AX
  7. MOV [0601], DX says store higher 16 bit (0601) into DX
  8. HLT to stop the execution of program

Here is the same program in JavaScript

let fact = 1;
for (i = 1; i <= number; i++) {
     fact = fact * i;
}
console.log(fact);

if number is 5 
Output : 120
Enter fullscreen mode Exit fullscreen mode

Code Explanation:

  1. let fact = 1; Here we are first initialising fact variable by 1.
  2. Then we require way to loop from 1 to the number to multiply the number repeatedly.
  3. After that, we will multiply the loop counter i with fact and will store the result in fact
  4. console.log operation will display the value of fact

Alt Text

What is Javascript ?

  • Javascript is the programming language of the web.
  • JavaScript is the web scripting language developed by Netscape. It is the most popular programming language in the world today. The language was standardized to ECMAScript, as a cross-platform Internet standard for scripting, but it is still most commonly called JavaScript.

Java vs JavaScript

A lot of people ( including me ) at the Beginning confuse JavaScript with Java and are under the impression that JavaScript is a ‘scripting’ version of Java. But what Java is to JavaScript is what car is to carpet ( #lamejokes ). They don’t have anything to do with each other.

JavaScript back in the days

  • JavaScript is first and foremost the programming language of the web. It was invented in 1995 by Brendan Eich, who at the time worked for Netscape, which created the first popular web browser (Firefox’s ancestor). Also,which means that Javascript is 24 years old now!
  • While its first official name was LiveScript in the beta releases of Netscape Navigator, the marketing machine of Netscape later altered its name to JavaScript.
  • Today, browsers mostly use the fifth edition of the ECMAScript (ECMA-262) specification.

Finally, Where is Javascript used ?

  • JavaScript is said to be the de-facto assembly of the web.
  • Web browsers are not the only platforms on which JavaScript is used. Emergence of the Node.js platform,allowed us to create JavaScript applications outside the browser.
  • Server Applications using Node.js
  • Gaming Applications for Broswer as well as there are some PhysicsJS,Pixi.js JavaScript game engines available.
  • We can also create Machine Learning Models using Tensorflow.js
  • Mobile Applications using React Native and Ionic
  • Desktop Applications: Electron , NW.js, AppJS are some JavaScript frameworks.
  • Some databases, such as MongoDB and CouchDB.

Yes, So that's all these are my key Learning from the Introduction Chapter of Book Eloquent Javascript. Also, Please do share your key learning from the Intro Chapter and what did you understood the most.

Please note that I don’t claim to have the best solution for Problems written in this blog. I’m more than happy to see other solutions as well.

This is a Bloging Challenge from #teamtanayejschallenge

Here's a link to the Website: https://ejs-challenge.netlify.app/

References:

JavaScript

Abstract Thinking - GoodTherapy.org Therapy Blog

Computation Power: Human Brain vs Supercomputer

Are Computers Already Smarter Than Humans?

Thank you very much for the patience. I’d love to hear your feedback about the post. Let me know what you think about this article, and javascript in general, through my Twitter and LinkedIn handles. I would love to connect with you out there!

Peace!

Discussion (0)