News for hackers. Stuff that matters.
Re:How Browsers Lay Out Web Pages by chakspak on Monday April 05, 2021 @11:56PM (#26707806)
This tutorial looks amazing. I know what I'm going to be doing the next few weekends.
Re:How Browsers Lay Out Web Pages by mjgs on Tuesday April 06, 2021 @06:14AM (#26710113)
It’s such a great idea for a book!

I quite like Python but really I want a version all written in NodeJS, so it’s javascript all the way down :)

Re:How Browsers Lay Out Web Pages by pavpanchekha on Tuesday April 06, 2021 @10:36AM (#26712285)
Hi mjgs. I'm one of the book's authors, and we debated this quite a bit. The reasoning for using Python is written up here: https://browser.engineering/blog/why-python.html

That said, it's pretty easy to follow along in JS if you really want and in fact... Stay tuned, there'll be an update in this space very soon.

Re:How Browsers Lay Out Web Pages by mjgs on Tuesday April 06, 2021 @07:55PM (#26718853)
Thanks for the reply. I like that you’ve chosen a scripting language, it makes the book much more accessible. If it were in c / c++ / rust etc, I would never read it.

Thanks for sending the writeup of why you chose Python.

As for javascript readability issues, IMO those are non-issues and actually in some ways beneficial to have one language, no need to context switch.

The web workers issue is perhaps a problem, but maybe it makes the implementation easier, even if it doesn’t look much like real browsers?

I don’t understand the networking issue you highlight, you can build any networking functionality using NodeJS, it’s actually very good in networked application settings.

With so many people that write code online in javascript, the book would be so much more accessible. It would be a great compliment to the Python version or any C / C++ version.

I’m interested to hear your update, what’s the best way to get that automatically?

Re:How Browsers Lay Out Web Pages by mjgs on Tuesday April 06, 2021 @08:24PM (#26719060)
One other thing...this passed by in my feeds last week, I’m not an expert in web workers or browser threads etc, but it seems like it might be relevant, so sharing it just in case:

“A fast, efficient Node.js Worker Thread Pool implementation”

https://github.com/piscinajs/piscina

Re:How Browsers Lay Out Web Pages by csbartus on Tuesday April 06, 2021 @03:05AM (#26708917)
Right! I'm working with the web since 2006 but still I find this book a must to read.
Re:How Browsers Lay Out Web Pages by bckr on Tuesday April 06, 2021 @12:07AM (#26707856)
Yes! Apparently it's still being written.... and I NEED them to get to the CSS bits.
Re:How Browsers Lay Out Web Pages by pavpanchekha on Tuesday April 06, 2021 @10:37AM (#26712296)
Book author here. A basic styling engine is the very next chapter, so it should be out in about two months, depending on how the writing process goes.
Re:How Browsers Lay Out Web Pages by bckr on Tuesday April 06, 2021 @11:49AM (#26713348)
Incredible, thank you!

I believe expanding the simple version into a decently robust rendering engine will be the ultimate way for me to learn CSS.

Thanks so much again!

Re:How Browsers Lay Out Web Pages by ronsor on Tuesday April 06, 2021 @12:26AM (#26707952)
No doubt I'll do something crazy, that is, try to implement this in C.
Re:How Browsers Lay Out Web Pages by peterkos on Tuesday April 06, 2021 @02:16AM (#26708531)
I was going to > inb4 rust!, but, isn't Gecko built in Rust?
Re:How Browsers Lay Out Web Pages by KwanEsq on Tuesday April 06, 2021 @06:47AM (#26710326)
The style parts are in Rust, but layout is C++, I believe. servo does have an experimental layout engine (or two? layout 2020?) in Rust, but I don't think that ever reached a point where Mozilla were seriously considering replacing Gecko's with it.
Re:How Browsers Lay Out Web Pages by timw4mail on Tuesday April 06, 2021 @08:52AM (#26711157)
I think Servo is basically a proving ground for replacing components in Firefox with Rust equivalents.
Re:How Browsers Lay Out Web Pages by ronsor on Tuesday April 06, 2021 @02:29AM (#26708644)
Gecko is (mostly, at least) traditional C++. Servo is written in Rust.
Re:How Browsers Lay Out Web Pages by amelius on Tuesday April 06, 2021 @06:14AM (#26710121)
Would Rust be the best choice of language, given all the back pointers (previous, parent)?
Re:How Browsers Lay Out Web Pages by timw4mail on Tuesday April 06, 2021 @08:54AM (#26711177)
Trees are not that bad in Rust, it's when you have a cyclical structure that Rust is really difficult.
Re:How Browsers Lay Out Web Pages by amelius on Tuesday April 06, 2021 @11:14AM (#26712825)
Yes, that's what I meant by "back pointers". In the article, every node has a parent pointer and a child pointer (or several). You can't have both of these pointers without introducing cycles.