Hacker News new | ask | show | jobs
by kavefish 416 days ago
With decades and decades of memory safety lessons in the books, it's hard to imagine how C++ was the language of choice when starting new browser from scratch in 2018.
4 comments

The browser was not started with the idea of taking over the main focus of development, it was just another part of an already pretty large hobby OS project
Fine. With decades and decades of memory safety lessons in the books, it's hard to imagine how C++ was the language of choice when starting new operating system from scratch in 2018.
It really isn't that hard to imagine someone starting a fun hobby project in the language they enjoyed and were the most comfortable with.
Dunno. It really is. Debugging memory corruption bugs in complex one-memory-space systems is very much not fun.
Nothing a little printf (or dbgln as it is known as in Serenity-Ladybird land) can't fix
Answer is here, although the article is outdated and the most recent news is that they are rewriting the browser at least in Swift.

https://awesomekling.github.io/Memory-safety-for-SerenityOS/

How is it outdated??

Their GitHub has 0,3% Swift code. They said they start once Swift 6 is out. It has been out for months. So either they abandoned Swift or haven’t really started or they are really really slow to start using it. All three options are against the article being outdated, wouldn’t you agree?

One of the primary Ladybird devs just gave a lightning talk at CppCon about porting their HTML parser from C++ to Swift.

https://www.youtube.com/watch?v=KCRx1jE6DnY

Current blockers to swift usage are found here: https://github.com/LadybirdBrowser/ladybird/issues/933 Rising tide lifts all boats, by trying to use Swift seriously, they're finding and helping fix bugs in the compiler
Because the article is from 2022 and says that they will use a custom language called Jakt which didn't pan out, it seems. Yes, I am also eager for the Swift rewrite to get off the ground.
Mostly because the author switched focus to yet another language, and eventually decided to focus on something else instead of programming languages.

https://github.com/sophiajt/june

When they started, the plan was mostly to have fun and see how far you can get when creating an OS from scratch. So picking a language in which they are experienced makes sense in that context.
One would think the same of C, where exploits trace all the way back to Morris worm in 1988, that is 36 years of thinking the problem are the developers, not the language, with new projects being started every day still.

At least C++ has mechanisms to write safer code, provided one makes use of them, even if still there are issues.

To use a modern example renaming the JavaScript file extension to a Typescript one, only gets you so far.

Then one can make use of Typescript's type system, or switch to Elm to the next level.

> One would think the same of C

I'm pretty sure that everyone does and did, because almost nobody wrote a browser in C either, never mind in 2018.

NetSurf from 2002 is the only one I can find?

edit: I should say after the first set, because Lynx and Mosaic are C.