Javascript vs c++ 

Friends, have you ever compared a sandwich and an airplane? For some reason many people think that JavaScript and C++ cannot be contrasted because of their different fields of application. With the advent of products such as NW.js or Electron, this problem is slowly changing its direction. Myth one. The use of One way or…

Friends, have you ever compared a sandwich and an airplane? For some reason many people think that JavaScript and C++ cannot be contrasted because of their different fields of application. With the advent of products such as NW.js or Electron, this problem is slowly changing its direction.


Myth one. The use of


One way or another, most programmers see JavaScript as a purely browser-based language, missing the most important detail: JS – a scripting language that is not tied to a single technology. Today, you can use JavaScript to write Web applications (like Angular), mobile applications (like Cordova), describe server logic (like NodeJS), write logic for “smart” devices, and write Desktop applications (like NW.js). JavaScript now is not just a language, it is a tool to do all sorts of things.

Myth Two or “Bias.”


Again, there’s an opinion from somewhere that you can’t write anything serious in JS because a large number of novices use it, writing low quality code. JavaScript has long since evolved from being a language that, at the expense of its simplicity, lets everybody write anything they want. It’s like PHP. The language itself is very powerful and becomes more functional with each release, but because of the old school followers, it continues to be considered bad because of the large number of bad solutions written in it. This is not a problem with the language. I would even say that JS gives such a wide range of solutions that there are not dozens, but many ways to choose from.

Myth three. Brakes


There are some subtleties here too. I think we all remember our first steps on the Internet in the browser Internet Explorer, when everything was slow. For some reason people have long been of the opinion that JS is a slow language, and that it makes no sense to do serious things with it. Meanwhile, from personal experience I can say that JS can be very fast. But it depends on the runtime. Google’s V8 (JS engine) is being actively developed now, which executes code at a pretty fast level. Yes, it is slower than C++, but it’s worth discounting that CSS design and HTML tags take some time to read and render. However, this is if we’re talking about the interface. Without rendering (interface rendering), the code execution speed increases quite impressively. V8 itself is written in C++.

Threshold of entry


Here the story is ambiguous. Someone says that he began to learn the first language C++, someone cite as an example PHP or JavaScript (the majority began to learn with Basic, Pascal, …, yes, yes, do not grumble). Frankly, I do not consider either C++ or JavaScript an easy language. But JavaScript has a great advantage: you don’t really need anything except a text editor and a browser to learn it. Browsers come “out of the box” with a console, and monitoring and debugging facilities. Get it, get to work.

If you begin to learn C++, you will have to get acquainted with the development environment, with compilation tools, with debugging of such an application, and God forbid, you will learn build tools too, you will go nuts.

But, you get used to it very quickly, and then the work becomes as easy as possible. In the process of work you get familiar with the language, you learn a lot about data types, and that you can not mix them, and that what works in JS, here, alas, will lead to a mistake.

Anyway, JavaScript has a lower threshold, due to the assumptions of the language. The absence of a property of an object or class will not cause an error, your script will continue to run, and instead of a value you just get “undefine”, which is also a value. The same situation in C++ will cause a fatal error and stop the entire program. There is also a difference in the requirement of data types, function declarations and so on.

JavaScript vs C++


This is a most incorrect comparison. It is like comparing airplanes and sandwiches. Unrealistic, if only because they are in different categories.

If we look at the general use of languages, JavaScript is still the browser language leader. Remark: because browsers don’t understand other languages. In its pure form. C++ is universal. Literally. And this brings us to the first criterion, which, in most cases, determines the speed of the language.


C++ – compiles into a computer-understandable language.


JavaScript is an interpreted language that executes within an external environment, which drops its performance a bit.


Next, let’s look at the field of application. I should point out right away that these are all conventions, and in reality things can be so different as to be the opposite.C++ can be applied everywhere when it comes to speed. And by “everywhere” I propose to understand it as you read it. If you want, you can write a JavaScript interpreter in C++ (which is already written in it). You can write a browser, a server, a program for any device.

