Skip to main content

Posts

My Experience in RBK

Recent posts

Compiler vs Interpreter

Programmers/developers alike write programs using computer languages that usually are close to human languages. These languages are called High Level Languages like Java, C++ and C#. But they differ in the way they execute their code; some of them are compiled and the rest are interpreted. Compiled languages take the entirety of the file and compile it as a unit. It takes takes time and generates errors after scanning everything. But that's not the case with interpreted languages, where they translate code statement at a time and memory efficient since there's no need to generate  an intermediate object code.

Git rebase vs Git merge

While working with git and github one will always face the need to combine their changes with the master branch of the team repository. to do this we have two solutions; we either use git merge or git rebase. To explain the differences between these two options we are going to consider the following example, you start working on feature branch for the sidebar of your website and other team members are updating the master branch with new commits. This will result in forked history as shown in the picture below. Merge: We can do the easiest option which is merging the master branch into the sidebar branch with this git command: git merge sidebar master This will create a new commit for the merge that connects both of these two branches, giving what looks in the picture below. So as you have seen merging is easy and really simple to work with. It's also a non-destructive operation; by this I mean that the already existing branches are not changes in any way. 

ES6 vs. ES5

ES stands Ecmascript which the standard that JavaScript was build on top of. ES5 was released in 2009 (ES2009) and ES6 was released in 2015(ES2015), so this means that it took the committee in charge 6 years to release an update to the language. That update was massive; mainly because version 4 was skipped. ES6 brings a lot of great features to Javascript that developers have been long waiting for.

Callback Hell

Before jumping into the topic of this blog I'm going to first talk about how it came to existence in the first place. While developing applications (web in general) and especially on the backend, we always face that need to make asynchronous calls to do stuff once others finish. And to solve this issue developers usually used nested functions also known by callbacks. While it solved the problem it still caused what is known by callback hell. Callbacks don't scale and are not good practice as far as I know. We can fix this issue and write better and readable code that works asynchronously but looks synchronous with the use of promises.

Big O Notation

Big O Notation is a mathematical expression that describes how much time an algorithm takes to run according to the size of it's inputs; mostly concerned about the worst case scenario. Types: 1- Constant Time O(1): On this order, regardless of the number of items, the iterations(time) are constant. Example: const getFirstItem = items =>    items[0]; getFirstITem([1, 2, 3, 4]);  // 1 (one iteration) getFirstItem(['b', 'd', 'g']);   // 'b' (one iteration) 2- Linear Time O(n): On this order, the worst case grows with the number of items. Example: Javascript's built in function indexOf, it loops over an array to find the  correct index of the passed element. The worst case is looping over the whole array. [1, 2, 4, 9, 23, 12].indexOf(12); 3- Quadratic Time O(n ^ 2): For this order, the worst case time is the square of the number of inputs. It grows exponentially according to the number of inputs. Example: Using nested loo

NodeJs Working Mechanism

Nodejs is an environment built with Google's V8 engine to run javascript code outside of the browser (i.e in the server side). It is single threaded unlike other server side technologies like Java and PHP. They open new threads for each request; but with Nodejs all of this happens on a single thread with even shared resources.  All of the operations that a developer does on a server built with Nodejs happen asynchronously and that means it does not take a specific amount of time. So, to work this method we use something called callbacks; which are anonymous functions that we pass to a function so that it will be executed once the first function finishes executing. ┌───────────────────────┐ ┌─>│ timers │ │ └──────────┬────────────┘ │ ┌──────────┴────────────┐ │ │ I/O callbacks │ │ └──────────┬────────────┘ │ ┌──────────┴────────────┐ │ │ idle, prepare │ │ └──────────┬────────────┘ ┌───────────────┐ │ ┌──────────┴────────────┐ │