News for hackers. Stuff that matters.
Re:Software Engineering at Google (2017) by Radim on Friday January 04, 2019 @05:14AM (#18822983)
Buried in the "2.11 Frequent rewrites" section, but a great hack for "productivity via a sense of ownership":

"In addition, rewriting code is a way of transferring knowledge and a sense of ownership to newer team members. This sense of ownership is crucial for productivity: engineers naturally put more effort into developing features and fixing problems in code that they feel is “theirs”."

Re:Software Engineering at Google (2017) by codeflo on Friday January 04, 2019 @05:57AM (#18823149)
I’m not convinced this works so great for Google. Some rewrites are very noticeable as a user, and things in the UI frequently shift around for no discernible reason. Perhaps worse, they seem unable to get below a certain level of bugginess in products like Google Maps and Gmail. Perhaps because a new round of rewrites always introduces new bugs before all of the old ones ever get fixed.

Perhaps their metrics tell them that all of this is fine, I don’t know. But then, you have to realize Google has so much money they don’t really have to spend it very efficiently. For everyone else, this approach to rewrites seems like an extremely expensive way to produce software that’s not even all that great.

Re:Software Engineering at Google (2017) by stcredzero on Friday January 04, 2019 @01:35PM (#18826467)
I’m not convinced this works so great for Google. Some rewrites are very noticeable as a user, and things in the UI frequently shift around for no discernible reason. Perhaps worse, they seem unable to get below a certain level of bugginess in products like Google Maps and Gmail. Perhaps because a new round of rewrites always introduces new bugs before all of the old ones ever get fixed.

Perhaps their metrics tell them that all of this is fine, I don’t know. But then, you have to realize Google has so much money they don’t really have to spend it very efficiently.

The user experience ranges between good to mediocre to bad, depending. Google is simply too rich and powerful to care. So long as the goose keeps laying the golden eggs, they can just keep going along and patting themselves on the back.

Re:Software Engineering at Google (2017) by erik_seaberg on Friday January 04, 2019 @04:27PM (#18827795)
As jwz put it, "It hardly seems worth even having a bug system if the frequency of from-scratch rewrites always outstrips the pace of bug fixing. Why not be honest and resign yourself to the fact that version 0.8 is followed by version 0.8, which is then followed by version 0.8?"
Re:Software Engineering at Google (2017) by walshemj on Friday January 04, 2019 @07:00AM (#18823401)
I saw this a BT where on system was rewritten in OWS (Oracle Web Services) used 15 Person Years and around a Million Quid - Not the best use of shareholders money.

But some one got to tick some boxes on there promotion track

Re:Software Engineering at Google (2017) by polskibus on Friday January 04, 2019 @03:07PM (#18827198)
Many enterprises are rewriting their apps to the cloud stacks for no good reason, at a great capex and later opex.
Re:Software Engineering at Google (2017) by heavenlyblue on Friday January 04, 2019 @07:09AM (#18823434)
Well, but that money was certainly not needed for someone else if it was so readily available.
Re:Software Engineering at Google (2017) by walshemj on Friday January 04, 2019 @01:56PM (#18826630)
Like pay rises, funding more roles to allow more career progression or gasp retuning it to the share holders?
Re:Software Engineering at Google (2017) by sytelus on Friday January 04, 2019 @08:07AM (#18823690)
If you have engineers with physiological problem of “not invented here”, you have a very serious issue. I am currently seeing this in real time in one of the projects and I was told almost exact same words as “reason” to recreate what we already have and working beautifully. It was clear to me that some developers are just too lazy to dive in to complex system. They get ticked off by one imperfection here and other over there and immediately run for exit shouting “I could do so much better”. Instead of understanding why things are the way it is, they fantasize about how they can one up original authors and claim their own hero title. They go on to throughly underestimate the time to recreate what has taken years of learning. So they spend next many months sweating out, copy as much code from “old” stuff as they can, dropping important feature here and there, adding new and old bugs - very often arriving at more or less same place they started off. Meanwhile competition has moved on to V2 laughing their way to the bank and customers scratch their heads why you are still stuck in same place for so long. Then our new “owners” gets their promos after massive marketing of how much better everything is now. But to everyone’s surprise they soon leave the project because working on bugs and incremental features has became boring and BTW, the new stuff is just as complex as old stuff. New devs roll in and we start the whole cycle again.
Re:Software Engineering at Google (2017) by klodolph on Friday January 04, 2019 @09:19AM (#18824168)
You can call it a psychological problem if you want but calling names is not a solution, nor does it really provide a good path to finding a solution. The labor market being what it is, people will leave steady jobs with good pay for more exciting work with riskier prospects and less pay. This happens all the time.

Bug fixes and incremental features will generally not get you promoted for good reasons, we expect senior engineers to have system design skills and there is simply no way to demonstrate that without having your engineers design systems. If you only assign tasks based on the needs of your product and not on the needs of your workforce you could easily find yourself with a critical skill shortage.

There's a certain inefficiency to this, but only if you put your blinders on. If you have engineers churning out meaningless work then you certainly need to address that problem, but if you prioritize short-term product success over team health you are only trading one problem for another.

Re:Software Engineering at Google (2017) by emperorcezar on Friday January 04, 2019 @09:26AM (#18824221)
> Bug fixes and incremental features will generally not get you promoted for good reasons.

This is exceptionally bad, but sadly true.

If you have an engineer who can unblock teams and fix issues in an hour that others take a week or cannot fix at all, they are gonna jump ship if they can't be recognized.

At that point you've lost a valuable resource.

Re:Software Engineering at Google (2017) by Novashi on Friday January 04, 2019 @09:44AM (#18824321)
Recognition is stupidly cheap.

If I can do that without it being a fluke, they’d better bump my salary.

Re:Software Engineering at Google (2017) by mcguire on Friday January 04, 2019 @10:49AM (#18824820)
Would you settle for a certificate?
Re:Software Engineering at Google (2017) by wbl on Friday January 04, 2019 @11:40AM (#18825335)
My landlord doesnt take certificates.
Re:Software Engineering at Google (2017) by auiya on Friday January 04, 2019 @12:53PM (#18826053)
Or a "kudos"? (page 18 of the PDF)
Re:Software Engineering at Google (2017) by closeparen on Friday January 04, 2019 @11:44AM (#18825387)
The fundamental nature of a tech company is near-unlimited appetite for new stuff to build and new people to build it. If there are zero projects on your backlog, such that the only way to do interesting work is to retrace old projects, you’re in serious trouble.
Re:Software Engineering at Google (2017) by seanmcdirmid on Friday January 04, 2019 @09:07AM (#18824101)
Code rots, even the best code rots, because the people and cultural environment that the code was written under change and fade away. Refreshing it occasionally, even if it isn’t improved in a significant way, is one way to deal with that rot.

Even if the product/library/framework never changed much, rewrites would still be necessary to keep it going as new generations of programmers shuffle through. Otherwise we wind up with a Verner Vinge dystopian culture of software archeology.

Re:Software Engineering at Google (2017) by jimmy1 on Friday January 04, 2019 @11:06AM (#18824975)
Exactly this. I view rewriting a code base, even if I am copy and pasting some things from the existing one a way of either learning or refreshing my knowledge on how the system works.

An added kicker, I have actually gone down this road, and later realized the only thing I needed to do was make a small change to the existing system, so I did just that and discarded the new work.

Business got their new features, delivered on time, the system was still stable and reliable, everyone was happy, and now my domain knowledge has increased significantly so that new features and development or bug fixes will be even faster.

Re:Software Engineering at Google (2017) by jazzdev on Sunday January 06, 2019 @06:24PM (#18841422)
Code does not rot. It gets complicated and starts to look rotten, but that's the hard won complexity of features and bug fixes. To think you can start over and not re-introduce bugs that have already been fixed seems foolhardy.
Re:Software Engineering at Google (2017) by collinmanderson on Monday January 07, 2019 @02:52PM (#18849288)
The underlying dependencies (OS, libraries, runtime, compiler, etc) slowly get out of date.

Out of date dependencies can be seen as code rot, regardless of quality/state of the actual code.

(Not saying that it should be rewritten because of that, but I do consider outdated dependencies to be code rot.)

Re:Software Engineering at Google (2017) by makewavesnotwar on Friday January 04, 2019 @10:30AM (#18824643)
This.

Trying to make the software "theirs" seems to be an issue at Google, at least with their open source software and has seemed to have lead to it being less reliable.

For example, Angular Material v1 was one of the most complete and stable front-end packages on the market a few years ago. Then, back in 2017 the lead developer for the project was replaced with a new dev.

This new dev then went about assigning every issue and pull request to himself, modifying or rejecting pr's that had previously been approved, closing issues that had in progress pr's as won't fix, locking discussions, and just generally breaking stuff. (I've personally had to peg my project to v1.4 because everything since 2016 has been a regression)

If you go to the Angular Material v1.x Github page today, you'll see the same dev on pretty much everything.

This isn't productive ownership as it prioritizes the engineer over the customer and has lead to a generally broken system from one of the most stable properties out there. Not to mention, these open-source projects are most people's first exposure to Google's code... Having them be unpredictable regarding the functionality of their software with little concern for users/contributors in the name of making their devs feel special seems like a bad model to learn from.

Re:Software Engineering at Google (2017) by duncan-donuts on Friday January 04, 2019 @08:30AM (#18823832)
One thing I think that is important to point out is the, “working beautifully” part. I agree that rewriting stuff just because is a waste of time and money. There are plenty of solutions out there that may solve a problem and may be working fine, but have now hit their scaling ceiling and people become frustrated. Rewriting stuff is a part of software, but should almost always be done incrementally.

I also don’t think it’s laziness. Developer hubris is real and it can get in the way of actual business value.

You pretty much nailed everything else. I share the sentiment because I’m currently working on splitting up a monolith into microservices. Most of the “quick wins” are things that didn’t need to be rewritten anyway, and the stuff that actually sucks is difficult to address. It’s tricky to get right.

Re:Software Engineering at Google (2017) by sytelus on Friday January 04, 2019 @08:39AM (#18823903)
The only reason given was exactly what was quoted by parent. Also refactoring different than rewriting.
Re:Software Engineering at Google (2017) by lmilcin on Friday January 04, 2019 @08:58AM (#18824046)
Remember, we are talkin about a bunch of good, well supported engineers working within rather well oiled machine with a lot of other teams doing similar work and sharing experience and advice.

Nobody said it is good general advice. There is so much stuff you need to do well to have a good chance at successful rewrite that it become good advice that it is a bad idea. Nobody said rewrites cannot be done. If you have a company that knows how to do rewrite (and makes it constantly which, I guess, helps a lot) then a lot of problems can be solved by starting from scratch and it it may be it is well worth it.

Re:Software Engineering at Google (2017) by casual_slacker on Friday January 04, 2019 @08:40AM (#18823907)
I know this is a battle as old as time, but the other extreme does exist: a system so complex that it directly attributes to attrition and decay, but too business-critical to get rid of. Yes, it's a "serious issue", and yes, it's common at many overgrown startups.
Re:Software Engineering at Google (2017) by sytelus on Friday January 04, 2019 @08:44AM (#18823943)
There are always good technical reasons to rewrite things but the reason quoted by the parent i.e. devs not “feeling” ownership and won’t work on code wholeheartedly unless it’s their code - those reasons are evil.
Re:Software Engineering at Google (2017) by sagichmal on Friday January 04, 2019 @09:21AM (#18824184)
No. Absolutely wrong.

A sense of ownership and responsibility over a codebase is fundamental and essential to proper stewardship and maintenance of that code, and refactoring and rewriting is the most effective way to inculcate that feeling. Sometimes it’s not always feasible, and sometimes it’s not necessary, but the end state is essential. Group or shared ownership of code is a manager’s wet dream but pragmatically impossible, a swamp of mediocrity.

Re:Software Engineering at Google (2017) by mcguire on Friday January 04, 2019 @10:54AM (#18824872)
Once upon a time, there was a core software engineering principle of "egoless programming". I'm glad we've thrown that piece of idiocy out the window.
Re:Software Engineering at Google (2017) by collyw on Friday January 04, 2019 @10:28AM (#18824635)
Bollocks. There are tons of people doing maintenance programming on code that they didn't write.
Re:Software Engineering at Google (2017) by PurpleBoxDragon on Friday January 04, 2019 @09:05AM (#18824084)
Does the developer not work on any systems unless they feel it is theirs, or is it a particular system that causes this phenomena? If it is the latter case, then the dev's reasoning is really a symptom of a deeper problem.
Re:Software Engineering at Google (2017) by thisiszilff on Saturday January 05, 2019 @05:47AM (#18831004)
If you feel ownership over some system, you feel as if the whole system reflects on yourself, whereas if you do not feel that sense of ownership, then you feel as if only the work you do on that system reflects on yourself. If you feel ownership then, you're likely to be more proactive in your maintenance and making sure that everything is up to standard rather than being reactive and fixing things that break. You want people to feel a sense of ownership, and rewriting a project is a very good way of doing that. Rewriting may not be the only way, of course, and it may not be the most optimal solution given other goals.
Re:Software Engineering at Google (2017) by gtirloni on Friday January 04, 2019 @08:35AM (#18823873)
It's hard to relate without more information about the specific situation.

What is the current programming language used?

Is the project mostly legacy (few or no changes in the last few years)?

Is the project critical to the company?

How many people are working on it today? Are they fully assigned to it or is it a "touch when it breaks" kind of situation?

Is the project following modern CI/CD practices? If not, how hard would it be to adapt in the current software stack? Would it be easier in a new stack?

Are developers spending more time than expected understanding the code base?

Is it a political situation? Is the current owner refusing changes? Could it be that rewriting it is just a costly way for removing ownership from that developer/manager?

Re:Software Engineering at Google (2017) by sytelus on Friday January 04, 2019 @08:54AM (#18824022)
Yes, there are many legitimate reasons to rewrite like dieng frameworks/languages. However we are discussing here the case where reason proposed for the rewrite is solely to satisfy physiological need of some developers to work on code they can call it their own. A lot of things can be done by refactoring but the devs with these issues often just start new projects of their own that does same thing. In companies like Google, for example, there are at least 5 different products for messaging.
Re:Software Engineering at Google (2017) by gtirloni on Friday January 04, 2019 @09:24AM (#18824209)
Ok, understood. I think the point I was trying to make (and apparently didn't write it down correct thus the downvotes) is that sometimes the ownership argument could just be an easier, less politically charged way to engage the audience. Who would argue against letting some new developer take ownership of something (if they have the skills, of course)? While discussing all those other questions I posed could open a can of worms.
Re:Software Engineering at Google (2017) by seanmcdirmid on Friday January 04, 2019 @09:12AM (#18824128)
Do you mean psychological or really physiological? I get the former, the latter seems dubious at best.
Re:Software Engineering at Google (2017) by chihuahua on Friday January 04, 2019 @02:57PM (#18827136)
Indeed, "physiological" would mean developers die or suffer serious injury if they don't rewrite. Seems unlikely.
Re:Software Engineering at Google (2017) by rodorgas on Friday January 04, 2019 @10:14AM (#18824525)
It’s not a physiological problem, it’s a technical problem. They do it so they work gets easier. It’s much easier to write code than to read code.
Re:Software Engineering at Google (2017) by zozbot123 on Friday January 04, 2019 @10:18AM (#18824554)
> It’s much easier to write code than to read code.

The fact that "write-only code" is apparently considered a part of sensible software-engineering practice speaks volumes about what their technical culture is like more generally. One would think that code should be much easier to read and survey than it was to write.

Re:Software Engineering at Google (2017) by zrobotics on Friday January 04, 2019 @10:54AM (#18824873)
But even something like a CS101 assignment takes longer to read than to write, at least for me. This is a common enough starement that I assume I'm not alone.

In fact, I'll often sketch out a block diagram or some pseudocode if I'm having trouble grokking something I'm reading just to help me get into the proper mindset. I agree this is a problem with the current state of the field, but I haven't seen any good solutions, only hacks and workarounds.

Re:Software Engineering at Google (2017) by Pokepokalypse on Sunday January 06, 2019 @01:36PM (#18839760)
The whole point of a computer language is so that another human being (or a team of human beings) can read it.

If the intention is for a uniquely skilled human to give a computer instructions, and the computer to execute them - then just write it in machine code.

Re:Software Engineering at Google (2017) by stcredzero on Friday January 04, 2019 @12:59PM (#18826108)
If you have engineers with psychological problem of “not invented here”, you have a very serious issue.

We need to be precise about what the problem is, exactly. Here is a more salient formulation: "Not Invented Here" is a form of bias that distorts cost/benefit analysis when people are deciding whether to reuse existing code.

They get ticked off by one imperfection here and other over there and immediately run for exit shouting “I could do so much better”.

Given the formulation of NIH as a form of bias that distorts cost/benefit analysis, what can we do at this point? How about quantifying the cost of the "one imperfection here and other over there" instead of going by the subjective being "ticked off?"

Instead of understanding why things are the way it is, they fantasize about how they can one up original authors and claim their own hero title. They go on to throughly underestimate the time to recreate what has taken years of learning.

To complete the cost/benefit analysis, we can then quantify the development cost of the library they are considering re-implementing.

Meanwhile competition has moved on to V2 laughing their way to the bank and customers scratch their heads why you are still stuck in same place for so long. Then our new “owners” gets their promos after massive marketing of how much better everything is now.

This needs to be quantified and put into the cost/benefit analysis.

But to everyone’s surprise they soon leave the project because working on bugs and incremental features has became boring and BTW, the new stuff is just as complex as old stuff. New devs roll in and we start the whole cycle again.

This also needs to be quantified and put into the cost/benefit analysis. Instead of doing cost/benefit analysis attached to individuals, it should be done by product or by project, so that these turnover costs are also accounted for.

Re:Software Engineering at Google (2017) by sowbug on Friday January 04, 2019 @12:21PM (#18825745)
A wide gap separates NIH syndrome and a healthy culture of collective code ownership (with the automated testing, shared style guidelines, frequent small commits, and continuous integration that usually go along with it). The situation you're describing sounds closer to the NIH side, but don't throw the baby out with the bathwater the next time someone wants to rewrite someone else's method to improve its readability!
Re:Software Engineering at Google (2017) by diminoten on Friday January 04, 2019 @11:23AM (#18825165)
To be clear, "Not invented here" isn't about "don't rebuild things", it's about "don't build things that exist outside of the company".

It's perfectly reasonable (for the reasons in the submission) to rewrite code that exists already.

Re:Software Engineering at Google (2017) by zozbot123 on Friday January 04, 2019 @10:24AM (#18824599)
> Instead of understanding why things are the way it is, they fantasize about how they can one up original authors and claim their own hero title.

Hell, if they really care about claiming that hero title, why not spend that effort to understand and refactor the parts of the code that were initially hard to deal with. What you wrote above is a distillation of what a "tech bro", "Type-A player", ego-based culture looks like. It is the opposite of true professionalism.

Re:Software Engineering at Google (2017) by JustSomeNobody on Friday January 04, 2019 @08:21AM (#18823763)
I don't think it is laziness. Some developers simply can't ever shake off the need to be the smartest person in the room. They have been told all their lives how smart they are. Now among peers, they're ... well ... average and they haven't been given the tools to understand how to cope with that. Some developers never outgrow that, sadly.
Re:Software Engineering at Google (2017) by StreamBright on Friday January 04, 2019 @06:40AM (#18823317)
This makes sure there is never 1.0 ever. I think this is one of the biggest mistake in software. We just keep rewriting things that are already doing what they supposed to. Like the Gmail UI. It got rewritten 3 times already and every iteration it gets shittier.
Re:Software Engineering at Google (2017) by srj on Friday January 04, 2019 @05:56PM (#18828544)
I think you're imagining much larger rewrites.

A system such as Gmail is composed of many smaller parts. If one of those parts was written years prior for a world that has since changed, it may be accruing technical debt as it's continually extended to fit new requirements. An occasional rewrite helps address this type of decay.

Without the rewrite you may find yourself 10 years later with a system that's both critical and kludgy, and at that point the rewrite will be a much larger project.

Re:Software Engineering at Google (2017) by nindalf on Friday January 04, 2019 @08:32AM (#18823847)
> every iteration it gets shittier

I like how you state this like it's an objective fact. I've always been happy with the gmail UI and the latest iteration is great too. Outlook on the other hand...

Re:Software Engineering at Google (2017) by Aeolun on Friday January 04, 2019 @11:14AM (#18825059)
Outlook has always been shit, but at least it has been shit in the same way for the past 15 years.
Re:Software Engineering at Google (2017) by StreamBright on Friday January 04, 2019 @03:48PM (#18827451)
It is not an objective fact but sampling the gmail users around me gives me an idea. Obviously is it not representative.
Re:Software Engineering at Google (2017) by why_only_15 on Friday January 04, 2019 @06:32AM (#18823283)
This is interesting to me because something like this only works if there are lots of tests and they can be run after every change. If you rewrite code constantly and potentially create new bugs by e.g. not understanding edge cases previous developers put in, then this isn't feasible. With a focus on testing this becomes practicable.
Re:Software Engineering at Google (2017) by fergus_google on Friday January 04, 2019 @10:26AM (#18824619)
It's common for code at Google to be rewritten without reusing most of the existing tests -- instead, new tests are written for the new code. Yes, this risks not understanding edge cases. But not all of those edge cases are still important.
Re:Software Engineering at Google (2017) by why_only_15 on Friday January 04, 2019 @10:17PM (#18829674)
Maybe a compromise would be that if you rewrite old code you individually go through old tests and have to sign off on deprecating them, and say edge case X is no longer important, so you keep most tests while not using ones that don't matter.
Re:Software Engineering at Google (2017) by snorkel on Friday January 04, 2019 @07:56AM (#18823627)
After working with banks that still run production code on obscure and obsolete platforms written by people who retired decades ago, I totally endorse this practice ... as long as I’m not doing the rewrite.
Re:Software Engineering at Google (2017) by Radim on Friday January 04, 2019 @08:04AM (#18823677)
The dance between death by ossification and death by excessive chaos is a delicate one.

Be too quick and you're constantly chasing shadows… wait too long and you're immobile.

Re:Software Engineering at Google (2017) by rpod on Friday January 04, 2019 @09:16AM (#18824153)
Hey, I just wanted to say that I really love your gensim library. I've used it for my Master's thesis a couple of years back and it's been a tremendous help. Thanks so much!
Re:Software Engineering at Google (2017) by Radim on Friday January 04, 2019 @09:32AM (#18824248)
Thank you! That's so nice to hear :)

To get on-topic: Gensim could use such a rewrite as well… The ML world changed, expectations and requirements changed, ecosystem and APIs changed. I changed too.

Re:Software Engineering at Google (2017) by yakshaving_jgt on Friday January 04, 2019 @05:43AM (#18823094)
Thanks for highlighting this. To me it seems an important idea that contradicts conventional wisdom, similar in the way that most people over-encourage DRY, blind to the fact it increases coupling.
Re:Software Engineering at Google (2017) by lugg on Friday January 04, 2019 @05:47AM (#18823103)
I frequently find myself drastically refactoring code to understand it. I don't commit those changes because it's not worth the effort to justify the cleanup to people who treat these rules as gospel.

Apparently me spending half a day reading code is no big deal but cleaning it up is a waste of time.

Shrug.

Re:Software Engineering at Google (2017) by quietbritishjim on Friday January 04, 2019 @07:43AM (#18823575)
I think the objections to rewriting code are sometimes justified, rather than just blindly following rules. As you said, refactoring code helps you understand it. This means that you can end up feeling like your code is objectively clearer than before you started, but sometimes it's just an illusion caused by the fact that you just (re)wrote it. If there are other people in the company that already understand that functionality, you're disrupting the effort they put into understanding the old version of the code. Combine this with the risk of introducing bugs or missing some obscure bits of functionality, and there is valid reason to object.

I find this is particularly common mistake by junior programmers (not saying this applies to you), presumably because they aren't used to reading other people's code. Frustratingly, this is often coupled with an attitude that missing out large chunks of existing user functionality is acceptable if it makes the code a bit simpler.

Of course, sometimes rewrites/refactors really are an improvement. Sometimes code really is fragile and confusing, either because of who wrote it or because it has had many small changes tacked on in the easiest places. Or perhaps the last person that understood that code has left the company, so it's OK that you find the code clearer only because you just wrote it! But in any case, it is fair to ask for real justification for a rewrite.

Re:Software Engineering at Google (2017) by lugg on Friday January 04, 2019 @01:58PM (#18826636)
You're talking about rewrites. I'm talking about cleaning up messes left by lazy people long ago, so long ago that most of the juniors are scared to clean it up despite it being impossible to understand without a days reading.

You can say it disrupts others understanding of shitty old code, frankly I don't care. Code is not immutable and maintaining status quo helps nobody except the old guard stay relevant.

Re:Software Engineering at Google (2017) by quietbritishjim on Friday January 04, 2019 @02:17PM (#18826835)
I said:

> Of course, sometimes rewrites/refactors really are an improvement

If that's what you were talking about in the first place, fair enough and my apologies.

Re:Software Engineering at Google (2017) by lugg on Saturday January 05, 2019 @04:14AM (#18830701)
No apologies needed. It was a fair assumption and I do agree with your points, although I think I've come to move more in the other direction the last few years.

Those perfect one line fixes are great but they approach their limits and eventually need to be refactored. This is natural and should not be frowned upon. Likewise you can't just refactor all the time, one line fixes are faster and less costly in all sorts of ways. The key is to pick and choose when to use each strategy.

I think we're too often looking for simple rules. There are none. Just a bunch of guidelines.

Re:Software Engineering at Google (2017) by logicallee on Friday January 04, 2019 @07:52AM (#18823615)
(Genuine question.) Do you think "small changes" shouldn't be "tacked on in the easiest places"?

I'll try to give an example I hope is realistic:

One of the heaviest things an application can get is a complete theme system. Suppose you don't have one. It's not a requirement.

Adding a theme system when there is none is months of work and might impact basically every line of code that displays anything.

So you're not doing it. Now for some exceptional system there is just one case where somewhere you are displaying something under an external widget that doesn't meet its size constraints or whatever - long story short your text is invisible, you want to inverse the font to get it working. You don't have any code like that.

Do you think it is OK to add it to the easiest possible place: in this case perhaps you add an optional argument called "need_to_invert_color" (this awkward phrasing tells you it's a hack) to a single function, default it as false, comment it as: //invert the color of the font. This is needed where an external graphing widget with a black background leaks onto our canvas due to not respecting our pixel boundaries, so that our text displays over it.

And then where you call comment the same thing, that //currently a bug in the widget code makes the widget leak xyz pixels below its bottom border. As a temporary fix we introduce an argument need_to_invert_color into our display function. As of this writing 3 Jan 2019 we are just using it from here. The correct fix would be for the widget to stop leaking instead, and when that is done white text is unnecessary - and we might not notice. So we start by testing whether the area we will be overlaid over is indeed the wrong color.

ETC. In other words a quick hack for a corner case, that doesn't fix the underlying bug (workaround) and even as a hack makes use of something that doesn't exist (a theme system), instead adding and documenting a half-assed thing tacked on.

Re:Software Engineering at Google (2017) by quietbritishjim on Friday January 04, 2019 @01:21PM (#18826310)
Of course this is just my opinion, but in many situations I think tacking one small change on to the easiest place is fine. My comment earlier wasn't meant as a criticism of that practice. It's just I would consider refactoring after this happens multiple times: at some point, all those little tweaks can add up enough that the original design of the "core" code gets lost in the noise.

When exactly is the right time can be hard to figure out. Especially because, if enough hacks have accumulated that code really does need a reshuffle, then the job of refactoring is harder, which actually increases the temptation to put it off. But I wouldn't make a big sweeping change just because of one small hack that's a bit ugly.

Re:Software Engineering at Google (2017) by logicallee on Friday January 04, 2019 @05:09PM (#18828152)
Thanks, this answers my question. I had always thought documenting half-assed solutions was particularly important not just for anyone looking at the code (to understand the whole code quickly, if they're new to it, make changes, etc - or even if the author comes back 6 months later, to be reminded of the assumptions that led to the hacks) but because whoever finally sits down to architect the rewrite will have some indications of the "hacks" (degrees of freedom) that must be made possible in the proper version. I thought they (or I) would sit down, have all the documented hacks on one side of their table, then use them to architect a nice solution that the hacks can then use instead, kind of like a requirements document.

This was my thinking on a lot of projects. But you know what? That rewrite never became necessary!

So not only did I not start with the "right" architecture - I didn't end with it either!

That's what "many small hacks in the easiest of places" reminded me of and I wondered if you in fact do approve of it. It has always seemed fine for me. Just no problem at all. But with documentation right there and the worse the hack, the clearer the documentation right there explaining and justifying it, up to and including "I don't know why this works but this system call makes the next line succeed, whereas removing it causes the next line to fail sometimes - this is tested in testxzy." Obviously a hack, a terrible hack if you don't know why it works. And a project can end up with a lot of these.

Re:Software Engineering at Google (2017) by chucksmash on Friday January 04, 2019 @09:03AM (#18824070)
Working Effectively with Legacy Code recommends just this idea. They call it scratch refactoring. Refactor without a lot of forethought to see how the system works, then just throw away your changes but keep your newfound understanding.
Re:Software Engineering at Google (2017) by lugg on Friday January 04, 2019 @01:59PM (#18826648)
This is effectively "it." But I do like to branch off the more useful refactors into their own commits.
Re:Software Engineering at Google (2017) by pault on Friday January 04, 2019 @10:31AM (#18824654)
I often see some bit of code, or a dependency in a project that I think is over engineered and too complex and start rewriting; first I get something basic working, then I discover some edge case, then another, and another, and eventually I realize that I have reimplemented the original code. It always makes me feel silly, but at the same time those have been the best learning experiences I've ever had.
Re:Software Engineering at Google (2017) by zozbot123 on Friday January 04, 2019 @10:53AM (#18824862)
The proper response to that is to actively document these edge cases (within the original code) so that they don't get missed as the code is maintained in the future.
Re:Software Engineering at Google (2017) by pault on Friday January 04, 2019 @12:23PM (#18825765)
I do, so I can remember how it works when I see it again in six months. :)
Re:Software Engineering at Google (2017) by zorked on Friday January 04, 2019 @08:57AM (#18824044)
Five people understand the system.

You refactor it.

Now one person understands the system.

Re:Software Engineering at Google (2017) by Aeolun on Friday January 04, 2019 @11:23AM (#18825159)
Initially the system took 8 hours of reading and 2 days of refactoring to grasp.

Now it takes 2 hours.

I’ll take that.

Re:Software Engineering at Google (2017) by titzer on Friday January 04, 2019 @04:17PM (#18827715)
Take a moment to consider that someone else in your team might actually understand the code in question, and when you rewrite it (and commit), you destroy their knowledge about how it works. Sure, from your perspective, you made the code better, easier to understand. From their perspective, even if they do the code review themselves, they will not understand it as thoroughly as you do, and they will be burdened with both the knowledge of how it used to be, and how it is now. The net result can be negative, and eventually no one understands any code that they didn't refactor in the last ~6 months, because if it's any older than that, someone's rewritten it.

Sometimes you gotta sit down and bite the bullet and read and ask questions.

Re:Software Engineering at Google (2017) by z0r on Friday January 04, 2019 @08:47AM (#18823977)
Writing code is hard, so there's nothing wrong with reading it being hard too. (I'm only half kidding).
Re:Software Engineering at Google (2017) by blub on Friday January 04, 2019 @05:54AM (#18823140)
Any company that can rely on an ads cash cow and a large, competent engineering team can probably afford to rewrite most of their software periodically. This won't apply to most companies, hence the conventional wisdom.
Re:Software Engineering at Google (2017) by paganel on Friday January 04, 2019 @07:02AM (#18823410)
> team can probably afford to rewrite most of their software periodically

I think Google partially does this in order to keep its engineers happy, as you are more happy when you develop something from the ground-up compared to just maintaining something already built. By going down this route those engineers are kept in a “happy state” so there’s less risk of them flying off to other pastures, where they could potentially build the next product that could “kill” Google. Sort of invisible golden hand-cuffs, if you will. I personally find it tremendously wasteful at a societal level but I can see the value of this strategy for Google as a company.

Re:Software Engineering at Google (2017) by yakshaving_jgt on Friday January 04, 2019 @06:10AM (#18823194)
Like most things, it depends. There are happy mediums between rewriting absolutely everything and making the fewest possible changes. This is true and viable in organisations of any size.
Re:Software Engineering at Google (2017) by Aeolun on Friday January 04, 2019 @11:17AM (#18825097)
Wait, huh? How does DRY increase coupling?

I mean, I guess the duplicate code/class is now coupled to the two places that use it, but I have a hard time seeing how that is worse than two duplicate instances of the code.

Re:Software Engineering at Google (2017) by BeetleB on Friday January 04, 2019 @11:43AM (#18825371)
Here is what I've seen (and been guilty of):

Two pieces of code in different parts of the codebase are very similar. They have nothing to do with each other - even semantically. But the code is very similar. So someone thinks this is code duplication and creates a function/class/whatever that both pieces of code can use. Repeat all over the place.

Then one day, one of those two places needs custom behavior. I can either change that function/class and create complexity (have to now support two use cases). Or I can stop using that function/class in that place and go back to the old solution. Sometimes, this is quite a lot of work as aggressive "DRY" leads to a fair amount of coupling - there could be a few layers of DRY'd code there to untangle.

I put "DRY" in quotes because none of this really is DRY. DRY originally was about requirements - not code. No requirement should show up in multiple places in the code base. In this example, even though the code was almost identical in both places, there was little else common. They dealt with different requirements, for completely different reasons. They should never have been refactored to use a common function/class.

These days people keep talking about over-use of DRY, but they're really complaining about overabstraction of disparate code - not the DRY in the requirements sense.

Re:Software Engineering at Google (2017) by erik_seaberg on Friday January 04, 2019 @04:38PM (#18827891)
This gets back to the https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle. I should be able to override just the behavior I want to change, rather than permanently edit the shared implementation eliminating the behavior you want.
Re:Software Engineering at Google (2017) by BeetleB on Friday January 04, 2019 @05:13PM (#18828190)
A better solution is "Just don't couple the two pieces of code!"

It takes a fair amount of work to design a good class where one can easily apply the open-closed principle. And one should where it's needed. But tying together two completely unrelated parts of your code base with such a class just because the two pieces of code are almost identical is the wrong approach. Then going ahead and designing it for the open-closed principle merely adds complexity.

Re:Software Engineering at Google (2017) by yakshaving_jgt on Friday January 04, 2019 @11:36AM (#18825285)
It increases coupling in exactly the way you just described.

Sometimes this is beneficial. Sometimes it isn't.

My point is — more often than not — conventional wisdom is that DRY is always preferable, whereas the reality is not that simple.

Re:Software Engineering at Google (2017) by dilyevsky on Friday January 04, 2019 @12:49PM (#18826020)
Lots of mental gymnastics to dress up the fact you can’t get promoted without shipping new code.
Re:Software Engineering at Google (2017) by titzer on Friday January 04, 2019 @04:04PM (#18827592)
Disclaimer: I work for Google. I speak only for myself.

In my honest opinion, frequent rewrites are by-and-large a disastrously bad idea, for several reasons. If there is one thing I would change about Google, it would be to slow down the frenetic pace of change inside. Rewrites just make the pace of change untenable. And I say this as one who is totally part of the problem: I helped rewrite significant parts of V8, the JS VM in Chrome, particularly the optimizing JIT compiler, TurboFan. (Don't get me wrong--I am not knocking any one specific project, my coworkers, even my leadership, etc). I've been at Google 9 years, and I don't know how barely any of it works anymore.

1. The assumption that requirements and environment around software change so frequently that it must be burned down to the ground and rewritten is a big part of the problem. Why do the requirements of software change? A. Scale. B. Because the software around it changed. Bingo.

2. Rewrites actively destroy institutional expertise. Instead of learning more as time goes on, engineers' knowledge becomes obsolete as old systems are constantly changing and rewritten for unclear benefit. Experts can no longer rely on their knowledge for more than a couple of years. This is extremely bad for critical pieces of infrastructure. In short, no one ever masters anything. This is due not just to incentives but due to change itself.

3. No one ever has time to do an in-depth followup study on whether the rewritten artifact was better than the original. Instead people go on their gut feeling of having rewritten something they often did not write themselves (and did not fully understand) with something new and shiny of their own creation. The justification of the outcome is done, in short, by the people who have a big vested interest in declaring success. (And yes, me too).

4. The idea that the software requirements keep changing around software is promulgated by the exact same people who never spend any time up front simply writing requirements down. Well, no fracking wonder the requirements seem to change somewhere in the middle or years later: they were never anticipated in the first place! We'd do better overall if the industry in general did some good ole requirements engineering. Most people I talk to have never even heard of this. Instead, we never have any time to stop and think about doing things right, but we always find time to rewrite from scratch.

5. Zero incentive to do things right. As a field, as industry, we are actually not very serious about writing good software. Instead, we're just going to trash it after 5 years. So software is constantly bad. But the next rewrite!

The drive for rewrites is mostly a swindle in my opinion. The reality is that some software needs to be shot in the head, some needs to be rewritten, but most software needs to be just maintained. That means bugfixes, performance improvements, scalability improvements, and sometimes, yes, refactoring too. But bugfixes and incremental performance improvements don't get anyone promoted. Even more cynically, but very realistically, "old" software that is maintained by experts means a dependency on those experts, and they end up being expensive. Corporations hate when their employees have job security! Rewrites are A.) driven by an influx of young talent who want to make their mark, B.) incentivized by the promotion process and C.) driven by a corporate pressure (everywhere, not just Google) to make sure that programmers and software are commoditized to avoid dependencies, bus factor, and job security.

Re:Software Engineering at Google (2017) by Pokepokalypse on Sunday January 06, 2019 @06:17PM (#18841382)
dude.

So much 3, 4, and 5.

I was so spoiled at my last employer. Leaving was a mistake, but I can't go back because I relocated. Seems like nobody in this entire town "gets it". Seriously.

Re:Software Engineering at Google (2017) by austincheney on Friday January 04, 2019 @08:31AM (#18823842)
I have learned this to be true from work on my open source projects. I tried to explain this concept at my previous employer and my boss looked at me like I was stupid. Stupid makes sense when you justify your existence according to story points.

What I have noticed from the travel industry is that backend developers tend to write a ton of original code and rarely refactor anything as though they are scared an improvement is always a regression. Frontend developers tended to not refactor anything either, but then they were scared to write any code at all (note: I am a frontend developer).

Part of this fear was justified because their automation was shitty. Often things were properly code reviewed, but changes would only be accepted with the smallest possible footprint. It hurts when the diff is a static text comparison counting every character, which means a bunch of comments explaining things or white space changes looks like a ton of code changes. It also keeps you from removing unnecessary code or reorganizing things. The killer though were frameworks for everything including test automation in various different flavors for the same sorts of things, which is like writing tests for testing of tests. In this case testing became a block to check off that had little or no real value.

Re:Software Engineering at Google (2017) by MichaelMoser123 on Friday January 04, 2019 @07:05AM (#18823418)
I am wondering if the rewriting rule applies to AdWords and search, I mean they probably would get very upset if their cashcow stops working, all of a sudden.
Re:Software Engineering at Google (2017) by hknd on Friday January 04, 2019 @07:11AM (#18823441)
I think we should not take "rewrite" too literally.

But both, search and adwords, have been rewritten multiple times since their launch.

You can have a look at the papers created by Jeff Dean (1) and Sanjay Ghemawat (2) which mention some of the new concepts/technologies/features used in those products.

1: https://ai.google/research/people/jeff 2: https://ai.google/research/people/SanjayGhemawat

Re:Software Engineering at Google (2017) by MichaelMoser123 on Friday January 04, 2019 @08:10AM (#18823703)
Thanks, very interesting articles!
Re:Software Engineering at Google (2017) by davidwihl on Friday January 04, 2019 @07:16AM (#18823467)
The AdWords API is now being re-written, the biggest change in ten years. It is migrating from XML to gRPC / protobuffers.

https://developers.google.com/google-ads/api/docs/start

Disclosure: I co-author the Python client library and have written a few of the docs on the site listed above.

Re:Software Engineering at Google (2017) by MichaelMoser123 on Friday January 04, 2019 @09:37AM (#18824277)
Thanks for the link!
Re:Software Engineering at Google (2017) by na85 on Friday January 04, 2019 @12:08PM (#18825620)
Productivity hack or make-work project?