Skip to main content

6 Hours NodeJS Challenge

So, what is Node.JS? Well, "Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser". At least that's all that I know about Node right now. But, that is going to change today. Well, I saw this YouTube video a few days back where a developer, who had no idea about golang a.k.a "Go Programming Language" and managed to learn it and create a simple application using it within a few hours. He was an professionally experience developer which I certainly am not at current point of time, however, even he must have faced some challenges while doing so. After all, it was officially a challenge after all. Although I am not professionally a developer, I really wanted to take up such a challenge. This blog is a record of how the challenge went for me. Of course, a few hours of time is not sufficient to master any programming language, I think that after reaching a certain level as a programmer we can certainly learn the language enough to be able to apply it. You must have heard that "Big companies like Google don't care about what language you know", well guess what, it's because they look for the programmers in high enough level to be able to learn and apply the programming language that they are using in any particular project n a short period of time. This is a test for me as a programmer to check if I am in that level.

I will be updating this blog along with time to keep a record of what a accomplish by a certain time. So here we go.


Entry 1: 29th June, 2020 - Monday - 10:20 AM IST

Since I have no idea about how Node.Js work and what I can do with it, I am going to learn some of it right now. Since I do not have enough time to learn from Udemy, I decided to use a handy tool. If you have some experience in programming then you know where this is going. If you guessed W3School, then you are absolutely right.



Entry 2: 29th June, 2020 - Monday - 10:29 AM IST

Before using Node in my local machine, we need to install Node in our machine. I have already done this and there is a video to guide you for this our YouTube channel.



However, right now we can't use node in any other location in Linux. So, now I am going to fix that.


Entry 3: 29th June, 2020 - Monday - 10:35 AM IST

I have now added the path of node (that I moved to home directory) to PATH variable and have tested using my limited knowledge of Javascript and it looks like it is running now even  from a directory that is not where has been installed.

Below screenshot is ti show how I did it.



Entry 4: 29th June, 2020 - Monday - 10:38 AM IST

Check out the below screenshot from W3School.



No doubt on why Javascript is a part of AJAX.


Entry 5: 29th June, 2020 - Monday - 11:10 AM IST

After facing some troubles, I have finally managed to create a server using Node in my local host port 8080 (http://localhost:8080).

I also found out that that this server will keep running till this file keeps running. As soon as I pressed "Ctrl+C" followed by "Enter" the process ended and the server closed.



Entry 6: 29th June, 2020 - Monday - 11:45 AM IST

I thought of trying some HTML using Node, I tried to do so and although it took me around half an hour and several trial and error, but looks like it finally worked out.





I tried the link in this page as well and it seems to be working fine, although, I am pretty sure that there would be a more efficient way of implementing this code.


Entry 7: 29th June, 2020 - Monday - 11:55 AM IST

I also tried the example in W3School for importing and using a user defined module.

I first tried to use import and HTML at around 11:15 AM IST, but it didn't work, so I then tried what I showed in Entry 6 and it worked for me. However, exporting a javascript module and importing and using it did work.


Entry 8: 29th June, 2020 - Monday - 12:10 PM IST

Now I switched from vim to sublime text editor for writing the script. Also, If you have ever used a server side scripting language like say PHP, ASP, JSP, etc., then you may know how they use GET to get a value from url.

Guess how it's don in Node.



Entry 9: 29th June, 2020 - Monday - 12:15 PM IST

Remember how I said in Entry 6 that there must be a more efficient way to run an HTML file  in Node server? Looks like a fount it.




Entry 10: 29th June, 2020 - Monday - 12:30 PM IST

I am finally able to connect Node to MySQL. I already had XAMPP installed in my machine, so I had no issues with that, however, I had to install npm in order to install mysql module. The installation took some time, however, it finally worked.





Entry 11: 29th June, 2020 - Monday - 3:30 PM IST

After learning and practicing a bit more of db connectivity, I finally started working on a small dummy app.

This app is a console app that can Add students in the database and fetch details of all or any specific student from the Database.

It took some time and tons of trial and error, however, the app finally completed.

Here's how it looks like



I started the challenge at around 10:15 AM IST. Looks like I really did it, that too under 6 hours.

I do understand that the app I created and a really a very small one, I also agree that I have definitely not mastered Node. However, 6 hours is not enough even for pro level programmers to master any programming language that they are new to.

Developing this app required me to learn things that I, or any programmer for that matter, would have taken days to master if we learn in a sequence without skipping anything. I had to skip a lot of topics, the ones that were not meant to be used in this app, in order to complete this challenge. However, I did understood the concept of the stuffs that were required for this challenge.

So, was this challenge worth it? Well, definitely yes. This challenge pushed me beyond my limits. Now you may ask "How exactly did that help? What did you accomplished by taking this challenge". Well, I would say "Don't you see, I created a app, even though it's a very small app, but using something that I had no idea about 5.5 hours ago.".

There are times when you need to implement something in your own project but have no idea how to do it. Then you come to know about some tech that can help but you don't know how to use it. If you don't challenge yourself to learn it, then you can never implement what you wanted to.

No matter how tough this challenge was for me today, I definitely had fun.

Comments

Popular posts from this blog

Swap two numbers without using a temporary variable

It's been a while since I've posted any blogs and vlogs. I've been trying to record videos for Planet of Codes Youtube channel, but there's quite a lot of noise whenever I try to record, so I thought why not I communicate through these blogs instead till I am able to record something for Youtube. So here we are, blogging for something that I actually tried to record in the form of a video. Usually in high schools and colleges, when most of us initially learn programming, we get a programming problem to swap two numbers. Usually the solution looks something like the below. num1 = 32 num2 = 87 temp = num1 num1 = num2 num2 = temp print(num1) print(num2) Note: Usually institutions ask students to write this program in C or C++ in first semester, however the above program is in Python, because, It's the logic that matters. This program can be written in any other programming language too. Well, here we are using a temporary variable "temp".  This problem can ac...

Significance of Development and Production Environment for any Application

The concept of the environment that any application runs on was something that I was unaware of as a student. I got introduced to these concept after becoming a part of corporate IT sector. Two of the most important environment are Development environment and Production environment. Of course, there are testing environments like  OAT and UAT environment, but at times these are taken as a sub part of the above mentioned major environments. So now the question arises, "What are  these environment? and why do I need to know about these?". Well, although subconsciously, we all are aware of these, not all of us are aware of how important these are to us and to each other. Development environment is basically the environment where the application is developed and maintained. Any changes that needs to be made to any application are made in development environment as well. The application in development environment could be any application made from scratch or any third party applica...

Project Narutopedia Webscraper

Hello Guys, It's been a while since I have posted something, isn't it?  So, what's up you ask? Well, it happened on Monday, 22nd February, 2021. I was just passing my time, watching a Youtube video on a virtual assistant project. The video was quite impressive to be honest. They even used some package to extract data from Wikipedia. After watching that video, I thought to myself, is there any such package for Narutopedia? Now those of you who know me personally, know how big of a Naruto and Boruto fan I am, so I started to check if I could find one, however, I couldn't find any. I am not saying that there is no Python package for Narutopedia, there could be one, it's just that I couldn't find any. So I thought, "Why not make a simple app that can extract data from Narutopedia for anything we search?". The only problem back then was that I had no idea how to do that. I then started to research and it took only a few minutes until I realized that there i...