9 ms·
If You Call Out Bad Code, Make Sure It's Bad First
- monkeyfacebag 14y agoI found this article helpful. I was very surprised by the quality of the code in the replace.js repo given the vitriol that surrounded it. I'm not a big contributor to open source, but I've recently made some modifications (improvements?) to a Haskell library I use and was planning to make a pull request soon. This event gave me pause. As someone who couldn't tell what was so eye-bleedingly bad about the replace.js code, I was nervous that I would endure a similar fate.
- mpyne 14y agoLikewise, I've been meaning to convert my local projects at some point and post them to one of the newfangled online git repos. I was going to use GitHub or Bitbucket to avoid saddling my crap on the git hosting I have available from the open source project I develop for, but now I'm not so sure GitHub is the best place for that. I don't mind the code being publically-accessible as the price for free hosting but I have no interest in being hounded about my personal scratch code either.
- saraid216 14y agoFor what it's worth, I've been on Github for years and no one has even noticed that my code exists. Which I don't mind at all, given all of this.
- yusefnapora 14y agoBitbucket offers unlimited private repos, so you can stash your personal stuff there without fear of roaming assholes. They only start charging once you have more than 5 contributors.
- LVB 14y agoshould it exist at all? Quite an arrogant evaluation criterion IMHO.
- DannyBee 14y agoYou are just angry you didn't get picked to be on the secret GitHub Code Evaluation Committee.
- up_and_up 14y ago> Now, I’m all for bad projects and bad code being called out. Bullshit, sorry. Questions to ask yourself before "calling out bad code". 1. Does this code belong to someone on your team? 2. Does your code rely on this code? 3. Does the code represent a risk to you or your business in some way? 4. Do you have the direct contact info for the developer so you can appropriately, discretely and professionally inform them about their code? Github == "Developer Playground/Experimentation Lab". Why in the hell should I have to feel that every piece of code I put up there 'must' adhere to 'your' standards or anyone else's? How can we as a development community rationally expect to grow the open source ecosystem and encourage people with this type of snobbery?
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- MartinCron 14y agoHow can we as a development community rationally expect to grow the open source ecosystem and encourage people with this type of snobbery? There's one lesson that I'm personally taking from this, after unsolicited ridicule, one sincere apology, one bullshit non-apology, and one arrogant I have nothing to apologize for! If I build a small thing to scratch my own itch (which I often do) I'm going to think twice about sharing it with the world at large. Or, more succinctly, I've become yet more of a misanthrope. Thanks guys!
- CodeMage 14y agoLet's face it, there seems to be nothing anyone can share on the Internet without someone else demonstrating John Gabriel's Greater Internet Fuckwad Theory [1]. I'm not saying everyone should always just let it slide, but try not to let it get to you, either. [1]: http://www.penny-arcade.com/comic/2004/03/19 http://www.penny-arcade.com/comic/2004/03/19
- 14y ago
- noonespecial 14y agoI propose a solidarity movement: Heather Arthur day: On this special day we post useful code that we might otherwise be unwilling to post because of what other people might think of it. Because some people have the courage to do this anyway and when they do, it makes the world a better place. If just a few people do this, they might be considered crazy and laughed at, but if all of us do it, why then we'd have a movement.
- mpyne 14y agoWe'd run out of calendar days if we had a "solidarity day" made up everytime something like this happened.
- noonespecial 14y agoI think you just made a very important point.
- saraid216 14y agoThat's why you pick one particular incident and then use it as an anchor point for all the other bad incidents to refer to. This is how all other solidarity days work.
- graue 14y agoIt's a good start, but this shouldn't be a special day. It should be every day.
- petercooper 14y agoI agree, but the common problem there is you get people spouting all the "stop reinventing the wheel!", "looks like NIH syndrome" or "it has no tests so it's irresponsible to release" type lines. This sort of disdain is frequently done politely and seemingly accepted by the community at large even here on HN.
- pjungwir 14y agoI had the same idea: Ask HN: What is your dumbest project on Github? :-) https://news.ycombinator.com/item?id=5112546 https://news.ycombinator.com/item?id=5112546
- Hupo 14y agoThe way I see it, writing command-line utilities in Node is really no different than writing command-line utilities in Python. Both offer a nice scripting environment, and while Node is more web-oriented, there's still quite a bit of libraries out there to do stuff with, making it potentially perfectly suitable for writing an utility for doing X. Hell, I personally even consider it somewhat more attractive than Python in this regard because Node has no equivalent to the 2.X/3.X compatibility mess that Python has. (Python wins in having more "general purpose" libraries, though, making it potentially more suitable for not-directly-web-related-development in nature.) And while this was mentioned a few times in the previous thread, it bears repeating again: There are quite a lot of people out there using Windows, which includes developers. Node is a first-class citizen on Windows, and grep, sed and friends won't be there out of the box for you. A properly done Node command-line utility is generally more cross-platform than a shell script using grep and sed would. And there's quite a bit of command-line utilities made with Node out there (most revolve around web development, such as build tools like grunt and things like CoffeeScript/TypeScript/etc compilers), so it's not like this one is unique in that regard either.
- pbiggar 14y agoAnother issue in the "is Node right for this" is that it's very very portable, significantly more so that shell scripts (Mac uses BSD utilities, windows has nothing unless you have cygwin), and even slightly more portable than python.
- Moto7451 14y agoNot sure I follow. OS X comes with the Bash shell and I have plenty of shell scripts (bash and perl) for automating my dev environment and numerous other tasks that run fine on both Ubuntu and OS X. OS X using FreeBSD as its Unix layer doesn't preclude it from interoperability with other *nix like systems.
- pbiggar 14y agoThere are differences between BSD and GNU utilities that manifest a lot. ps uses different syntax. find has a different output style. grep doesn't support -P.
- FooBarWidget 14y agoIf you've ever seriously written shell scripts you'll know that they're not 100% portable. You always have to go through hoops to make them work properly across operating systems systems. BSD and OS X come with the BSD userland tools, with the exception of bash being default on OS X. Linux comes with the GNU userland. A few differences from the top of my head: - BSD utilities do not accept any -options after filenames, GNU utilities do. - The situation is reversed for BSD find. It insists on accepting a directory name as the first parameter. - BSD sed doesn't support the -i option in the same way as GNU sed does. - Even different versions of GNU utilities are not necessarily compatible. A few years ago I ran into compatibility problems with 'head', 'tail' and even 'free' across different Linux distros. I can't remember the exact issues though. So I agree with the grandparent, Node and Python are a lot more portable than shell scripts.
- Moto7451 14y agoAh I misunderstood the comment to mean the facility just wasn't available (being lumped in with Windows) which struck me as odd. I generally just wrap things in checks for $OSTYPE and Perl when I'm not working with the system itself.
- erock 14y agowho is Heather Arthur, and why they hell does she have 3 posts up on here about some people's opinion on her project. get over yourself, and move on, seriously.
- sbank 14y agoI see many comments from people saying that they are more hesitant about participating in open source after this. That they have been working on some code and will now think twice before they put it out in the open. It makes me sad. Please don't let this deter you! I know how it feels. I was literally shaking when I put my first project on GitHub. Literally. The second time too. And the third. Still am. Still scared of making a fool of myself, but I know what a great learning experience it is and that it benefits my career, so I force myself to do it. Add to that the fact that it is a ton of fun, and every single star a project of mine gets (and the stars are few) makes me proud.
- anon1385 14y agoI write software because I enjoy it, not to advance my career. I enjoy interacting with real users of my software, solving their real problems. Contributing to open source is not enjoyable because many of the people you have to interact with are so obnoxious, so I rarely do it. Not everybody is trying to pimp their CV. For example today I found a memory leak in a popular open source library. There's a good chance it is installed on the computer you are using right now. It never even occurred to me to submit a bug report or patch because when I have submitted patches to this project before one was completely ignored (somebody else fixed the issue 6 months later) and the second time I got flamed (that crash causing bug still exists as far as I know). I have about half a dozen local copies of projects related to things I'm interested in that have various improvements or fixes that will probably never be submitted back to the project, and I don't think I'm unusual in that. Most of the issues are fairly obvious and tend to get fixed eventually anyway.
- Osiris 14y agoI haven't made any source code public, probably a lot for these reasons. I'm been thinking lately about working on getting a QA management tool open sourced. I believe that the community will be better off if we continue to participate together as a community rather than withholding because we're afraid of getting our feelings hurt.
- weego 14y agoThe endless conversation tennis using HN as a traffic-driving net is getting really tiresome
- mmariani 14y agoThat's good advice in the same spirit here's another one. Don't trust in neat websites nor in pretty documentation; always read the code first.
- moccajoghurt 14y ago> I won’t claim to be great at this, but it’s something I spend time on trying to improve, even if it’s at the cost of learning some new language or framework. It’s an ongoing process, and this blog post is part of that process. This basically means that he could have been one of the guys who called out the badness of the replace code and just took the opportunity to get some attention by posting about a hot topic.
- graue 14y agoI see a lot of people saying you're going to keep personal projects to yourself (instead of putting them on GitHub or similar) because of this fracas. Please don't. The Twitter snark isn't normal, it's an exceptional case. It wouldn't be on the front page of HN if that kind of behavior were the norm. And it's the jerks on Twitter who came out looking bad here, not the author of the code. I really like how GitHub has encouraged people to err on the side of releasing their personal experiments. I was doing it myself in pre-GitHub days by publishing Darcs repo URLs on my website, but it didn't have the social aspect and Darcs never caught on like Git has. It's lovely to see the idea of "share all your code, by default" so validated as it is on GitHub. Whether or not you release your code, assholes will still exist and they'll still find a way to be assholes. So don't let them ruin a good thing.
- sillysaurus 14y agoThe Twitter snark isn't normal, it's an exceptional case. No, this isn't true. It's completely normal. It's been normal since long before Twitter. In exactly the same way high school bullying is normal, this is most definitely (a) prevalent, and (b) a problem. But it won't change, because people tolerate it. You want me to open up my personal projects? It's not going to happen. It won't happen because we live in an ecosystem where the top dog is the one who barks the loudest, not the one who's most productive. People pay attention to what other people say. And there is nothing anyone could say about personal projects except "Pretty cool" or "Damn, what a steaming pile". The first is nice, but I'll get by without it. The second serves only to lower me and my ideas. I don't want my capabilities (ideas) to be constrained by others' lack of imagination.
- BCM43 14y agoCan you link to other examples of this happening?
- king_jester 14y agoYou can visit Twitter periodically for a week and see this happening everywhere, programming and dev hash tags included (heck, a lot of the trending topics on Twitter are hugely racist or sexist).
- debian69 14y agoI was with him until he said he'd didn't know what YAML was :(.
- DeepDuh 14y ago.... at the time. Jesus..
- fernandezpablo 14y agoI just gave the code a quick look and I find this `eval` usage not too cool: https://github.com/harthur/replace/blob/master/replace.js#L41-43 https://github.com/harthur/replace/blob/master/replace.js#L4... It relies on the fact that you can provide javascripts String#replace a "replace function" (1). The author just evals the contents of a command line provided file into a variable called `replaceFunc`. Beside that, there's not a lot that can be pointed out as "bad", at least by just reading it lightly (5-10 mins). [1] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
- VMG 14y agoIt might not be optimal but the set goal couldn't be achieved differently without much overhead. It's a valid use of eval in my opinion.
- klibertp 14y agoAs VMG writes, it's one of a few places where 'eval' is the right tool for the job. In this case you either have to drop the feature (of providing replacement function), implement your own language/DSL that compiles down to JS function or just use eval. What would you do in this case?
- pjungwir 14y agoI'd still like to know how these jerks even came across Heather's code in the first place. I suppose I should be grateful for obscurity. I even have a command-line utility written in C to count from 1 to 10. (Well it does a little more than that, but that's the general idea.) I'd hate to hear what they think of it. I'm not really a C coder so I'm sure it's fairly ugly, and I suppose they'd say it "shouldn't exist at all." In fact I've got all kinds of silly/pointless projects stashed up there--even a few that I'd say shouldn't exist. Heaven forbid I ever become famous enough for people to take a look! These guys seem to have all the maturity of kids egging someone's house. Who asked for their opinion anyway?
- gjulianm 14y agoWell, now I'm curious for that CLI. Why do you need an utility to count from 1 to 10?
- pjungwir 14y agoJust shared this on a different thread[0], but here it is: https://github.com/pjungwir/range https://github.com/pjungwir/range [0] "What is your dumbest project on Github?": https://news.ycombinator.com/item?id=5112546 https://news.ycombinator.com/item?id=5112546
- jsnell 14y agoI use the standard Unix utility "seq" almost daily as part of shell one-liners. Lots of things are named with a sequential component. Sometimes iterating over those is easily done with a shell glob, but sometimes it's just simpler to do "for i in $(seq 1 8); do restart foo-$i; done". It's very useful, but basically impossible to discover except by happening to see somebody else use it. So I really don't wonder that somebody would end up unknowingly reimplementing it.
- monksy 14y agoI think this is a matter of poor critism. There is a strong suspicion that the code isn't all that useful. It ignores the tools that are available. Its great that the person wrote it, but there are certainly better options out there. Oh well.. good on them for releasing it. Its a learning experience. On the otherhand I think this is stating to reveal the less than stellar aspect of open community based/social projects. Not everyone agrees with you, and/or has the same opinions as you. Also, its not all free love and drugs as it was promoted to be.
- clubhi 14y agoThat was a very poorly written blog.
- swartzrock 14y agoI enjoyed reading David's post and only have one issue: Oxford Comma? Seriously? That's ridiculous, unnecessary and unparsable.
- clhodapp 14y agoYou pause there in speaking, so you should put a comma there.
- swartzrock 14y agoUnless I increased my speaking rate to prevent the awkward situation of requiring the comma... or perhaps there never was a pause there (eg "eats shoots...")
- VeejayRampay 14y agoYet some of the people singled out as the snarks in this article are people active in the community as teachers, participate to user groups, spend a lot of their free time on maintaining beginner-oriented software. Life is best seen in shades of grey and I'm sure they sincerely regret having reacted that way. The more general issue is that Internet has become a place of competition and EXTREME negativity, just read any article on Hacker News if you need convincing. Some dude will spend months or years working on some shit, only to be greeted with cheers and claps like "wow, that sucks", "How is that useful?", "Your code is bad and you should feel bad", "LOL, you handled security like my 2-year old handles the TV remote". So no, it's not even a problem of calling out code when it's bad, it's just a simple matter of recognizing that those people you so hastily call out are in fact human beings. And NO ONE likes to be humiliated.
- at-fates-hands 14y agoI experienced when I first started out as a developer, my co-workers were just like this. They'd rip apart sites left and right, people's apps and anything else they could set their sites on. I was hazed on a regular basis for the code I was writing, simply because I was considered a "junior" developer. It wasn't until after I left there I realized how incredibly myopic and arrogant these people really were. This was one of many lessons I had to learn. There is no one way to do anything in development. Sure there are certain things you should and shouldn't do - but one way to do everything? Hardly. After I left said company I really gained more respect for how people write and maintain code. As such, I now just keep my eyes and ears open for best practices. Unless it's going to be constructive, I never hack on anybody else's code. I know the feeling of thinking you've done something wrong. When in fact, it might just be a different approach to reach the same conclusion.
- zeeg 14y agoIf you call out bad code, you call out bad people? Half of you included, look at the ridiculous shit you say, and how much more offensive you are than anything anyone originally said. Also this is great for a laugh: http://dl.dropbox.com/u/116385/Slingshot/Pictures/Screen%20Shot%202013-01-24%20at%202.29.48%20PM.png http://dl.dropbox.com/u/116385/Slingshot/Pictures/Screen%20S...
- asshole_hunter 14y agojust shut up man and leave this for a while.
- mkhattab 14y agoI agree, the responses are much worse that was originally said. There's also the expectation that you'll suck it up and deal with it which betrays the purpose for reacting against what you said in the first place. Oh, you missed the tweet, in the screenshot, where he wishes you get cancer and that he calls you a cunt :)
- e4c5shev 14y agoThe problem with being rational is that you are dealing with people that don't seem to like you, or have taken to disliking you.
- brudgers 14y agoA person who looks at a piece of art and says, "Eh. I could do that," isn't a critic. He's just another asshat with an opinion. Criticism is the highest aspiration of non-fiction writers. Zinsser says so in On Writing Well so it must be true. Even if it's not, what he says about most people sucking at it, certainly is. Negative criticism is easy, positive criticism isn't. Lead with an insult, and the internet pays attention. But it is hard work to criticize something productively - to point out the value and the areas for improvement. Writing a lead for that criticism is even harder. Most people, including myself, are not in the habit of spending the time to do it right. The article takes the time to get it right. It does so by looking at why Heather did what she did. It compares what she did to the common alternatives. The author tells what he did when faced with similar situations. That's what makes it good criticism.
- ianstallings 14y agoMan there sure are some sensitive sallies in the dev community lately over this whole debacle. Part of this industry is handling criticism. Not everyone is going to be a fan. That's part of being a developer. Devs were getting their pants torched long before me on the Internet and I don't see that ever ending. A lot of it is opinion. So treat it as such.
- georgemcbay 14y agoThis is getting way off topic of the original project, but as an older (40) programmer, I've learned that even if code is objectively bad you generally shouldn't call it out unless you have the full context of how it got that way. I write code every day, some of it is great, most of it is good, some of it is shit (working shit, but shit nonetheless). The reason some of it is shit varies: time constraints don't allow for the proper solution, working around a crappy abstraction that I can't control, etc, but if you decide to focus on some snippit of the shitty code I wrote and extrapolate that to assess my skill as a programmer I reserve the right to extrapolate that your experience doing real world programming is pretty limited, because otherwise you wouldn't be so naive.
- ragmondo 14y agoexactly. I am in the same era as you and unfortunately haven't managed to hook facebook or google to hire me so my day consists of making the most out of the shit I am served each and every day. You know that 3 line shell script that accounts only needed to run once a year ? Yes that migrated into an 20,000 line perl module that HAS TO run every night without fail but nooooo do they want to (pay to) re-engineer it ? No. Because the customer would not benefit. The most fun I have at work now is "try to get the most audacious python module through the firewall and then get it approved by the project manager as they have absolutely no clue about what I do". Sorry kids but unless you make it (and make it big)... that's you in ten years time. If I am honest, I have got over the "OMG what's it written in?" stage. If it works and if the (time saving per run * the times I need to run it ) > time it would take to write it myself, then .. that's a success. Then.. move onto the next issue to get some project tasks done, contract renewed, kids fed, mortgage paid etc etc etc.
- dvo 14y agoI stopped worrying much about so-called bad code a long time ago. Reading eye-watering, mind-numbing code is practically a pre-requisite for working on any non-trivial enterprise system at a business of any reasonable size. In many ways, you come to enjoy the challenge of it. I've had to read code written in an almost obfuscated manner in languages I'd never previously worked with before. You get used to it. You learn to read and grok just about anything. On the topic of massive Perl scripts, I once worked on implementing a system that was an unholy maze of Perl, Pro-C, Pro-COBOL, Oracle Forms, Java, and PL/SQL. It was the first time I'd ever had to read and write Perl and Pro-C. I even remember reading Pro-COBOL at one point to debug a problem. Good times. Since the above is somewhat tongue-in-cheek, I'll clarify that I certainly think we should strive to write excellent code and constructively help each other to that end. We should probably be very slow to dispense judgement but quick to share carefully considered, contextually relevant advice. You really do need to understand the context under which something was written to make any useful statements about goodness or badness (which is still probably not that helpful a measure). Something that looks bad at first may be fantastic work considering the circumstances under which it was written.
- michaelochurch 14y agoI think that one of many problems with our industry is that even many good engineers can't really tell good code from bad. (Bad engineers are already hopeless.) That's why there are so many flamewars over cosmetic bullshit like tabs-vs.-spaces. Most code flamewars are over style, not substance. But it's substance (overuse of inheritance, lack of interface integrity, inappropriate technical choices) that kills projects.
- nicholassmith 14y agoI pull people up for similar things on here, if you're going to call something out explain why you think it's bad. You don't need to provide a rewrite to it, you just need to not drive by snark it.
- Mahn 14y agoBreaking news, people on the internet have opinions and criticize things. Just don't take it too seriously and have your own opinions.
- damm 14y agoI don't understand what has happened to people. There is only 2 people who can call out said code. They are: 1) Their Employer. Then you can ask them to refactor the code. 2) Them. Additionally, your mother was right. If you don't have anything nice to say you shouldn't say anything at all. Just because you were born on this planet and survived past birth; does not give you the right or the excuse to harm another person or cause harm to said person's "Value of Life".