294 points · by aagr · 12y ago · 142 comments
That said, I'm sure the Chromium source is a great resource- just a strange and important omission from the article.
I would also suggest that anyone looking for a platform-independent runtime check out APR (Apache Portable Runtime): http://apr.apache.org. It's lower-level than some of the Chromium libraries mentioned in the article (it would be equivalent to the "base libraries" block in the "Chrome Development Platform" figure), but sometimes that's all you need. Plus, it's already designed as a library for other applications to use, there's no need to repurpose anything like you might have to do with the Chromium sources.
You can see them all if you go to about:credits in Chrome/Chromium.
Edit: I assumed the entire codebase was multi-licensed, it looks like you're saying that different parts have different licenses, which does sound like a headache.
The C++ culture at Google is amazing, and proof that large-scale C++ can actually be really nice if you stay within best practices. It takes a lot of effort and experience from a lot of knowledgeable people to craft these practices, but thankfully Google publishes its C++ style guide (http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...) so that everyone can reap the benefits of this.
If the profession ever wants to produce anything reliable in C++, one of the first things that needs to happen is to start treating all unsafe legacy code like toxic waste, marking it clearly, handling it carefully in isolation, and disposing of it with prejudice as soon as possible. I don't ever expect to see this, which is partly why I switched to languages that try to handle failures and mistakes gracefully.
You say this very matter-of-factly. Many (myself included) do not believe in exceptions, and in C++ where they are poorly implemented, think not using them is best practice.
I would summarize, but this 10 year old article I've seen on HN a dozen times does a much better job than I:
http://www.joelonsoftware.com/items/2003/10/13.html
Error handling is essential, but exceptions are far from a perfect solution. The Linux kernel is an impressively complicated, and robust piece of software and they get along just fine without exceptions. One just needs to be vigilant when handling errors.
This has already been done, so you are obviously wrong.
Exceptions are cute for small amounts of code. But as soon as you get a sizeable codebase, you have zillions of functions just waiting to explode your call stack in ways you could never expect.
Documentation doesn't fix it either. Even if you could somehow guarantee that every single function has detailed descriptions of its possible throws, you won't get devs to read all the documentation for every function in some piece of code that needs a small fix.
I generally agree though, error paths are the last area I want to expose myself to flaky manual propagation and the 'well, I think I handled/freed everything' discipline. The regimental 'goto cleanup' type code you see in the kernel is not something I want in my projects.
It's real-world C++, not 'Modern' or Boost- or 0x-C++ (not even C++98). There is a huge gap between C++ development in the trenches and what is published on the internet about C++.
Yet the C++ code powering downloads was pretty bad and poorly maintained, written, replaced with Go.
http://talks.golang.org/2013/oscon-dl.slide#10
For sure there are great C++ programmers at Google, but across the company as a whole?
I fully concur with haberman about the state of C++ at Google.
https://hg.mozilla.org/mozilla-central/file/tip/ipc/chromium
The more long term concern is the way it's creating a sort of development priesthood. You have the chosen few that are making decisions and developing the platform largely in secret and pushing the code out to mere mortals from on high. This wouldn't be so bad, except the decisions are not made in the interest of the mortals, but of the priesthood and the strategic interest of their Googly God, and they exhibit a level of contempt for the mortals by disallowing them direct access to things such as the components so lauded here. In an ideal world most of what's mentioned should not be in the C++ layer, but in JS, except the hooks to provide that are simply never going to be exposed (at least in the near term because of the JS performance it would be technically dubious), leading to this them and us situation where they get to develop all the low level stuff, and no one else does, especially if any patches would conflict with the interest of their lord and master. They simply aren't dogfooding their entire development stack. Mozilla, for all their flaws, do actually engage the rest of the world in what they're doing, and early Java, while slow, did have a relatively small JVM with an enormous class library which was mostly written in Java itself. You could argue Sun's error was to Swing too far in the other direction by insisting on being all Java where at the time it really should not have been.
So yes, sadly I've come to view many Chrome devs as smug self serving slightly delusional types persistently confused that the masses don't acknowledge their brilliance, and this piece is evangelism to try and persuade us of this. The truly scary part of this is they just might be right to have this point of view in order to prevent what happened to Android where groups outside succeeded in nullifying many of the expected advantages of a standard open mobile platform, and I suspect it's this which has led to their open but closed approach to things.
>In an ideal world most of what's mentioned should not be in the C++ layer, but in JS, except the hooks to provide that are simply never going to be exposed
Do you even know what you are talking about? the only thing that is reasonable to be written in javascript is webkit, specially the DOM.. and as far as i know, the chromium folks are already doing it.. (its called oilpan, i think)
There's no way the other parts could be working in javascript.. javascript is not that sort of language.. first you need a non-GC language: C, C++, Rust or ObjC (if you can stand it)
Than you need access to the native threads, and process, net, etc.. of each platform and provide native bindings for each platform.. and you need to do it fast(this probably means AOT compilation).. and again javascript is not that sort of language..
People need to stop being lazy and learn to use different tools for different needs..
I wont even comment on the cultist non-sense part.. but the source of chromium is there.. you can use it.. its open.. what could be bad about it?
Its ok; if you need multiprocess ipc + net + actor-based thread concurrency + gpu compositor + webkit.. (like i do)
But, dont know if it worth the trouble otherwise..
For instance, it takes a very long time to compile everything, it takes long to debug (the final chrome binary with debug symbols end with 2G.. all loaded in the heap) and you got a big codebase to know about.. so use it with care and in need.. otherwise you will waste your precious time trying to kill a fly with a canon
For the record, I'm working on a new C++ project where I ended up picking up small (very small) pieces of chromium codebase with the rest being in conservatively written C++ (but not as conservative as described in google code-style guide). In general, I'd say /base and /threading libraries are useful sources to raid at the beginning of your project. These are high quality implementations of basic things most programs would need and somewhat easier to disentangle from the rest of the code.
first: know how to use gyp and ninja build tools then.. you can embed: base, crypto, net and ipc..
Anything more than that, things start to get more complicated.. for instance: if you want to use the 'ui'.. then you have to embed 'cc' and 'gpu'.. and to work right.. you will need the browser process + the gpu process.. and will have to create a custom-renderer, or adapt the renderer process to yourself.. so now you will realize you are doomed!
The other Chrome components past the ones i've pointed out, will need to use the IPC and multiprocess logic from chrome.. so that part should only be used in very specific scenarios..
Edit: i think the 'cc' module, the chrome compositor, also has some sort of autonomy from the multiprocess IPC core.. so could also be used with: base, crypto, net and ipc
I dont think exposing it directly here wont be very succint.. (i wish this was more simple to explain about) since there are some details about how the technology works (or should work) and since i dont wrote any docs about it besides my personal notes.. i was expecting to jump here at HN with a working prototype for us to play with in some months from now.. as it would be easier for people to wrap their heads around it
Im glad to talk about it to anyone interested, and if anybody else is curious, just drop me some mail at fabiokaminski at gmail dot com
With more people interested and involved, of course i can just stop coding and write a doc or paper about it in more detail.. i know theres a lot of pressure out there for something like this.. as the journey for me to get into this formula was driven by my own needs, and the lack of something already real that i could use... (couldnt do it for web browsers and app platforms wasnt really there)
It wasnt easy to get into this formula.. and i can say that this engine is REALLY cool, once its a reality i have no doubts, it will be a much more heavy-weight sucessor of what the browser could have been if it was reimaginated and designed to be more powerful than it is.. (and with the things we do know now :))
This movement is really interesting to me. If I could clone myself, I'd be working on an exokernel in Rust that just exposes a V8 VM, and uses a DOM implementation as the native drawing interface. Processes == tabs...
Of course, there's higher level work that needs to be done to expose more of the machine in JavaScript. Check out http://extensiblewebmanifesto.org/ , signed by Google, Mozilla, and W3C TAG members, as well as #extendthewebforward on Twitter.
0 - http://words.steveklabnik.com/returning-to-free-software-a-g...
I made a decision to start using the Chromebook to dogfood this particular vision of computers: I'm not happy that it involves Google, but they're the only one with an implementation that's this far along, unfortunately.
I've been meaning to write on this whole thing, haven't had the time...
I've been trying out Nitrous.io, and it's pretty great. I also SSH into a Digital Ocean droplet too. I just use Vim and git and everything else as normal.
> What surprised you that was so easy?
Mostly that it works.
> What did you find more difficult that you wish was easier?
I still haven't done any international travel with it yet, I bet I'll spend a lot more time using my X1 Carbon then.
I tried it out on a VM chromeOS when I was thinking about getting a Chromebook Pixel, but I ended up going with a Macbook instead - seems like more features for the same amount of money.
I found the following, which mentions Chrome Web Browser, is that equivalent for the sake of applications? https://chrome.google.com/webstore/detail/vnc-viewer-for-goo...
Unfortunately, it is impossible to live in a world of ideals, and so, I must compromise from time to time. As I mentioned elsewhere, I have another machine with 100% free software that I use for PGP when I need to keep secrets.
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/XU...
https://groups.google.com/forum/#!topic/mozilla.dev.platform...
It'll still be possible to use Firefox to run XUL apps, though.
Isn't that what Qt is for, with the added bonus that it's what Qt is actually for and thus e.g. documented and supported?
If you want a fairly high level, cross platform C++ library, there is no reason NOT to use Qt.
Which coincidentally, Chrome & Chromium are based on, making the cross-library usage full circle.
The warning is based on one review, and doesn't seem accurate in this case, so this might be something to try to get resolved.
[1] https://www.mywot.com/en/scorecard/mobilespan.com?utm_source...
All of these libraries are MIT licensed, well documented, and designed to be very focused libraries with very little feature-creep.
For TLS: PolarSSL has worked for me, but its GPL and tends to break ABI quite a bit [3]
[1] https://github.com/joyent/http-parser
Edit: to be clear after you get your app up and running with the current version how much time has to be spent on ongoing maintenance down the road?
I'm the author of the post. Happy to answer detailed questions on using Chromium as a Dev platform. Any suggestions for a follow-up post?
This statement makes very little sense. You say that you can't use web apps because you would require client have a specific app (chrome) on their machine, but then you say the solution is that they must have a different specific app on their machine. I would re-write that or remove it.
The Chromium project doesn't build on many platforms, and the build system they use for it is minimally documented.
While individual bits of code might be reusable on other platforms, I'd be hesitant to base any project I create on Google's codebase given the lack of portability and their reliance on arcane buildsystems.
Awesome post, though.
The Chrome runtime has some good libraries but using that over say Qt really only makes sense if you're a (former) Chrome developer. For everyone else it's just needless pain.
(You could say that's because we're kind of like a browser, but we don't actually use the most browser-like components of Chromium. We do need an http(s) fetcher and html/css/js parsers but the Chromium ones aren't a good fit for our usage.)
A big shout out to the author of this stack overflow post, where I first confirmed that it might indeed make sense to develop function-based middleware in C or C++ and share it between iOS and Android to bridge the low and high levels of your app: http://stackoverflow.com/revisions/5234868/2
What other alternatives are there? Apache Portable Runtime?
Further, I really don't like the idea of adding a third-party draw API to a language standard. Dunno if we really want to blur the line between language and library.
Just started experiencing this early on this week via Node Webkit, it is just awesome what NW with Chromium brings to the table.
The first thing that came to my mind is that this should have been there 15 years earlier through Java/Embedded browser. However the powers of the time (read IE) were not interested/even actively blocked embedded browser usage.
that's not the case tho, and that's why its a blog post and not something everyone and their dog uses.