Re:Will you hire this guy?
by wyldfire on Friday April 01, 2016 @09:17PM
(#11409752)
`goto` to arbitrary labels can be pretty risky. But `goto` to facilitate a single-point-of-exit for a function is a pretty sane idiom. It's all over the linux kernel and I don't think that anyone regrets it.
So I wouldn't state something like "Even Linus isn't perfect," rather "you should be open minded to learn new development idioms in environments where you're less experienced."
Re:Will you hire this guy?
by Gibbon1 on Friday April 01, 2016 @09:38PM
(#11409817)
Check out the function it's from, it's a classic function with multiple guard exits and normal return at the end. The gotos to a label in an if block is what's amusing. But you can see why he's doing that, he has exactly one exit per returned error type.
Re:Will you hire this guy?
by vskarine on Friday April 01, 2016 @09:32PM
(#11409793)
Agree with you. My first job out of college was working with C code on embedded modem software and when I saw this pattern and was like WTF?! but then realized how useful it is to have single point of exit in a function (especially in embedded systems code).
Re:Will you hire this guy?
by Gibbon1 on Friday April 01, 2016 @09:42PM
(#11409829)
Often it's very useful to have separate returns from functions for errors. The reason being you can set a break point on the error return and then let the code run. The code will run normally until the error occurs, which in some cases may take days.
Re:Will you hire this guy?
by mikestew on Friday April 01, 2016 @08:50PM
(#11409657)
I'll use the "vouch" function for the first time ever, because if you think Roman's an idiot, congratulations, you're in the running for World Champion of Missing the Point.
Lest you doubt me, let me quote the final sentence which you probably didn't read after the first, and impulsively felt the need to run back to HN and show everyone how smart you are: "Author of this code is Linus Torvalds. This world is not perfect and your judging based on small peice of code just doesn’t work."
IOW, Roman might very well know C better than you do, and ironically folks like you might be the reason he wrote the post in the first place.
Re:Will you hire this guy?
by nhaehnle on Friday April 01, 2016 @09:35PM
(#11409809)
It's not clear without more digging who the original author of the code is. Somebody pointed out that it's from drivers/usb/core/hub.c, but the blame history doesn't go further than the initial commit of the repository. That's why it's attributed to Linus Torvalds.
Most likely, the code evolved in a way that makes the goto look sillier than it did in the original version of the code.
Re:Will you hire this guy?
by ChuckMcM on Friday April 01, 2016 @09:50PM
(#11409852)
I suppose I should be happy that some Fortran code I wrote back in school wasn't in Github. One of the things I look for in people is their ability to learn, and to do that they have to challenge themselves, to re convince themselves when they do something that it is still the right thing to do, the right path to take, and when they discover new information or new insights they adapt their behavior appropriately.
It makes me wonder if folks growing up in the permanent digital foot print age will be able to escape their early years. There is a reason police records for minors are often sealed, so as adults the things they did as kids don't permanently stain their lives. It is the basis for the right to be forgotten movement in the EU as far as I can tell.
Re:Will you hire this guy?
by Xyik on Friday April 01, 2016 @09:08PM
(#11409716)
Seems just like click-bait, author makes a point but doesn't really go in depth or explain his thoughts. And it only works because the author tries to mislead you : 'This code smells' Why does it smell exactly? Why should he work at Starbucks?Don't judge a book by its cover, don't extrapolate on a single data point, or a single piece of code, got it.
The use of 'goto' in C to separate error-handling code from main-line code is a commonly accepted practice.
Also, "goto" isn't an operator.
So I wouldn't state something like "Even Linus isn't perfect," rather "you should be open minded to learn new development idioms in environments where you're less experienced."
Lest you doubt me, let me quote the final sentence which you probably didn't read after the first, and impulsively felt the need to run back to HN and show everyone how smart you are: "Author of this code is Linus Torvalds. This world is not perfect and your judging based on small peice of code just doesn’t work."
IOW, Roman might very well know C better than you do, and ironically folks like you might be the reason he wrote the post in the first place.
As for the other comments, I'm thinking I'm reading this quite differently than others. That's cool, that's why we have a voting system I guess.
- the code is "awful"
- the programmer "doesn’t know basics"
- "goto statement in C" is somehow anathema
Most likely, the code evolved in a way that makes the goto look sillier than it did in the original version of the code.
Direct link: https://github.com/torvalds/linux/blob/48d10bda1f2c69980601a...
It makes me wonder if folks growing up in the permanent digital foot print age will be able to escape their early years. There is a reason police records for minors are often sealed, so as adults the things they did as kids don't permanently stain their lives. It is the basis for the right to be forgotten movement in the EU as far as I can tell.