8 ms·
Web Browser Engineering (2021)
- keepamovin 2y agohey, this book looks cool! well done :)
- pavpanchekha 2y agoThanks!
- asicsp 2y agoSee also this previous discussion: https://news.ycombinator.com/item?id=28898157 https://news.ycombinator.com/item?id=28898157 (409 points | Oct 19, 2021 | 63 comments)
- dang 2y agoThanks! Macroexpanded: Web Browser Engineering: Scheduling tasks and threads - https://news.ycombinator.com/item?id=30336408 https://news.ycombinator.com/item?id=30336408 - Feb 2022 (3 comments) Web Browser Engineering - https://news.ycombinator.com/item?id=28898157 https://news.ycombinator.com/item?id=28898157 - Oct 2021 (63 comments) How Browsers Lay Out Web Pages - https://news.ycombinator.com/item?id=26707368 https://news.ycombinator.com/item?id=26707368 - April 2021 (50 comments) Web Browser Engineering (A Book) - https://news.ycombinator.com/item?id=24055748 https://news.ycombinator.com/item?id=24055748 - Aug 2020 (1 comment)
- bberrry 2y agoI'm so incredibly thankful that there are people like Pavel and Chris putting effort into articles like this. You are truly the best of us
- andai 2y agoThe author's post explaining why Python was chosen: https://browserbook.substack.com/p/why-python https://browserbook.substack.com/p/why-python Apparently some of it now runs in the browser ("in the book itself") by compiling Python to JS? https://browserbook.substack.com/p/compiling-python-to-js https://browserbook.substack.com/p/compiling-python-to-js
- globalnode 2y agowriting it in python makes me actually want to read the book, in fact i definitely will give it a read. if it was done in rust or go id probably skip it, and c++ is just too hard to look at for a fun project. will come back after reading and hopefully have something more meaningful to say about it.
- CrayKhoi 2y agoI've been levelling up on browser internals, and this book is awesome. It helps build up intuition on how browsers work, without going through the millions of lines of chrome code.
- mananaysiempre 2y ago[flagged]
- kaptainkarl 2y agoAs a native English speaker, yes that is kinda weird to be "incredibly irritated" by a sentence that's completely normal and well constructed.
- mmkos 2y agoWith all due respect, this feels better suited as a journal entry rather than a comment on a HN thread.
- mananaysiempre 2y agoPerhaps, but it would have been of little use as a question there. Once you acquire enough of a feeling for a foreign language that not every bit of your skill in it comes from somebody telling you that a particular thing is said in a particular way, you are doomed to live with a constant suspicion that your feeling is somehow off in a way you don’t recognize. Usually it can be suppressed and ignored, but sometimes it can’t, and occasionally it has to become a question. (I expect this is a fairly common experience.) This was one of those.
- jgwil2 2y agoI'm not sure about your point about "leveling" vs "leveling up", because for me, "leveling" means making a surface level/flat and does not have any video game-related meaning, but the "on" is probably coming from the phrase "to read up on" something (meaning to study/read about something; there's also a slangier variation, "to bone up on" something).
- _benj 2y agoIt is so exciting to see material like this being made! Browsers seem like mysterious, undecipherable black boxes, which is very likely how G wants them to be perceived, but that is cracking by seeing the efforts/results of such projects like ladybird and others! I hope to one day be able to jump in and contribute to break that moat! And this books looks like an amazing start!
- wmanley 2y ago> I hope to one day be able to jump in and contribute to break that moat! The moat isn't caused by a lack of non-chrome browser engines, it's because so few people use a non-chrome browser engine. Firefox already exists - it's just that ~no-one uses it and for websites that don't work with it those users have learnt to just open up chrome. I'd love for the moat to be broken, and contributing to a browser engine like ladybird would be fun - but it doesn't contribute to breaking the moat. I'd love to know what would.
- DavidPiper 2y agoI'm one of those ~nobodies. Firefox is actually quite good these days, I use it at home and at work, 100% of the time - i.e. no Chrome or Safari fallback needed. If anyone's looking for a reason to try a switch again, consider this your sign.
- abudimir 2y agoSame here. I have Safari and Chrome only for cross browser testing.
- mattlondon 2y agoIs the performance hit sorted yet when opening a page? For me Firefox used to hang for a second or two doing something? Just a blank screen with the progress bar paused around 20% or so and apparently nothing happening...(DNS? HTTPS handshake?) and then it would kick off and load normally. Happened on mobile(android) and desktop(windows, Linux, macros). On chrome-based browsers the same pages on the same computers on the same network would load in within the blink of an eye, with no pause. I eventually gave up and went back to chrome after Firefox being my daily for years. I prefer the dev tools in chrome anyway TBH
- jm4 2y agoThis looks awesome. About 15 years ago, I started working on a headless browser and maintained it for several years. It used SpiderMonkey as the js interpreter and had a custom DOM implementation. It ran all the modern js from the time, AJAX, etc. Later, I added a custom Flash runtime. It basically did everything but draw to the screen. That project was a lot of fun. I'm definitely interested in going through this book.
- aitchnyu 2y agoUmm, if you wanted/want to draw to the screen, what library will you use?
- skeeterbug 2y agoI believe Chrome uses Skia
- lesuorac 2y agoYes [4]. > [1] The library is used as of 2023 in Google Chrome, ChromeOS, ChromiumOS, Mozilla Firefox, Mozilla Thunderbird, Android, Firefox OS, Flutter,[5] Avalonia (from Alpha 4), LibreOffice (from version 7.0) and RAD Studio[6](since version 12.0). > [2] Changes to the Skia repository will be rolled into Chromium by the AutoRoll bot several times per day. > [3] It serves as the graphics engine for Google Chrome and ChromeOS, Android, Flutter, and many other products. [1]: https://en.wikipedia.org/wiki/Skia_Graphics_Engine https://en.wikipedia.org/wiki/Skia_Graphics_Engine [2]: https://skia.org/docs/dev/chrome/ https://skia.org/docs/dev/chrome/ [3]: https://skia.org/ https://skia.org/ [4]: https://github.com/chromium/chromium/tree/main/skia https://github.com/chromium/chromium/tree/main/skia
- pmarreck 2y agoWhoa. Somehow I have not heard of this. Can this be used to make cross-platform GUI apps?
- 2y ago
- austin-cheney 2y agoNice book. I would recommend splitting chapter 9 into two separate chapters where executing JavaScript via Duktape is one chapter and then interacting with the DOM and events are a separate later chapter.
- pavpanchekha 2y agoIt might be best read in two sittings! The chapters get longer as the book goes on and tackles more advanced topics, and I do recommend following along in code as you progress through the book.
- ilaksh 2y agoHere's my idea https://github.com/runvnc/tersenet https://github.com/runvnc/tersenet
- deleted 2y ago[deleted]
- currygen 2y agoIt's refreshing that browser engineering seems to become a "trend" now. The ecosystem is quite sparse with basically only Google, Apple and Mozilla defining it. I'd like to see forward into a future with more independent browser engines.
- pmarreck 2y agoOr perhaps an entirely new platform/protocol, since this one is completely saturated with complexity at this point.
- amjoshuamichael 2y agoI keep coming back to this idea as the (albeit ideal) future of the web. HTML keeps morphing and changing to fit the increasingly complex requirements of modern web apps. I mean the W3C spec is 114 million words (1). I think that web apps as a concept are a good idea, but I just can't believe that HTML/CSS/JS are the best technologies to fill that out. I'd love to see someone tackle a new, "micro-sized app format", with a much simpler document format, and something like a FORTH as a scripting language. Uxn (2) and Decker (3) are good examples of this, but obviously a proper implementation would have to be built with the full range of possible UI and accessibility in mind, not just monochrome bitmap displays. A web standard so simple, anyone can implement it! One can dream... (1) https://drewdevault.com/2020/03/18/Reckless-limitless-scope.html https://drewdevault.com/2020/03/18/Reckless-limitless-scope.... (2) https://100r.co/site/uxn.html https://100r.co/site/uxn.html (3) https://internet-janitor.itch.io/decker https://internet-janitor.itch.io/decker EDIT: There is Project Gemini (https://geminiprotocol.net/ https://geminiprotocol.net/), but it doesn't support styling or scripting.
- RodgerTheGreat 2y agoFor the record, Decker uses a 4-bit palette configured from a 24-bit gamut: http://beyondloom.com/decker/color.html http://beyondloom.com/decker/color.html Reflowing UIs to suit varying aspect ratios is a challenging puzzle that Decker presently doesn't touch, though I do have some ideas for the future. If decks were embedded as inline "applets" of interactive content within a fluid document container (markdown, gemtext, etc) I think reflow would be considerably less important.
- pavpanchekha 2y agoOne of the authors here—thank you all for the nice words. Happy to answer questions!
- SomeWan 2y agoThank you for this amazing book! I always wanted to learn more about the technological foundations that I rely on as web developer (or engineer, as you put it). I am just curious, what was the process that lead you to decide to use Python to implement the browser? I feel like JavaScript via node would have offered a more related programming experience.
- zahlman 2y agoThis was answered elsewhere; see https://news.ycombinator.com/item?id=41847363 https://news.ycombinator.com/item?id=41847363.
- mannyv 2y agoOne great thing about this book is the 'stuff I didn't do' part. Layout is really hard. Just tables by themselves are hard, even without any css around them. CSS makes layout impossibly difficult. I challenge anyone to keep the whole CSS spec and its associated behaviors in their head. At this point css + html + javascript have become a dynamic PDL, and probably is one of the most complex pieces of software today. As an aside, video decoding is offloaded onto hardware, so it's not as battery intensive as it used to be.
- pstrateman 2y ago> As an aside, video decoding is offloaded onto hardware, so it's not as battery intensive as it used to be. This is technically but not usefully true with most videos on the web today. The video decode itself is accelerated, but each frame passes through JavaScript to be composited. The only time video is fully hardware decoded is when it's a simple video element to a static video file.
- pavpanchekha 2y agoI think by "JavaScript" here you mean rendering—that's partially true. In macOS and Windows these days (also I think Linux with GTK4 on Wayland, though only in a limited way), the window manager is itself composited and a window can send a small display list to that window manager for it to composite. In that case, it's possible to actually have the video decoding to happen entirely in hardware and never have the browser directly interact with decoded video bits. That said usually the window manager compositor is pretty limited and the browser will only do this when the stars align. The sort of things that can break it are any kind of weird clipping, transparency, or effects applied to the videos.
- incrudible 2y ago> each frame passes through JavaScript to be composited What do you mean by that? There is no Javascript doing the actual compositing, and the actual compositing is (usually) hardware accelerated.
- afavour 2y ago
- systems 2y agowhy python, why not a system programming language like C, OCaml or Go (or newer languages like zig or odin) Are web browsers, not considered to be "system software"
- dvektor 2y agoI think the point is to demonstrate how things work and are designed, and python is easy for everyone to understand. I don't think the author is recommending trying to write a production web browser in python. (or probably at all ;)
- nindalf 2y agoGoing to take a wild guess that maybe they're going to rely on the excellent, extensive standard library of Python which C and Zig can't compete with. The second constraint was probably that they want to keep the number of lines of code low to encourage more people to buy the book. That's where Python does better than Go - you can do a lot with list comprehensions and you don't have if err != nil every few lines.
- pavpanchekha 2y agoDefinitely the second reason, but we actually try hard not to use too much of the standard library, for easy porting. But it's nice that sockets & ssl are standard, plus a (bad) GUI library.
- FartyMcFarter 2y agoThey definitely are system software, since they include compilers and interpreters, software libraries and other such things which AFAIK have always been considered system software. Browsers these days are about as complex as any operating system, or perhaps more complex when you consider all the non-systems stuff in them.
- pavpanchekha 2y agoAuthor here, I wrote about this on the blog: https://browserbook.substack.com/p/why-python https://browserbook.substack.com/p/why-python Basically, performance isn't a big focus, Python is very widely known and doesn't have too many quirks for non programmers to deal with, and systems languages emphasize error handling that, for expedience, we often need to skip.
- pmarreck 2y agoI hope the AI gets good enough to dynamically translate from one language to another with high reliability, in case not everyone is a fan of Python
- wslh 2y agoIs there a promotional code for HN? I was a happy user of HTMLUnit [1] with Jython [2] in the past and am very interested in a future where we can automatically generate portions of browser code using code generation and verification techniques. I've never felt as comfortable with tools like Playwright/Cypress/Selenium as I did with HTMLUnit (with all due respect to both). [1] https://htmlunit.sourceforge.io/ https://htmlunit.sourceforge.io/ [2] https://www.jython.org/ https://www.jython.org/
- pavpanchekha 2y agoThe book isn’t out yet, so no promo code, but the whole thing is free online.
- wslh 2y agoThank you for your prompt response. I understand the item isn't available, but I clicked the "Add to Cart" button thinking it would either place me on a waitlist or ship once available. However, I was then prompted to enter a promo code, which caused the confusion.
- pavpanchekha 2y agoAh, weird! We can ask our publisher. This HN post was a surprise (Chis & I didn’t put it up) so we weren’t prepared.
- julenx 2y agoI was able to pre-order the book just fine — it didn't prompt me for any promo codes.
- adhamsalama 2y agoLooks very cool, will definitely read it! Thanks!
- adhamsalama 2y agoWould be nice to have the option to download it as an epub to read it on my e-reader.
- abixb 2y agoMy thoughts precisely. I wish there was a service that could convert book-length webpages into neatly formatted ePUB document. I did find a 'converter', [0] but the service has tons of room for improvement. [0] https://www.freeconvert.com/webpage-to-epub https://www.freeconvert.com/webpage-to-epub
- adhamsalama 2y agoThe website has a single HTML page version, I downloaded it using SingleFile extension on Firefox and sent it to my Kindle using Caliber after converting it to AZW3. The result is great!
- farmeroy 2y agoThis is amazing, I just want to drop everything and start digging through this. Well done!
- mvesto 2y agoThis is awesome! Nice work
- bloopernova 2y agoThis is wonderful! I had an opportunity to run a tutorial on basic command line usage for newer software engineers. It's always fun to see people's expressions or read their reactions to seeing me telnet to port 25 and 80.
- pradmatic 2y agoI've been looking for a fun project to start and I'm already thoroughly enjoying this book. Kudos for making the writing particularly engaging. This comic book about how Chrome works is also a great place to get started: https://www.google.com/googlebooks/chrome/med_00.html https://www.google.com/googlebooks/chrome/med_00.html
- bafatik870 2y ago[flagged]
- adr1an 2y agoCare to elaborate? I've just noticed those are links to comments that are spam and the account was deleted on github.
- wai-dang-loveme 2y ago[flagged]
- rjurney 2y agoWhat an awesomely comprehensive resource, reminds me of MITRE ATT&CK.
- mannyv 2y agoSome major problems that browsers have to deal with have to do with UI. Specifically: 1. Users expect the UI to update in realtime, 2. Developers expect the UI to update in realtime, 3. UIs tend to be single threaded, and 4. The principles of software engineering and the reality of software stress encapsulation, but the realtime nature of UI requires visibility into these processes. And of course this impacts the Javascript layer, since this is yet another environment with the same constraints as above.