7 ms·
>Why build a new browser in C++ when safer and more modern languages are available? >Ladybird started as a component of the SerenityOS hobby project, which onl
by dbcooper 2y ago
>Why build a new browser in C++ when safer and more modern languages are available?
>Ladybird started as a component of the SerenityOS hobby project, which only allows C++. The choice of language was not so much a technical decision, but more one of personal convenience. Andreas was most comfortable with C++ when creating SerenityOS, and now we have almost half a million lines of modern C++ to maintain.
>However, now that Ladybird has forked and become its own independent project, all constraints previously imposed by SerenityOS are no longer in effect. We are actively evaluating a number of alternatives and will be adding a mature successor language to the project in the near future. This process is already quite far along, and prototypes exist in multiple languages.
- richardwhiuk 2y agoSo half a million lines of tech debt?
- vaylian 2y agoI think that's too pessimistic. The code is there and it can be used to push the project forward. If some part of it is not good enough, then an alternative implementation can be created (potentially in a different language)
- neocritter 2y agoA classic: https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/ https://www.joelonsoftware.com/2000/04/06/things-you-should-... >> "The idea that new code is better than old is patently absurd. Old code has been used. It has been tested. Lots of bugs have been found, and they’ve been fixed. There’s nothing wrong with it. It doesn’t acquire bugs just by sitting around on your hard drive." >> "Each of these bugs took weeks of real-world usage before they were found. The programmer might have spent a couple of days reproducing the bug in the lab and fixing it. If it’s like a lot of bugs, the fix might be one line of code, or it might even be a couple of characters, but a lot of work and time went into those two characters." >> "When you throw away code and start from scratch, you are throwing away all that knowledge. All those collected bug fixes. Years of programming work." It's an older piece, but like good old code, it still holds up. Newer tools and technology have improved the creating of new code, but they've also made improving old code easier in equal measure.
- noduerme 2y agoThe only exception is if you have 500k LOC in a language whose runtime is going to be deprecated on all platforms overnight. I'm referring to the uh, retrospectively unfortunate decision I made in 2007 to start building large scale business app frontends in AS3. I guess I should be thankful for the work, having to rewrite everything in TS from scratch a decade later. (At least the backends didn't have to be torn down).
- neocritter 2y agoThere's a parallel universe where someone convinced you to rewrite it in something else from the start and you spent years on the rewrite instead and it never went anywhere. Could you have done that emergency rewrite without 10 years of becoming an expert in the problem you were solving? The alternative universe has you spending time becoming an expert in a new language instead and maybe not getting anywhere with the rewrite.
- noduerme 2y agoTotally true. Spending years fine-tuning the business logic and UIs made the eventual rewrites a lot cleaner and faster, having already iterated many times over the years and discovering what worked and what didn't. And learning TS after AS3 was easy enough. The real pain point was switching from a paradigm in which I owned the screen graph down to the pixel-level placement of each component, to a trying to wrangle similar behavior from a mix of DOM elements, relative/absolute positioning and arbitrary stuff drawn into canvases. Particularly for things like interactive Gantt charts and some of the really complicated visualization components that had been a relative pleasure to design and code in Flash. But yeah, it was much easier to learn a new language paradigm knowing exactly what I needed to implement, rather than having to devise the logic at the same time.
- Tade0 2y agoI wonder how many businesses suffered the same? I remember Flash as a complete, straight-to-business platform that allowed me to just focus on getting stuff done. It was a sound decision back then.
- ramon156 2y agoWould another language have avoided this?
- wiseowise 2y agoIf we go by parents definition of “C++==tech debt”, then yes.
- chx 2y agoNothing but Rust is safe from being attacked by the Rust zealots. It's been extremely annoying these last few years.
- richardwhiuk 2y agoThis was more C++ versus "we haven't picked what we are going to write this in"
- skywal_l 2y agoJakt[0] was being developped by Andreas at some point. It seems stall for now. [0] https://github.com/SerenityOS/jakt https://github.com/SerenityOS/jakt
- alkonaut 2y agoNice to see. The only thing that would meaningfully set it apart from the others would be to have a core that isn’t a big ball of C++. That would potentially allow it to be developed and maintained with less resource than the other browsers, and that would be the only way this ever reaches any kind of impact.
- fregonics 2y agoIf I'm not wrong Firefox is already Rust. The language was even created inside Mozilla.
- kobalsky 2y agoOnly around 11% of it is Rust according to https://4e6.github.io/firefox-lang-stats/ https://4e6.github.io/firefox-lang-stats/ , which by the way is no small feat given how huge the code base is.
- deleted 2y ago[deleted]
- alkonaut 2y agoIt is. They realized that writing a modern browser (i.e. one that for example uses multiple cores efficiently by doing layout/rendering/etc in parallel) is almost impossible in C++. To the point where creating a whole new language just to solve the problem would be a smaller undertaking. Which says something about the scope of this problem. And I really do think they are right.
- tombert 2y agoWhy is it almost impossible? I'm a little out of practice with C++ but I thought the modern C++ features were considered pretty solid in regards to memory safety and the like?
- nicebyte 2y agoc++ isn't memory safe and will probably never be. that being said, it's not more or less possible to create an efficient browser engine for multicore systems with c++ than any other language. programming language is not the thing that makes the task difficult.
- Sammi 2y agoAlso the web standards themselves are written in an object oriented style. Using a non oo language like rust is therefore an uphill battle where you end up fighing against the language. The web standards just lend themselves naturally to be implemented in an oo language like c++.
- pjc50 2y ago?! Rust is roughly equally as OO as C++ is. Which is not surprising given its aim to replace C++. https://doc.rust-lang.org/book/ch17-00-oop.html https://doc.rust-lang.org/book/ch17-00-oop.html
- Sammi 2y agoRust does not make it simple or easy to reference objects from objects. You will be fighting the borrow checker if you try. This is what I mean. The web standards have lots of references between everything. This type of object oriented programming means having lots and lots of cycles in your object graph. This makes Rust very veeeery unhappy. The Servo people are trying, and they have been trying for a looong time...
- r3trohack3r 2y agoI don't understand, isn't this what Arc is for? An "automatically garbage" collected pointer? Or is it not well behaved for this use case (i.e. blowing the stack on free)
- rddbs 2y agoArc is an atomic (not automatic) reference counter which can be used across threads. Reference counting in general can still be tricky to use when you need cyclical references though, which is what it sounds like the spec has.
- Avamander 2y agoTrue, but the patterns allowed on the web (or in GUIs for that matter) are incredibly painful in Rust. There was a nice article about the GUI part: https://www.warp.dev/blog/why-is-building-a-ui-in-rust-so-hard https://www.warp.dev/blog/why-is-building-a-ui-in-rust-so-ha... These points are even more painful with web standards.
- guywithahat 2y agoI kind of hope it stays with C++. C++ has been around for decades and is the gold standard for large performance applications, if they used python like many open source projects I worry it would be too slow, and rust feels like a fad
- galangalalgol 2y agoLet us hope it is not a fad. It is already in the windows kernel, android, and chrome in addition to Firefox. MS, google, and the NSA have all said to stop using languages like c and c++.
- sgt 2y agoWill Jakt be used as a C++ replacement long term? Going Rust for Ladybird is probably too far fetched given the sheer amount of C++ code. And also, Jakt seems to solve the memory safety problem while still giving C++ performance.