Let's build a browser engine Part 3: CSS
limpet.net
limpet.net
This reminds me of the famous Torvalds quote:
"Bad programmers worry about the code. Good programmers worry about data structures and their relationships."
As I have advanced in skill as a programmer, I'm continuously reminded of how true that is. The canonical example at this point is obviously git - which has a mind-blowingly simple albeit clever structure - but I've found it to be the case in almost everything.I'm currently working on a compact DSL for performing a certain type of aggregations across streams of JSON objects. To me, the workings of programming languages used to be a black box with a lot of magic going on. Once I understood the concepts of lexing, parsing, using a visitor to traverse the AST and stack machines, it was went from being out of my reach to a simple but slightly time consuming excercise.
There are many other examples -- raytracers, databases, rendering html and css as per the article and so on - but the point is that once you've found a convenient abstraction and a good way to represent the data, tasks that seem complex can become rather easy. A good chunk of what defines a good programmer seems to be the ability/intuition to find those magic abstractions which obliterates the problem.
"Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious."
Which is precisely what Category Theory is all about.
I've also been toying with designing and writing bits of code for a minimal (but still HTML/CSS compliant) rendering engine, although my goal was more to explore the limits of how simple a rendering engine can be while still being useful.
Note that this is much of the idea behind Rust (which is used by this series): browsers are too large and difficult for humans to guard against the presence of vulnerabilities, so we use software (i.e. compilers) to do it. Compilers have a much longer attention span than humans do.
Sandboxing can also achieve this, although at a much more coarse-grained level.
That said, i don't have any strategy at hand regarding browser complexity, but i believe as it gets more prominent, the change will come. At least i hope that the browser i'll be running in 5 years would be a saner piece of software.
What I'd like to see is support for more general, compiler supporting infrastructure. A platform where you could develop your domain specific languages and data structures that are then transformed to native environment. Kind of like JavaScript is used as a transpiler target, but you still need to have loads of functionality on top of browser base.
Then there could be ways to tag your data with semantics (this text is a heading, this is a link), accessibility, editorial intents (text select, copy/paste) that browser could use to display for specific devices and provide interaction (typing, touch).
Since browser is a place to present and produce almost everything digital, not one standard body nor a standard can provide this. HTML/JS/CSS was borne into what it is today for few, narrowly scoped purposes and is creakingly, laboriously converted into different thing each time you open a web app.
As a web developer, this is actually something that's good for my industry. What I don't need is more choices in browsers, more quirks I need to know and more issues to deal with across a multitude of platforms.
Sure, it's getting better. However, I hardly see a day in the near future where you can code something once and it works perfectly across every single browser.
I know this will not work for everything, especially app-like sites; but if web developers would do this for sites whose purpose is to provide information -- which is arguably one of the main goals of the Internet; then maybe it would be a better experience for all browsers, and we wouldn't have such absurdities as static pages that require JS to display.
Blink is not WebKit just as WebKit is not KHTML.
The person above is correct, most open-source browsers use some WebKit based engine OR Gecko. The differences between WebKit, Blink, and to a less extent KHTML don't change that fact. They're still the same core-codebase.