Hacker News new | ask | show | jobs
by andrepd 4048 days ago
Makes me wonder, as a non-web developer, would it be possible in principle to develop for the web in a low-level language like C/C++? What I mean is, is it only impractical and inconvenient for the developer, or is it fundamentally impossible?
4 comments

Your javascript is JIT-compiled and can be extremely fast (see asm.js). Conversely you can have extremely percieved-slow C++ applications (giant office suites etc.). It's not the speed of the language. This is like rookies swapping out multiplications for logical shifts and thinking it should make a big difference. It's the computational complexity.

What would "develop for the web in a low-level language" even mean? An assembler interface to the DOM isn't going to help.

The problem is the computational complexity of the task. Every CSS rule has potentially to be re-applied to every DOM object every time you change anything. Especially the sizing and layout ones. Because they're all interdependent, paralellism won't save you here. By comparison, games are so fast because pixels can be parallelised.

You could build an alt-web if you had a suitably sealed VM running code in any language with access to the rendering portal and a security-enforcing network abstraction. This was what Java applets were supposed to be, and Flash is somewhat, but they had three problems:

- fixed size: ability to cope with resize or different devices not built in

- not as secure as hoped (javascript-to-local-user exploits have been very rare by comparison)

- too slow to start up and too willing to hog resources when they did.

It's certainly possible today with emscripten. And, for an old C++ fart like me, it's rather tempting. I'm not saying it's advisable though...
Javascript as an abstraction allows developer to have a significantly lower skill level. Remember designer that was upset that she was presented with a FizzBuzz on an interview, which she couldn't solve? She can write websites in Javascript, and actually provide value for people.

And this is not only about the beginner developers. I'm a game developer myself, and I use garbage-collected C# with Unity engine instead of pure C++. This means that my games won't have performance or graphics of Human Revolution, but I'm able to prototype and change game logic much faster.

Definitely possible, but it's up to you whether or not you're willing to take the time to do it.

Modern web apps "deploy" nicely and play well with modern OSs, but at the end of the day you're downloading a bunch of code and running it. Nothing says you couldn't have an OS that downloads compiled binaries and executes them for your web app. A browser just makes it easier to design a page with clicky buttons and text boxes.