ChromiumOS Developer Guide, Programming languages and style
chromium.googlesource.com
chromium.googlesource.com
> Use only spaces, and indent 2 spaces at a time.
These conflict in the C++ guide (as well as shell). As I’ve aged, 2-spaced code doesn’t provide the necessary contrast for me to easily read & scan code, but rather than picking a larger number or using tabs so users can configure the value, a low, hard-to-read number was chosen.
I myself have always used 4 spaces for C++ codebases. Spaces provide fixed width and consistency, regardless of the code editor. Tab proponents say that the power of tabs is that they can be configured. Thing is, I don't want to configure them everywhere I go, and I change stations a lot. Think also of code viewers: non-logged in GitHub defaults to a 8-spaces tab width, which is enormous and code becomes too wide to read without horizontal scroll in a non-ultrawide screen.
Also, people are clumsy. I'd wish this was not the case, but that's the world we live in, and people (I'd even say MOST people) are clumsy as hell and will somehow mix spaces with tabs.
Long live the glorious and sweet dictatorship of opinionated, unconfigurable code formatters. Whether they impose 2 spaces, 4 spaces, or tabs, I don't care. Code getting automatically formatted in a consistent style across all teams and contributors, that's bliss.
(I myself actually believe that tabs for indentation + spaces for alignment would be the best of both worlds, but never tried to enforce it in my projects)
I only can use it on personal projects, as most places I worked in use spaces.
The limit on what constitutes a reasonable line length is a bit subjective but I'd say that well written code rarely goes above ~120 or so. Depends a bit on the language, some just have more boilerplate than others. But instead of making that a hard limit I'd warn above that number so actual people can decide if it makes sense there or if a rewrite is in order. Auto-formatting is great and all, but ultimately a human should have the last decision.
Though if you force me to pick a value, then it's 4 because that's the sanest choice for like 95-99.9% of all people.
Use tabs and allow people to pick their own spacing
Also good for accessibility
> New projects should use that unmodified public Python Google style guide (4 space indent with methods_with_underscores). Historically, we adopted a style that was congruent with Google internal Python style guide (2 spaces with MethodsAsCamelCase).
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/sty...
Why are we still having this meaningless discussion in 2023? Adding this functionality to editors shouldn't be that difficult and we can end this discourse.
For everything else, I indent twice, but I have a habit to compress double-indentation in my source code into a single character code by pressing the Tab key only once.
I pose this question sincerely, as I'm over 40 and still prefer 2-space tabs myself.
On the other hand, when the style rules also impose a very short maximum code line length, e.g. of 80 characters, then I agree that in such cases 2-space indenting is a superior choice, because the slight decrease in readability is compensated by a greater increase in readability due to a much less frequent need to break long lines.
When I write for myself, I prefer 4-space indenting, but together with a greater maximum line length.
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/sty...
If you were asking about Black specifically, it's very popular:
> The following notable open-source projects trust Black with enforcing a consistent code style: pytest, tox, Pyramid, Django, Django Channels, Hypothesis, attrs, SQLAlchemy, Poetry, PyPA applications (Warehouse, Bandersnatch, Pipenv, virtualenv), pandas, Pillow, Twisted, LocalStack, every Datadog Agent Integration, Home Assistant, Zulip, Kedro, OpenOA, FLORIS, ORBIT, WOMBAT, and many more.
> The following organizations use Black: Facebook, Dropbox, KeepTruckin, Mozilla, Quora, Duolingo, QuantumBlack, Tesla, Archer Aviation.
Of course rust has a built in one, so yes.
- dropbox
- Mozilla
- nextcloud
- Backblaze
has forked ChromiumOS and replaced the backends with their storage. That would be wonderful.
They've got the browser, they've got the Sync integration, they've even got some Android apps (or, well, the Amazon Appstore, but best attempt?) They've even got the Win32 support from a cloud environment (Windows 365 Cloud PC). They could just market it as "Edgebook" or "edgeOS" or "cloudOS" or "liteBook" or something similar... Just don't call it anything related to "Windows."
If they really gave it their full effort it could be interesting hardware. It would be the product of choice for IT departments to deploy in companies that use Azure AD; for employees that don't need more than a web browser, or only need a Win32 app that isn't Microsoft Office on a rare occasion. As for education, just "we're not Google" is a nice pitch in some areas.
I think one thing putting Microsoft off though is that launching a non-Windows-based desktop OS is daunting; and also, one of the dirty secrets about how Chromebooks manage to get so cheap is they use the cheapest ARM processors with ridiculous amounts of binary blobs patched in that will never go upstream, so kernel updates are almost nonexistent (thus why many Chromebooks, even the one I bought from Walmart for $110 last week, have a ~5 year end-of-life). For Microsoft, maintaining customized kernels for each device that will never see an update, for many years, and basing a device's lifespan based on that kernel is antithetical to the design of Windows. Microsoft wants to ship one Windows to everyone, with an objective End-Of-Life standard, and relatively high-quality drivers; not a device-specific Windows, with a device-specific EOL, with binary blob drivers that merely hit the level of "functional on this one weird kernel".
I don't think that's actually true? For starters, the majority of Chromebooks are x86 machines, even most of the cheap ones. But more to the point, AFAIK Chromebooks, even ARM Chromebooks, are maintained mainline/upstream in linux. This is surprisingly hard to get a good citation for, but see ex. https://github.com/torvalds/linux/blob/master/arch/arm64/boo... which is device tree stuff for... honestly the code names confuse me, but I think kukui, jacuzzi, and fennel are all names for Chromebooks (or boards in Chromebooks, I think).
> one of the dirty secrets about how Chromebooks manage to get so cheap is they use the cheapest ARM processors with ridiculous amounts of binary blobs patched in that will never go upstream, so kernel updates are almost nonexistent
doesn't seem to be true. Google doing its own thing in userspace is separately annoying to me but actually an advantage in terms of keeping the machine's kernel up to date.
https://developer.chrome.com/docs/extensions/reference/fileS...
For example, no exceptions. Exceptions are a core part of the language and are fundamental to many of the features and or in maintaining invariants.
Not having exceptions means that all Google components are inherently useless in normal C++ unless they wrap them up.
The style is designed to dumb it down to make it usable by everyone who never had C++ training. For that it's valuable, but shouldn't you want your developers to be proficient with the tools they use anyway?
Nice evolution from an annoying dialogue in MS Office. /s