Node.js

In my previous article, I was talking about Node.js and why it’s fast. Today, I want to talk about V8.

I suppose some of you heard that JavaScript executes as fast as C++. Some of you don’t understand how it’s even possible. JavaScript is a dynamically typed language with Just in Time (JIT) compilation, when C++ is static-typed language with Ahead of Time (AoT) compilation. And somehow, optimised JavaScript code executes a little slower than C++ or even with the same speed.

To understand why that is, you need to know some basics of V8 implementation. It’s a huge topic, so I will only explain key features of V8 in this post. If you want more details, such as hidden classes, SSA, IC,… they will be in my next article.

Read Full Article

Happy New Year! I’ve finished Advent of Code and want to share my solutions with you. Of course, some solutions can be improved; I don’t claim these to be the best solutions possible.

When I started playing this game, I decided to write one paragraph with a solution and explanation to it. But you can see that I went a little further with that…

TL;DR: This isn’t really an article, more like a collection of gists with explanations. All of the solutions are available on my GitHub if you just want the code.

Read Full Article

Here I am again with an article about Node.js! Today I want to speak about another Node.js advantage — execution speed. What do I mean by “execution speed”?

It can be anything ranging from calculating Fibonacci sequence to querying database.

When talking about web-services, execution speed comprises everything that is needed to process requests and send the response to the client. That’s what I mean — time spent on processing request, starting from opening connection to client receiving the response.

As soon as you understand what’s going on in Node.js server when it processes the requests, you will realise why it is so fast.

But before talking about Node.js, let’s look at how request handling is done in other languages. PHP is the best example because it is popular and unoptimised.

Read Full Article

TL;DR If you are not interested in reading the post and want to see the results, check out my repository — generator-sails-rest-api.

Otherwise, let’s dive into terminology before reading. I want to be sure you understand terms and what I’m talking about.

What is REST API?

Let’s look at Wikipedia:

In computing, Representational State Transfer (REST) is the software architectural style of the World Wide Web. REST gives a coordinated set of constraints to the design of components in a distributed hypermedia system that can lead to a higher-performing and more maintainable architecture.

Building RESTful web services, like other programming skills is part art, part science. As the Internet industry progresses, creating a REST API becomes more concrete, with emerging best practices. As RESTful Web services don’t follow a prescribed standard except for HTTP, it’s important to build your RESTful API under industry best practices to ease development and simplify client adoption.

As Wikipedia said above, “REST is the software architectural style”. It’s not a library you can install and work with. It’s just a bundle of rules you need to follow when writing your web service.

Read Full Article

Hi everyone! My name is Eugene Obrezkov, and today I want to talk about one of the “scariest” platforms — Node.js. I will answer one of the most complicated questions about Node.js — “How does Node.js work?

I will present this article as if Node.js didn’t exist at all. This way, it should be easier for you to understand what’s going on under the hood.

The code found in this post is taken from existing NodeJS sources, so after reading this article, you should be more comfortable with NodeJS.

Read Full Article