Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

I think you are too optimistic. Even today C++ is probably the best choice for writing a general purpose browser from scratch.


sort by: page size:

Opinions like this makes me want to create a new browser engine just to be contrary. And because the web deserves something better than C++.

Right, Browsers too are written in c++ for the most part

Yes. All the popular browsers are mostly C++ for example.

Yet the 'modern web browsers' we're all using are probably written in C++.

I'm yet to see a 'modern web browser' that is fully written and only written in C. (C bindings don't count)


Maybe a more interesting question is: Would you use C/C++ to develop a browser today?

Most browsers are developed in C++ because for the timeframe in which the projects started, C++ was the performant answer

Changing languages is not a magic bullet. Browsers written in C++ can be just as safe and maintainable -- especially with the resources of large companies behind them, with tons of engineers and testers etc.

In 2013 I don't think it has anything to do with the merits of C++ vs other languages. You can surely write a better browser from scratch in a language like Haskell; a project this important could even implement their own JVM if they want to use Scala and need to guarantee some performance characteristics. Like how Facebook wrote their own PHP compiler/optimizer.

A browser that breaks on non-standard markup is worse than useless. Legacy compat is so critical and so complex that a rewrite is just not an option. Lots of money and time is invested in battle-tested security etc, you can't just throw that investment away. Again, like how Facebook is still written in PHP.


lol - you're aware that most web browsers are written in C++?

So which web browsers are not written in C++?

Alternatives to C++ are not universally slow for browser engines. I have first-hand experience here :)

Neither of you are really answering the question. You still haven't proposed a language is better.

When the half dozen browsers that represent about 99.9% of the browswer market all use C++, perhaps the explanation is not "They're all wrong."


That's the point. Languages lining up to become the C++ of the web is actually a better way of looking at the field.

I agree with you about the project being a joy for the developers.

But as a user, in no way I would rely on a browser started in 2020 written in c++ (or in zig, given other comments about its security characteristics). Keep in mind that gecko/webkit were written initially in c++ because c++ was the best language available at the time for these projects. This is not true anymore.


This is true, but consider that today we are using computers fo to run tasks much more complex than 30 years ago. Rendering a complex HTML page with CSS and Javascript is an herculean and time-consuming task, which is why Firefox and Chrome are written in C++; and don't forget deep learning!

Plus, low-level languages like C are sometimes the only way to go if you are writing for embedded systems with slow CPUs.


Not everybody wants “Scheme in the browser”. In the spirit of “Worse is Better”, plenty of people want to run C++ in the browser. I’m not one of them, but hey, whatever floats your boat.

That said, I’d like a few useful libraries (e.g. - fixed precision decimal arithmetic) written in web assembler. But otherwise, I actually prefer writing in JavaScript (as FP more than OOP) over C++/Java/C# (degenerate Simula 67 clones) for most application level tasks.

Writing in C++ won’t make DOM access or async I/O go away, though :-)


Off the top of my head, any of these would have been a much more sane choice: Standard ML, Ada, Java, concatenative languages, E, Lisp, Haskell, Erlang, Python.

> few people (including me) would accept a "security upgrade" which made my browser significantly slower and memory hungry.

I can't tell if this is a joke. You know practically website is constantly running the shittiest JS you can imagine (and sometimes Actionscript), right?

Even if the language somehow can't handle implementing a certain task efficiently, you could still make a separate OS process for say, decoding the video stream, and passing it back to the safe code.

If you think there is a technical reason that browsers/OS today are written in C/C++ you are wrong. The reasons are purely circumstantial. Also note that most C/C++ coders aren't aware that other languages even exist or are practical, so good luck getting them to switch.


People who don't know say these things. Try writing web applications in C/C++, it's a deluxe development situation. Where do you think web browsers come from? Everyone afraid of C/C++ are shooting themselves in the feet.

I wonder what advantages choosing C++ to write web apps would bring. At the end of the day it's all JavaScript so performance is rather moot point.
next

Legal | privacy