Hacker News new | ask | show | jobs
by tree_of_item 3168 days ago
> I'm imagining that if only the compiler were allowed to do I/O, I'd have to rebuild Chrome whenever I wanted to see a new site, or even see an update to a site, or change my preferences. Wait, scratch that, I can't change preferences, because it can't save.

Chrome IS the compiler. Your preferences are a program provided as input. Websites are programs provided as input. You wouldn't need to rebuild Chrome to change things.

1 comments

Can you elaborate on what you mean?

How would I save my preferences?

Do all websites have to be compiled as programs first, so they can be input as programs into new Chrome?

If my websites were provided as input and compiled into Chrome, how do I avoid rebuilding Chrome when the websites are updated?

If Chrome is the compiler, then Chrome is allowed to do all the I/O it wants, just like it does right now?

I mean, at some point you're just asking me to implement it for real, but I'll give you some hand-wavy answers:

You save your preferences the same way you might save `jquery.js` on your computer.

Chrome IS the compiler, you don't need to compile them first to give them to Chrome.

I'm not sure what you mean by "compiled into Chrome". Since when you do compile a program "into" the compiler? Look, your browser probably JIT compiled a dozen programs just for you to be able to view this page and comment. Did you need to rebuild Chrome?

Yes, Chrome is doing the IO. Importantly, the page is NOT doing the IO. So, there's no XMLHttpRequest, for example.

To make an analogy to Python: you don't need to recompile Python to interpret new Python programs. Chrome would be like Python: Chrome is itself a compiled program, but it interprets user settings and web pages.

Chrome is allowed to do whatever I/O it wants, but the programs it interprets (like user settings and web pages) are not allowed to do any I/O at all. These interpreted programs are sandboxed.

This isn't really surprising if you think about it. Chrome is already an interpreter for a sandboxed language (JavaScript)