DEV Community

Discussion on: What Does C++ Do That Rust Doesn't?

Collapse
 
angularnodejs profile image
AngularNodeJS 🚀 • Edited

Javascript and Web ASM is going to kill this debate of what language to use in the near future as the JS Engine will move out of the browser and become native with cross-platform support and access to native OS APIs.

When in doubt, always bet on Javascript!

I coded in C++ for 10+ years, I don't miss it, it's too low-level and suffer from having to write tons of your own code. Rust, I've been told is not a simple language to learn for most web programmers. So forget adoption from web developers.

I personally wouldn't waste my time learning Rust as much as I don't care for C++ and how unproductive that language is. I'll just wait it out and be super productive in JS writing native cross-platform code compiled to Web ASM.

Here is a nice talk about what's coming: youtube.com/watch?v=Qn_4F3foB3Q

Collapse
 
deciduously profile image
Ben Lovy • Edited

Interesting take.

not a simple language to learn

Nor is C++, but lots and lots of people have anyway.

forget adoption from web developers

Perhaps, but I don't think web developers make or break the issue here. AssemblyScript and such projects do seem interesting, but I am curious if they will be adequate to completely replace lower-level languages used to produce WASM today. WASM is a low-level concept, and having a more granular level of control in the source language is often a good thing here. Writing all your WASM in a language that lacks facilities for this might work for some domains, but I'm not convinced you can blanket-replace C++/Rust here with something like JS. I could very easily be wrong, but while JS can product WASM, can it actually produce highly optimized, tightly controlled WASM?

I don't think every developer will need this, most applications will be perfectly happy without it, but I do think some of us will.

All that said, too, while I agree WASM is game-changing tech, it still only addresses a subset of where C++ proliferates today. I think this is only addressing one part of the tool.

Collapse
 
angularnodejs profile image
AngularNodeJS 🚀 • Edited

Yes WASM bytecode will be highly optimize, both using static analysis and dynamic branch-prediction as done in V8 Engine and SpiderMonkey JS Engine. Even right now execution time for hot-optimize JS is close to C++ code.

Here is a talk from Google JS vs C++: youtube.com/watch?v=aC_QLLilwso

The Moz technical committee along with other peoples are working on defining low-level system APIs that will be uniform and standardize. We will get true cross-platform support.

The main point is, we will finally have cross language interoperability. I will be able to use Python modules, or C/C++ libs with my JS code and likewise other language will be able to use NPM module. Basically everything will be compiled down to a WASM package, module or whatever they end up calling it.

JS with WASM will never replace something like C/C++/Rust for low-latency system coding, but how many people code drivers? or ultra low-latency systems? The typical developer will want to code some application or server most of the time. Most all will go with the easier dominant programming language to code in. Even the hype train at Mozilla for Rust has died and they stop pushing Rust as the language for the web.

WASM is going to be game changer, both in and out of the browser. Most likely you won't notice any changes, as new build tool and do the compiling for you.

Thread Thread
 
deciduously profile image
Ben Lovy • Edited

Points all well taken, but I want to code drivers! And compilers, and kernels. If I could do so in Rust, I'd be much happier than in C or C++.

There are many, many types of programming.

I will be able to use Python modules, or C/C++ libs with my JS code and likewise other language will be able to use NPM module.

Right with you there. WASM is a game changer. I'm just not sure that makes Rust a waste of time...maybe even the opposite.

Thread Thread
 
angularnodejs profile image
AngularNodeJS 🚀

Let me take that back What I meant to say is, knowing what's coming, there is no reason to switch to different programing language. They will all run at "almost" the same speed as WASM bytecode.

Sure if you want to re-write the OS in Rust, then that might be a project you want to take on. It won't be any safer or bug free.

Whatever you do, never ask Linus why Linux is coded in C and not C++ :-D

harmful.cat-v.org/software/c++/linus