Role of C++ in Modern Web Apps

C++ is the high performance programming language for developing core system programs including memory management, file handling, networks etc, While JavaScript is used for developing UI rich applications for both web and mobile platforms. 

The world is moving with fast access applications and i think both C++ and JavaScript can play a key role over here.

Most of the super apps are developed using JavaScript based libraries like React, Angular etc. Combining C++ into these apps will make the back-end operations very fast. We can make back-end C++ dll’s and link the front-end JavaScript using Nodeffi(link below) or other interface libs.

A little Intro about C++

Bjarne Stroustrup, developed C++ in early 90’s. C++ is supported by large foundations and it has evolved from C++98 into C++19 following the ISO standards. Learning common C++ concepts is easy, but we have to dig deep into its architecture to know well about how complex programs works. Please find some useful C++ resources added below. 

How C++ Works

C++ program, like Pascal or Java is a user defined language. A computer compiles C++ into an assembly language which can be understood by the CPU. 
C++ Test Program: Hello.cpp
#include <studio>
void main ()
{
cout <<”Hello world”;
return 0;
}
Compile the code: g++ -o Hello Hello.cpp
g++ is the main compiler and it creates an object file called Hello.o. The object file consists of assembly code. Finally we execute the run command like, ./Hello which runs the program into output as “Hello World”.

Memory & Bytes

A collection of 8 bits is called a byte and (on the majority of computers today) a collection of 4 bytes, or 32 bits, is called a word. Each individual data value in a data set is usually stored using one or more bytes of memory, but at the lowest level, any data stored on a computer is just a large collection of bits.
A computer memory represents files, pictures, videos etc., is stored in the form of Bytes(KB, MB, GB etc). A picture is a group of pixels with 3 different colors(Red, Green and Blue) and each color occupies 1 byte. So a single pixel occupies 3 bytes with a total of 24 bits.

Built-in Data types
int, char, double and bool are the 4 built in data types defined by the compiler itself. All other types are defined from the above 4 data types.

Naming Convention
Int numberOfCars; or int number_of_cars; are the 2 basic naming conventions in C++.

Implicit Conversions
Operators ‘+, -, *, /’ works on different types like int, float, double etc. But ‘%’ operator works only with same type like int, int or float, float etc.

Assignment Operator
Int j = 3 + (i=5), here i is assigned into 5 and the sum of j = 3 + 5 = 8.

Operator Precedence
The compiler normally provides the operator precedence from left to right. Example: 3 + 4 * 5 + 4 * 9 will be like 3 + (4*5) + (4*9). 

Pointers & Arrays 
Pointer variable holds the address of another variable. Pointer and Arrays works in the same way, but in different ways. Pointer works in heap memory while Arrays works in static memory. 
int arr[] = {1,2,3,5,6,7,8,9,10};
int *ptr = {1,2,3,5,6,7,8,9,10};
int pos = arr[3];
int pos1 = *(ptr+3);
Both returns the same value, but in different ways. 
sizeof(arr) can be found during compile time and it gives the total size of values stored in it. 
sizeof(arr) = 40 bytes(each integer value holds 4 bytes, so 10 values equals 10 * 4 = 40 bytes).
sizeof(ptr) returns just the size of the first pointed value and it can be found only during run time, not compile time.

Some of the best C++ JavaScript technologies to learn are as the following.

Boost – www.boost.org
MingW/Gcc – www.mingw.org 
Nodejs/Reactjs – www.nodejs.org / www.reactjs.org 
Lodash – www.lodash.com
Nodeffi – www.github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial

Be the first to comment

Leave a Reply

Your email address will not be published.


*