day 04 of 1000 days

Welcome, hope your day was good. Sorry for the gap, I was ill. But I promise, this won't happen again in my journey.

Brief: - Today I studied backend web development. Learnt some basic how the web works.

Detailed:- Client and Servers are nothing but computers connected to the network. The server contains the site(its data etc), and the client is the browser trying to connect to the server. The client sends a request to the server when we type the site URL in the browser, and the server sends a response for the request which contains site files(html, CSS, js).

There are two types of sites :

1.) Static sites -> Server only have html, css, and js files and send them as they are to the client. These could be the files like portfolio website which don't have to be updated with data.

2.) Dynamic sites-> Each time the user logs into the site the server has an application which interacts with the data and compiles it into a site (making HTML, CSS,js) which then send to the user.

Sometimes user also sends a request to ask for some data/information to the server. They may not ask the whole site. The server has an application programming interface(API) which responds to this request and send data to the user.

I also started nodejs learning. The reason for choosing this is that I have js knowledge(not expert level though) and it would be easy to move forward in it. Also, it's in the demand.

Nodejs is not a language but js runtime environment. The runtime environment is like a system/container which has everything to run js. Browser is also js runtime environment. The difference is it runs js on the client side. Nodejs is made to run js on the server side. It is made of the v8 engine of google(the same used in chrome) and c++ libraries (to interact with data, network etc). The engine is thing where js code executes.

Nodejs is made up of various modules. Modules =packages=libraries= code which is written to do some specific tasks like to interact with file system. Nodejs provide a tool called npm(node package manager) to manage these packages. Nodejs has many built-in packages and many 3rd party packages.

Nodejs is single-threaded. In simple words, it can do only one task at a time. Thus we have to design our programme to avoid blocking the thread.

[I was confused in thread and core. In case you are also, let me explain in layman's language though this may not be technically correct. 1 thread = 1 operation. The core is real hardware that does operation/task/thread. 1 core can run 1 thread, ie do one task/operation. In modern cpu we have hyperthreading ie 6 cores 12 threads. 6 cores for 6 threads, and for the next 6 cores, we have made 6 virtual cores. For multitasking (like running a game with chrome opened in the background) more threads are useful, for a big single operation (like video editing) more cores are useful.]

Actually, in nodejs we write our code such that the heavy time-consuming tasks are transferred to other threads.

I also made a file using fs module and then read the output. You will have to watch some video tutorials for it, as the documentation was confusing or probably I am not that good to read it.

I later practised the js array methods, especially the map, filter and reduce methods. We should use them instead of for loop as they are declarative and closer to functional programming. (I at this moment don't know much about these.)

Personal: I was down with a fever. I did some study but not that much. I will try to be fit from now on. Today I started some yoga, 10 min anulom vilom and 2 surya namaskar. They may not sound much but concentrating for 10 min was tough at least for now and being fast surya namaskar was tough. I will also have to work on my weight, which I will start tomorrow.