JavaScript is more of a browser based application. More recently (with the advent of NodeJS), just used to describe the server, and already surpassed other languages (and even PHP) in terms of speed when it comes to real-time applications. Although the scope of JavaScript is expanding with each release, both the language itself and the environments in which it can be used. And with the advent of NodeJS it’s possible to write applications for Desktop systems. Although, let’s be honest – in the case of creating a mobile or Desktop application, you create a shell over the browser. That is, it’s still a browser-based application, just with a greater level of access to different contexts.

Next, let’s go into the Desktop application, and before we do, let’s make two more points.


C++ is versatile in any use and allows you to write applications of any complexity and focus.


JavaScript is used to write browser applications, but due to the advanced runtime environments, it is possible to write full-fledged Desktop and mobile applications, servers, etc.


Now about interfaces.

Yes, this is a sore subject for all “Cishniks”. Or is it? There, however you slice it, JavaScript (in combination with HTML and CSS) has an advantage, because every element can be customized down to every pixel, and give reaction to any input events (mouse, keyboard, etc.), and the abundance of elements themselves passes into the hundreds. Also, if some of them are missing, you can create them yourself. In the case of HTML and CSS, the limit on the look of the application is pure fantasy. But with the arrival of CSS3 and HTML5, even this is not a limitation, because the whole Internet – the HTML and CSS, and you can draw ideas from everywhere. The interface part can expand in a positive direction due to the hundreds of libraries that allow to do this. A typical example is jQuery.

In C++, the situation is slightly different. Since we are talking about Desktop, the set of possible elements to use is limited to the library of graphic elements. QtWidgets or WxWidgets. In most cases, they are of course sufficient, since almost all of the programs with an interface are collections of fields and buttons. The visuals in this case are just a set of standard elements.

However, you should pay tribute to the HTML&CSS, the interface, built on it, looks the same on all platforms and operating systems. And you can customize everything – from colors to fonts. If you are not familiar with the flexibility of CSS, please google it. Believe me, you will be pleasantly surprised with the variety of design options.

In general, moving away from cascading tables and widgets, and looking at the format of maximum abstraction, HTML and CSS still win, because they are sharpened to do the design. The standard graphical elements in the widget libraries often have an appearance that is tied to the design of the operating system, and their display is not flexible. Yes, there is QML, which followers of C++ and Qt can use against JavaScript, but no matter how people talk about it, there is no flexibility there. It kind of works, but it’s just a parody.


Building an interface in a JavaScript application is easier, at the expense of CSS and HTML
Building an interface in C++ is more difficult, it is more tied to the libraries and difficult to extend.


The possibilities of the languages are also different, but as has been said many times before, JavaScript does not have its own functionality, but only uses what the environment provides. And, in this respect, it is very good.

What functionality is usually needed when developing Desktop applications: interface organization, input/output processing, file access, possibly database and network access, multimedia, and that’s about it. Of the basics, that’s about it.

C++, of course, has facilities for organizing any level of functionality, full file access, access to OS systems, and… an infinite number of options.

JavaScript, on the other hand, has long been limited in this respect, and has only recently begun to reveal itself as a language for writing Desktop applications. I have visually told you about the NW.js technology here, so I think I will not repeat myself.

Together, the combination of NodeJS and Chromium gives full access to all parts of the OS, and the ability to use NPM packages brings the functionality of programs to the level of applications in C++ in terms of interaction with the OS. Moreover, you can put some parts of your applications into modules in any language and use them inside your own application (google child_process in NodeJS).

Regarding syntax, there are pros and cons to both. In general, C++ and JavaScript look similar in terms of syntax. And the keywords are inevitably similar because both languages are “C-like”, that is, they both have the same syntactic roots. However, when it comes to special cases and solutions (e.g. classes), the difference is already visible. Although, with ES2015 (current actual specification), there are very similar C++ code constructs describing class functionality.

The bottom line is this.


JavaScript is a wonderful language. It can do things of any complexity, and the NW,js shell gives it access to all the auxiliary systems and services of the OS, and its capabilities extend to infinity. And HTML + CSS turn interfaces into works of art.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *