News for hackers. Stuff that matters.
Re:Software Engineering at Google by kortilla on Tuesday March 17, 2020 @05:27PM (#22610643)
If you’re interested in becoming a software engineer or are junior, do not read this and cargo cult it because many of these things will not be good practices for 99.99% of the industry.

Google has custom tooling, custom kernels, custom hardware, etc and legions of support at every layer of the stack. Complexity is not eschewed but it is rather embraced if it means some slight improvement in utilization or better looking latency distribution.

Those goals are not sustainable in normal businesses, even tech ones.

Google places very little emphasis on things like code readability and testability because it’s easy for them to do rewrites or just run tests on 1 million cores to shake out race conditions and locks.

Read this for entertainment but don’t try to blindly apply it to your work environment. Most of it will make you a bad engineer for non-FAANG envs.

Re:Software Engineering at Google by thelean12 on Tuesday March 17, 2020 @05:32PM (#22610688)
> Google places very little emphasis on things like code readability and testability.

Why do you say this? I've seen the opposite.

I can't submit untested code or code that doesn't have "readability" approval. It's certainly not perfect but testability is a huge part of any project I've worked on.

Re:Software Engineering at Google by twitch-chat on Tuesday March 17, 2020 @05:44PM (#22610792)
Not to mention a lot of the open source stuff at Google like Chromium or Android is very readable.
Re:Software Engineering at Google by kortilla on Tuesday March 17, 2020 @08:50PM (#22612434)
The “readability” label comes from other “brilliant” Google engineers.

Also, tested code is not the same thing as “testable” code. Mock and monkey patching can very easily give you 100% coverage of untestable code with garbage tests.

Re:Software Engineering at Google by joshuamorton on Tuesday March 17, 2020 @10:46PM (#22613106)
> The “readability” label comes from other “brilliant” Google engineers.

This doesn't mean it leads to complex code.

The Google cpp style guide[0], for example, tries at length to keep code simple and stresses that even in C++, you should prefer simple things unless the performance benefits (of, say, nontrivial ownership) are provably necessary:

> The performance costs of value semantics are often overestimated, so the performance benefits of ownership transfer might not justify the readability and complexity costs.

[0]: https://google.github.io/styleguide/cppguide.html

Re:Software Engineering at Google by kortilla on Tuesday March 17, 2020 @11:50PM (#22613454)
> > The “readability” label comes from other “brilliant” Google engineers.

> This doesn't mean it leads to complex code.

It does mean that it’s a completely subjective thing coming from other people in the very same culture of which I’m being critical. It’s like someone claiming the Chinese government isn’t authoritarian because Chinese citizens have slapped on the “non-authoritarian” label.

Re:Software Engineering at Google by alarge on Tuesday March 17, 2020 @05:53PM (#22610879)
Chiming in here to agree with the others. In particular, finding simple, understandable solutions to complex problems is highly valued at Google. Complex solutions are an anti-pattern.

And the comment about readability and testability is so far different from my experience that I have to wonder where the poster is getting their information. Google code reviews have to be among the most nit-picky I've ever seen in a 30+ year career, with serious attention to detail all the way down to punctuation in comments.

Re:Software Engineering at Google by kortilla on Tuesday March 17, 2020 @08:56PM (#22612474)
Nit-picky reviews are a smell, not a good thing. It can often mean that the reviewer is not really reviewing the big picture (is the intent of the change being fulfilled, is this the right place in the architecture, etc) and it making up for it by focusing on irrelevant details.

Seriously, code review on punctuation in a comment is not good in any scenario and it speaks nothing to the legibility of the code itself. If anything, it might mean the code is unreadable and the reviewer is too embarrassed to point out that they can’t follow it.

Re:Software Engineering at Google by joshuamorton on Tuesday March 17, 2020 @10:42PM (#22613080)
This conclusion doesn't, at all, follow from the premise.

While yes, nit-picky review could mean the reviewer doesn't understand the big picture, an LGTM with no comments at all is more likely to be indicative of missing something.

What you really mean is that nit-picky reviews that don't pick up on actual logic or functionality issues are a smell. Which is true, but isn't usually the case at Google[0]. The chapter on teamwork covers some relevant concepts (like psychological safety).

[0]: https://testing.googleblog.com/2018/05/code-health-understan...

Re:Software Engineering at Google by kortilla on Tuesday March 17, 2020 @11:48PM (#22613440)
The comment I replied to is literally highlighting people nit-picking punctuation as if it’s a good thing.
Re:Software Engineering at Google by joshuamorton on Wednesday March 18, 2020 @12:05AM (#22613514)
Which it is!

You seem to be assuming, without prompt, that nit-picking punctuation comes at the expense of a thorough overall review.

Code review on punctuation is absolutely an important part of readability. Consistency makes understanding and scanning (for human readability) and potentially parsing and modifying (for machine readability) much easier.

As someone who both reviews a lot of code and reads a lot of code, consistent documentation with good grammar and punctuation is enormously helpful.

Re:Software Engineering at Google by kortilla on Thursday March 19, 2020 @04:39AM (#22625639)
I’m not assuming, this is based on my experience at Google. People that focused on punctuation rarely provided anything more than the superficial review.
Re:Software Engineering at Google by joshuamorton on Thursday March 19, 2020 @04:48AM (#22625674)
Again you're begging the question.

People who focus on punctuation do so at the expense of everything else, sure. But people who give thorough reviews give thorough reviews, including nitpicky comments.

I've given and received thousands of reviews at Google (in multiple languages, across multiple teams), and can say that my experience has been fairly consistent: code review is high quality and detail oriented, including, but not at all limited to, small things like grammar and comment formatting.

Re:Software Engineering at Google by kortilla on Friday March 20, 2020 @04:10AM (#22635909)
I’m not begging the question, I’m just sharing my experience from working at Google and other companies. By a wide margin, the most useless reviews were ones nit-picking formatting, punctuation, etc.

> But people who give thorough reviews give thorough reviews

Ok.

> including nitpicky comments.

Disagree. Pointing out that someone forgot to capitalize an initialism in a comment is not thorough, it’s a time suck. A thorough and competent reviewer will realize it doesn’t matter and will know not to distract the CL owner will such irrelevant trash.

Sure, there is an a small section of the Venn diagram that leaves good review comments and sprinkles in “nit:” turds, but that group is much smaller than both the fully incompetent nit-pick group and the competent reviewer group.

Seriously, unless a code comment is illegible or it’s being compiled into user-facing docs, it’s absolutely useless to leave something like “nit: it’s TCP, not tcp”.

Re:Software Engineering at Google by joshuamorton on Friday March 20, 2020 @04:26AM (#22635970)
> Seriously, unless a code comment is illegible or it’s being compiled into user-facing docs, it’s absolutely useless to leave something like “nit: it’s TCP, not tcp”.

I think you're describing style errors, not grammar errors. For example, the Google style guide says that (certain) comments should be complete sentences. Asking people to use good grammar (and capitalize/punctuate) those sentences as though they were documentation (because they are!) is valuable for reviewers.

I say this as someone who, when reading unfamiliar code, is able to understand it more readily if the inline documentation is easy to read. "tcp" vs "TCP" doesn't impact that, but other grammatical nits absolutely due.

Re:Software Engineering at Google by kortilla on Sunday March 22, 2020 @02:49AM (#22653236)
> I think you're describing style errors, not grammar errors.

The entire thread (not started by me) is about nit-picking punctuation and now you’re trying to explain to me that I’m describing style errors. So what? It’s useless feedback regardless of which chapter in the Holy Google Docs covers it.

> Asking people to use good grammar (and capitalize/punctuate) those sentences as though they were documentation (because they are!) is valuable for reviewers.

Right, it’s valuable for the reviewers because it makes it seem like they provided feedback when they have nothing of substance to add. It’s not valuable for the author though nor is it realistically valuable to future people reading the code in question.

>I say this as someone who, when reading unfamiliar code, is able to understand it more readily if the inline documentation is easy to read.

I think maybe you don’t know what “nitpick” means. https://www.dictionary.com/browse/nitpick

If it has a meaningful impact on the ability to read it, it’s not a nitpick.

Re:Software Engineering at Google by joshuamorton on Sunday March 22, 2020 @04:00AM (#22653457)
My experience differs. Consistent and well formed prose in docstrings and comments absolutely helps reason about unfamiliar code. Nitpicking for good formatting, spelling, and grammar is valuable in code comments just the same as in documentation or any other form of technical writing.

If the comments aren't important enough to spend care and thought on, they should be deleted.

> If it has a meaningful impact on the ability to read it, it’s not a nitpick.

This is boring semantics. Given what you describe as nitpicks, we draw the line of meaningful impact on readability in different places. So I'm claiming that some of the things you describe as nitpicks in fact aren't.

Re:Software Engineering at Google by jbn on Wednesday March 18, 2020 @12:34PM (#22618455)
what about nitpicks related to whitespace? These are an endless source of time-wasting, IMHO.
Re:Software Engineering at Google by joshuamorton on Wednesday March 18, 2020 @01:01PM (#22618773)
At Google or in general?

The closest I've seen to this is comments of the form "can you reformat this" or "this doesn't match the rest of the file". Google's style guides have fairly strong guidance on formatting, so there's usually a "right" way (enforced by a linter), and if not, then usually you defer to the existing style in the module.

Re:Software Engineering at Google by jbn on Wednesday March 18, 2020 @02:02PM (#22619463)
I meant in general. Except python-like languages that make it a non-issue, in C/C++/Java I think people attach way too much importance to spacing, trailing whitespace, tab vs spaces, and column width.

I would agree with linting or just deferring to existing style, but in truth I care little about this, it's just not significant to me (yet others seem to overvalue it, to the point of talking exclusively about this).

Re:Software Engineering at Google by thedance on Wednesday March 18, 2020 @03:48PM (#22620498)
At Google (in google3) there are automatic linters that run on every change and if they fail then your change simply will not be approved for style. There's no debate about it. This is one of the great things about gofmt: either your Go program passed through it, or it did not and won;'t be accepted. Arguments about the formatting need to be in the form of a changelist against gofmt itself.
Re:Software Engineering at Google by jbn on Wednesday March 18, 2020 @05:27PM (#22621420)
I agree, automating this so as to make it a non-issue is really the only way to deal with this at scale (i.e. in presence of a lot of change and many reviewers).
Re:Software Engineering at Google by shaftway on Wednesday March 18, 2020 @03:49PM (#22620508)
Every team I've been on at Google has presubmits that enforce this, along with command line tools to "fix" it. There's no arguments about spacing. Nobody really cares about extra lines, but if you use tabs instead of spaces you're just wrong and your CL can't be submitted.

It's actually nice. I disagree with some of the rules and would like them to change. I think that if your if-block has a single statement and there's no else, and it all fits in a line then it's fine to inline it.

    if (theAnswerIsKnown) return theAnswer;
But I'm wrong. Because the linter doesn't allow it. So I moved on and I don't bother fighting that fight.

Edit: To be clear, I might be right, and this might be better, but I'm "wrong" in the sense that it's not linter compliant.

Re:Software Engineering at Google by jbn on Wednesday March 18, 2020 @05:26PM (#22621410)
w.r.t "if you use tabs instead of spaces you're just wrong", can you expand on that?

Do you mean 'wrong' in the sense of 'wrong according to the rules enforced by the linter' or 'wrong philosophically' ? If it's the latter, how is that wrong and is not even a subject for debate?

This is an honest question, I guess I just don't see how something like this can "just" be wrong (to me it's irrelevant and not worth the ink used to write such statements in code reviews... though I'm playing devil's advocate here obviously :-) ).

PS: of course if pre-submit checks enforce the rules, then as you said it becomes a non-issue. I have been in environments where there are no such tool-enforced checks, yet people comment on it endlessly, routinely blocking code reviews for whitespace issues...

Re:Software Engineering at Google by kinkrtyavimoodh on Tuesday March 17, 2020 @07:29PM (#22611802)
> Google places very little emphasis on things like code readability and testability because it’s easy for them to do rewrites or just run tests on 1 million cores to shake out race conditions and locks.

This is complete nonsense. Google's code review and testing and reliability practices are better and more sensible than most big and small companies I have worked for and heard about.

Re:Software Engineering at Google by kortilla on Tuesday March 17, 2020 @08:52PM (#22612447)
I didn’t say anything about reliability now did I?
Re:Software Engineering at Google by kwhat4 on Tuesday March 17, 2020 @09:38PM (#22612739)
I think you have a point here, but it was not well articulated in your post. Much of the industry doesn't focus on software engineering only programming which leads to massive unmaintainable garbage codebases. These are the same people that want to save a few dollars by outsourcing the work to low cost places like India and are too ignorant to realize that the development takes 10x as long for a product that is unusable. My best advice would be to avoid these organizations as they will never value the engineering and only seem to focus on the lines of code output as a metric of productivity. Unfortunately this is a lot of the "industry," however I believe the 99.9% is a bit of an exaggeration. As software engineers, we should find value this sort of information regardless of our current employers opinion and hope that we can land at an institution that values engineering.
Re:Software Engineering at Google by getmeoutofhere on Tuesday March 17, 2020 @05:29PM (#22610661)
Are you saying this as an ex-Googler / current Googler? Otherwise, please give some citations for some of your claims.
Re:Software Engineering at Google by syndacks on Wednesday March 18, 2020 @12:15AM (#22613570)
Their Google status is irrelevant. The nature of their comment is that there's a propensity to emulate big tech when it's not needed. Off the top of my head: Kubernetes, microservices. My citation is news.ycombinator.com.
Re:Software Engineering at Google by teen on Tuesday March 17, 2020 @05:29PM (#22610668)
as someone who worked previously at google, and went back to the start up world working with php mysql, this is not true at all
Re:Software Engineering at Google by Lammy on Tuesday March 17, 2020 @05:54PM (#22610898)
How is it not? Seems like simple economics to me. Something like maintaining a custom kernel distribution takes ${x} amount of engineer time for ${y} amount of “savings” (better perf, custom patches, nonstandard features, whatever). Why bother until you have a fleet of machines large enough for y to be greater than x?
Re:Software Engineering at Google by thelean12 on Tuesday March 17, 2020 @06:05PM (#22611029)
I don't have numbers but I feel this is exaggerated. Most people work on pretty normal stuff.

The biggest proprietary sink for most people is stuff like the build system/tooling/etc. Not many people have to be in a role where you're micro-optimizing something. They certainly exist, but not in the numbers some people on here seem to think.

Re:Software Engineering at Google by tituswinters on Wednesday March 18, 2020 @10:52AM (#22617272)
The opening chapter is very clear on that point: this is a scouting report of a software ecosystem that works at scale, what things we think are a good idea generally. It is not a "This is how you should do it," in that Google's requirements are a few orders of magnitude different than others (expected code lifetime, codebase size, engineering population, compute requirements).