293 points · by jgrahamc · 14y ago · 136 comments
So I would go in and "fix" things... only to find out a month later that the code was the way it was because of some obscure edge case that I had never thought of. It turns out that in my arrogance I was the dummy all along.
After that happened a couple of times, I stopped approaching strange code with that attitude. Programmers are in general pretty clever, and if you see something strange in some code, don't assume it's because they're dumb. At first assume it's because you're dumb, and only change your mind if careful and deliberate analysis--and talking to someone else with history in the organization--proves otherwise.
Then all of a sudden, you don't need to waste time on careful and deliberate analysis, and hunting down people who might know about it, and making assumptions, because the 2 minutes it would take to write a few lines of explanation would save you all of that.
At which point, the real question is: why did they choose not to document this non-obvious solution, and the edge case that required it?
From my personal experience with "corporate programming", the usual suspects are:
1) corporate culture that dictates that you need to get the code out ASAP and let someone else worry about maintenance
2) original author's assumption that he/she will be the only one to touch that code
I've been guilty of #2 before I learned that even if I am the only one to touch the code, if I wait long enough before I come back to it, I'll still have the same problem as a newcomer would.
As for #1, this is a typical corporate culture for any company whose business isn't producing code (and for quite a few whose business is precisely that).
When you get familiar with a domain it is very easy to get blind to what people without exposure to it will consider obvious or not.
4) Documentation that is held separate / made in different systems. That diverge over time. Or, one failure in training of the new guy is to not provide them a good overview of the documentation system(s). And/Or, the documentation organization and systems are cumbersome to the point of being unuseful, unless you already have a pretty good idea of where stuff is (and isn't -- all those empty forms that end up being ignored).
Unfortunately, three months from now, "someone else" is you, and "getting the code out ASAP" means figuring out the spaghetti code you wrote but no longer understand.
In the long run, doing it right the first time helps us go faster. Therefore, it's part of the programmer's job to resist pressure to do it wrong.
For example, you could have one 10-line method, interspersed with comments, or you could have a hierarchy of method calls, each with a name so clear that it needs no comments. The second method is less likely to get out of sync with what the code actually does, and it's more testable.
This the lesson that stuck with me most from Clean Code, which I highly recommend.
Not trying to pick on you, but every time I see someone implying that "naming things better" is a panacea, I want to throw it out there that sometimes, nothing beats a good comment to explain (in natural language) what's going on here.
// It may look as if you could just say p->adjust() here,
// but that doesn't work because of a subtlety involving
// cancelled credit cards belonging to purchasers in Uganda.
// Please tread carefully!
... And then, if talking to another human being is the only real way to grasp what's going on, you use your version control system to find out who added that comment and go talk to them.If the code isn't the clearest comment you have, you're doing it wrong.
Comments are a crutch for people who write poor code. Comments have zero authority or guarantee of accuracy, and more often than not have little correlation with the actual code.
Code is canonical. Comments are noise.
Business logic is complicated and rarely defined by a developer but by a product manager. Often you can understand what's being done in the code, but the WHY is necessary to understand why it's there and what it is trying to do. I believe giving a brief synopsis of the business logic in a method comment and, if it's not super straightforward, a brief overview of the steps or algorithm, is incredibly useful.
I guarantee you won't be able to figure out what your program is doing by looking through years old wikis left by product managers no longer at your company.
Donald Knuth, who gives money to people who spot bugs in his code, even invented literate programming to mix prose explanation and code better. Is he an idiot?
This paradox rests on the most elementary common sense. The gate or fence did not grow there. It was not set up by somnambulists who built it in their sleep. It is highly improbable that it was put there by escaped lunatics who were for some reason loose in the street. Some person had some reason for thinking it would be a good thing for somebody. And until we know what the reason was, we really cannot judge whether the reason was reasonable.
I rebuilt a messy WP blog (i18n hardcoding, dead code, etc) from scracth. Turns out the weirdest thing they did (perverting category/post system using additional metadata) .. they did it because of a weird bug the most important plugin they needed which was not open source anymore. Hit me right in the face.
As someone mentioned earlier, one has to explain everything in the system. The code is only the tip of the iceberg.
Maybe the ratio isn't one to one, but please, please don't just give up second-guessing ugly code.
I have to disagree with this statement and the article. I've asked some of these questions in the past, and the reason I ask is because I'm curious, not because I'm trying to call anyone "dumb".
The fact that people try to understand the underlying technology of such a complex mission, and later followup with a "why" question, simply shows how the general public is interested in these events.
I'd be more worried if people didn't ask any questions at all, implying that they do not care for such scientific and technological breakthroughs.
Indifference can be a dangerous thing.
It is the desire for knowledge.
I loathe semantic games in arguments as much as anyone, but I too often see "ignorance" being given some kind of special place in science, where it doesn't belong.
There's a reason why NASA didn't just dedicate 8 years, $2.5 billion, and a tremendous amount of human effort to land a rover called "Ignorance" on another planet.
Curiosity: in this glorious age of Google, Wikipedia, Wolfram-Alpha, and so many other free and readily available resources, it doesn't start with the words, "Why don't they just..."
It is not ok to just go "they should have done it this way" without consideration for the millions of factors and limited resources they have
Especially from some people that have no idea how hard it is, how hardware can fail in hundreds of ways, how things are harder in a slower processor, in low level programming, in real time app
"Oh but they should have used Erlang/OCaml/LISP/JavaRT/NodeJS for that they are soooo stupid" SHUT UP
They did it, not you, and they have to live with the consequences, not you.
The point is that it's foolish to assume you know better than someone, particularly when you are unaware of the background to their decisions. And doubly so when the someone in question is as smart as the NASA/JPL staff undoubtedly are.
Dumb questions can have interesting answers. Even if people don't ask them nicely.
Of course, as you point out I didn't mean to say that I know better than the guys at NASA. It's meant as "The way they do it seems strange and non-intuitive, how come they do this?". I agree that I could've worded that better.
That being said, I disagree when you say "It doesn't take much research to find the answer". Case in point, my comment:
"Why don't they just put a camera filming downwards to determine the ground speed? Wouldn't it be simpler and more reliable?"
I don't think any of your "answers" addresses this specific question. So it boils down to "Because it's on friggin' Mars, doofus". When I posted the comment, I hoped someone around here had an explanation for this (after all, determining a ground speed is something even non-space exploring robots need, I'm sure :).
But again, I agree the wording is awkward and comes off as pretentious, but do believe that it wasn't anything but genuine curiosity (sic).
For instance, people have everyday technology in hands and they believe, if the ordinary Jane/John Doe has a multi core processor smart phone costing them 1000$ with manufacturer margin, NASA/ESA/JPL whatever guys with millions of dollars of funding has to use better and faster and fancier hardware. And by being ordinary John/Jane Doe, fancier does not mean "radiation hardened", "autonomous in hostile environment", "updatable on slow and relayed links". Because these are not their daily problem. They do not know about them. Also if Apple/Samsung/Motorola heck even Nokia guys could design and mass manufacture, and distribute any smart phone in a few months to be held on john's or jane's hands, NASA must be a fricking snail fast. How distant could Mars be? I can transport from continent to continent in a few hours?
Don't be harsh on them.
Some of the questions may seem dumb, but may be really good questions if they are worked on. For example, I believe radiation hardening is needed because while transportation to Mars there is massive amounts of radiation to be moved through. If the Curiosity would not be operated in the journey, and Mars radiation levels are not that massive. Could Curiosity use multiple (with spares of course) faster and cheaper ordinary processors with small energy footprint, if the transportation was inside a radiation hardened armor that would be gotten rid off on the Mars surface?
Perfectly reasonable question though.
I now listen for the word 'just' when other people are pitching ideas, or forming repsonses and tend to ignore what is said next as I suspect they too have put little thought into the statement they are about to make.
I'm not sure this is a great general case recomendation, but it has helped me in my parsing language for possible stupidity.
Thing is, unlike the average folks with lofty ideas of self-serving "fixes" for every irritation in their lives, people in technology aren't just consumers from a distance - they're builders, maintainers and influencers.
It's a dangerous problem when these "active" people don't understand context, concessions, dependencies and just generally what it takes to actually create things in the real world.
I believe it's one of the roots of various stifling attitudes of conformance and covering your ass above real, forward homegrown engineering.
Apologies if that doesn't make sense. I had a hard time trying to articulate my ideas there.
Iff you have ten, twenty expendable machines then you don't need the same level of QA, thus opening up a lot of interesting possibilities. If we can get equivalent amounts of exploration done in just half (or maybe quarter) the cost then it opens up room for an arms race of sorts where each generation can be rapidly iterated upon and we can plan such missions within a one or two year timeframe instead of an eight year one.
Of course, this is easier said than done... ;)
If you enter this paradigm then you can eliminate costs such as that long arm which you need to position the instrument package. That arm in of itself is an engineering marvel and it requires a lot of careful design to make sure that it doesn't malfunction. (remember you have a not so light weight at the end, the torque due to that is huge and you have a complex assembly consisting linkages to transfer torque and so on...)
The idea of this is to see how simple and redundant you can make things. If for the cost of that arm we could have one small team of rovers wouldn't it be worth it? Wouldn't it jump start exploration?
Also "Why don't they just" has multiple meanings in my opinion. You explained one of them, a sort of incredulous question querying the stupidity of the people who made those decisions. But it's also used far more innocently as well. I and a lot of my friends will ask questions in that format but as a genuine query not meaning to tread on anyones toes or insult anyone. (I'm having trouble articulating this!)
This sort of question asking isn't the exclusive domain of Mars rovers either, it's everything. Politics, economics, business etc etc. It's just natural human curiosity, people trying to understand things that seem counter intuitive at first.
From what I see, it looks like most readers interpret that phrase as an arrogant arm chair expert assuming NASA, or who ever, are full of really stupid people and the person "asking" is essentially suggesting he knows better. The simpler interpretation that a person who knows they don't know is simply asking is often the secondary thought, if that thought occurs at all.
I think that has a lot to do with the combat nature of on-line "debate". People now are sort of trained to expect confrontation rather than a mellow old chat. Kinda ties in to a recent thread here about , er, negative and harsh replied to Show HN articles.
This is one of the things I'm beginning to really not like about on-line discussions. I end up spending more time trying to make sure I'm not misinterpreted than making my actual point.
I bet if NASA had had a competition to come up with the most likely to work gizmo, up to 1 lb (or whatever) we'd have seen some pretty good ideas (beyond duct taping an iphone to the antenna mast)
I was trying to find an easy CSS hack to make the layout impervious to long words but it turned out to be a little tricky. Can anyone find a CSS "one-liner" (few-lineser?) that'll fix this?
Hardware is hard to fix but software is do-able. There is a lot of explanations how this was done with Pathfinder:
http://research.microsoft.com/en-us/um/people/mbj/mars_pathf...
http://chronicle.augusta.com/stories/2004/02/16/liv_404763.s...
http://queue.acm.org/detail.cfm?id=1035610
there was also some reconfiguring of Curiosity on-going/completed ~ http://blog.chron.com/techblog/2012/08/nasa-about-to-perform... there is also a lot of work done on 'self healing' software systems ~ http://www.zdnet.com/blog/emergingtech/self-healing-computer...
The real problem is that it's hard to tell the people asking questions like this out of truly interest apart from the people being undeservedly condescending.
I suppose the most important thing is to phrase questions like this carefully and to be polite. I think it's also useful for the answerer not to assume bad faith unless it's very overt. A presumption of reasonableness from everyone would markedly improve discussions about projects like the Mars rover which generally contain very useful information and insight but can get side-tracked by the very issues this article talks about.
If we are going to be making these efforts at Mars in the future (whether autonomous or manned) it seems worth the investment :)
Would that really change anything? A higher bandwidth between the rover and Mars's lower orbit will not make the link between Mars and Earth much faster, and that's the true bottleneck.
Not to mention wireless communications are not "free" as any smartphone owner probably knows and the rover's daily energy budget is pretty much fixed, the more the rover stays in contact with Mars's lower orbit, the less energy it has to drive around or fire its lasers.
And finally, for what it's worth, the MRO is already "significant improve[ment of] coverage".
Yes. The rover is only in communication with its satellite for a limited time frame each day, and the satellite <-> earth link is wider than the satellite <-> rover link. With more satellites we could have around the clock high speed link up, and improve the bandwidth - future missions are likely to be loaded with more and/or higher bandwidth sensors.
Are you sure? My understanding was that the biggest bottleneck lay in the fact that the orbiters could only communicated with the lander for 8 minutes per day.
Fairly crippling :)
> Not to mention wireless communications are not "free" as any smartphone owner probably knows and the rover's daily energy budget is pretty much fixed
I understood the energy source gave a fixed output - it's not a daily budger per se. So 2 hours communications (rather than 8 minutes) wouldn't leave it unable to move for the rest of the day.
I could be wrong.
However; if it takes a week to send it an update - or to receive big pictures - that implies delays in its work anyway.
I agree that the MRO is a significant improvement. I was just idly pointing out that if the aim is to go to Mars more it would be worth investing in infrastructure as much as science.
The algorithm part is equally simple to explain. Most of these algorithms aren't broke, so there's no real impetus to fix them. The equations are pretty well known, so between missions, there's really not a need to change them up.
This doesn't seem quite right. From watching documentaries on the past Mars missions, it seems like each piece of scientific equipment is done separately by various engineering groups around the U.S. and the world. They are only integrated at the end. And those individual pieces of equipment are getting changed right up until the deadline if they aren't working up to spec.
So the requirements are eight years old, but the tech isn't necessarily. They are just very conservative in their requirements.
For example if others haven't been asking this question we wouldn't got this explanation. And now that I got this explanation of NASA's process I would like to know "Why don't they just make all this process more agile?"
For example why have only one launch in 7 years with expensive hardware? Why not multiple launches with cheaper technology?
> But rather than explaining all this stuff, I think there's a
> better way: build, land and operate a rover here on Earth.
Is this implying that building a rover here would provide an explanation for their technical choices? With a 2kg payload limit for a balloon-launched rover, you might be better off with the latest technology. GPS on a chip rather than separate components making up GPS circuitry. Or a tiny, power-efficient mobile chip rather than some power-hungry chip from a decade ago.For example, build everything around the Camera, but make sure that when it's within a year of going up into space, the design is such that the highest resolution camera available can take the current camera's place.
Of course, anyone who has worked on the project will easily be able to say that I have no clue. And I don't. But I guess that if I were included in the planning stages, and it came down to the data collection components of this machine, the first thing I would add would be that it should be capable of upgrading to the latest and greatest within a year of launch.
As a final note, I understand that they DID do this with software. They can update the operating system and roll back. They can advance the software, bug fix, etc, in a VERY safe way from afar.
Then I got a job with a company that manufactures sensors used by a huge number of companies and governmental departments, including NASA and Boeing. And my job was Output Smoothness Technician -- which meant that I was the one guy who was responsible for verifying the electrical specifications of every single part that left the plant. (The next two steps were QA -- which tested things like watertightness -- and then shipping.)
I learned a lot from that job. I learned that there are a lot of decisions behind every single little thing. For example, let's take the tiny little linear potentiometers that Disney uses in its animatronics. Someone at Disney decided they needed them; one team of engineers came up with a spec; another team of engineers figured out how to turn the spec into something that could be made; another team figured out how to make it. Then someone decided what kind of metal to use. Someone else decided how to tune the potentiometer to provide the desired output. Someone else decided what kind of grease to use. And then during manufacturing, someone decided whether or not the housing was good enough, someone decided whether or not everything fit together right, someone decided whether or not the weld was good enough, and so on.
By the time that little thing got to me, there were thousands of little decisions stored in it. Some good, some not. Then I had to test it and decide whether or not it would do what the customer wanted. Should I throw it out, wasting the company a lot of money? Or should I ship it, and let the customer decide, and hope the QA on their end is better than me?
I pretty quickly developed a reputation as one of the toughest OS techs they'd ever had. I threw back a lot of parts. The sales manager (who basically ran that location) hated my guts. But we still had defective parts come back every month!
Now imagine that you're trying to build something that you can't service, and you can't fix. You get only one shot to get it right, and a lot of money and a lot of people are riding on you. Best of all, you're building it to survive in an environment that you just can't really create here on Earth, so you don't get to test it the way that you'd test a lot of things.
That's why it takes 8 years and a lot of money: because it's very, very hard.
I think that one day sending things to Mars will become something that we're used to, and at that point, it will get a lot faster and a lot cheaper and a lot more reliable. But, right now, we're still trying to do things that we don't really know how to do. That's hard, and it takes time.
Further, since it's not practical to test things on Mars, so you can imagine how difficult this can be for the engineers here on Earth.
The process described here is typical of many companies because it's not possible for one person to do all of these steps. The level of expertise required is too high. You may be a great mechanical engineer, but do you know about the performance characteristics of the hundreds of different kinds of grease? About the way the sleeve should be machined? There's a list of specializations thousands of items long, and at best you'll be able to truly master only a small percentage of these even through a whole career.
The ultimate reason technology is unreliable is because the world is a complicated, crazy place that often exposes you to situations you're not prepared for.
Instead, let's consider that everything ever built will fail under a certain set of conditions. Understanding a particular component's reliability means understanding all the things that are likely to go wrong over its lifetime and fixing some, and characterizing others. The many people working on different parts is an outcome of different concerns seeing different problems and applying solutions. These solutions are sometimes contradictory: a weak potentiometer shaft may be improved by using a particular alloy of steel instead of, say, aluminum. But now that alloy may make the part too heavy, or too expensive, or it may create problems for the bearing it has to sit in, etc.
What you see in the long development time isn't that something is necessarily "unreliable" it's that it takes that long to understand how it can fail and make it reliable enough to sustain the mission. This is already why engineers will tend to use tried and true parts: they already understand them completely.
To me, eight years to build and test equipment to fly to Mars and wander around on another planet's surface is a pretty reasonable turnaround time.
Radiation? What does radiation do to electronics? Do they corrode? Will things short circuit?
Would shielding an iPhone be more expensive than using outdated parts?
Do we know that the iPhone isn't reliable enough? Mine seems to be fairly reliable. Any problems with it are solved by a simple reset. Certainly a small bit of old battle tested code/hardware could handle this problem. Is the benefit of having modern hardware not worth it?
I'm sure all of these questions have answers, but it's not like I know where to find them.
Sidenote - "Why don't they just" shield the electronics rather than making the electronics itself radiation proof? I ask that knowing that there is a legitimate reason (shielding weight?), but it is something I have sincerely often wondered.
PS: If you added up the entire mass of everything ever put into orbit you would not be able to make a shield to guarantee normal equipment would be able to stand a 5 year mission in space.
Now, if you're wondering how better to phrase your questions of this sort, I'm afraid I don't have any specifics, because I'm not sure if I'm just as guilty of this, or if I've successfully rephrased my questions of this sort. What I do is try to imagine that I've spent years designing, building, and debugging the thing in question, and gone through multiple reviews by outside organizations where every design decision was scrutinized, and had many meetings with coworkers (formal and informal) to discuss the thing in question. And then I ask my question in the affirmative, rather than in the negative, such as:
"Why did you do X, would Y also work?"
"I would have done Y. What is it about X or Y that I am missing?"