109 points · by doodlesdev · 3y ago · 108 comments
The best programmers I know rarely see things as 100% good or bad.
And even if you do, it's still better to say "X is bad because Y" instead of a meaningless assertion like "X is an antipattern" or "X is a code smell".
But are the "best programmers" the best judges of such things. I often find they are not because they often understand their tools in a way that is incomprehensible to others. I've seen many junion engineers fizzle into disfunction because they are paired with "one of the best programmers". I've seen "the best programmers" adopt tools and patterns that cannot survive their departure because they are too complicated and too specialized for anyone else to own.
> rarely see things as 100% good or bad.
For me, I held this view most strongly when I was an intermediate programmer. I quickly moved into the "every tool for its job" phase after the "the things I learned with are best" phase.
But as I've become an advanced programmer, some of my opinions have become much stronger. For example (and this is just an example I don't want to argue about this) I currently see "the self initializing singleton" as pretty much a 100% bad pattern. This because my experience has taught me that not knowing when something is going to get setup is a weakness, not a virtue. This is an opinion I was actually incapable of developing as an intermediate programmer because I had not yet encountered the myriad of annoying bugs that come from ambiguities of initialization. I just respected the "ease" and "cleverness" of the pattern.
That was not the kind of developer I was thinking about.
> But as I've become an advanced programmer, some of my opinions have become much stronger
I don't mind strong opinions at all. What I mind is extremism, and how terms like antipattern and code smell contributes to it.
You called the singleton pattern you described a "pretty much 100% bad pattern", then went on to explain your experience and opinion in a humble way. I think that's a great example of a strong opinion which was not "extreme".
But that's difficult to distinguish and act upon, so the meaning seems to have morphed into generic "bad thing you should never use".
Regardless, I've never seen it refer to code that didn't turn out to be bad in the author's opinion.
Like, I don't think you can get away with just typing "code smell" in a CR. That's lazy but the gut reaction to some code can be a useful starting point.
Well and concisely put. I agree.
Personally, what bothers me most about "X considered harmful" essays is the unspoken subject of the sentence. Who is it that considers X harmful? The title is structured to imply a broad consensus that is well beyond the point where anyone could possibly disagree with it. They want you to read it as "X considered harmful by all experts you should trust", but it's almost never that. The author is making up an authority, then telling you the authority is on their side.
Now, to me, one isn’t supposed to use that passive voice title for one’s own writing unless you want it to be taken as a joke.
At least Dijkstra had some earned cred before he published "Goto Considered Harmful".
That publisher happened to be Niklaus Wirth.
“Considered Harmful” Essays Considered Harmful - https://news.ycombinator.com/item?id=9744916 - June 2015 (79 comments)
"Considered Harmful" Essays Considered Harmful - https://news.ycombinator.com/item?id=290490 - Aug 2008 (4 comments)
Kidding aside, Fortini's tongue-in-cheek answer is the best one to such silliness. Certainly advice is neither absolute or contextless. I'd say that to suggest otherwise, especially in online discussion, is to act in bad faith.
Certainly "considered" is already doing the job of pointing out it's an opinion, not natural law.
Probably didn't anticipate so many people not getting the joke!
To some extent Anglos will never understand.
> Finally a short story for the record. In 1968, the Communications of the ACM published [...] "The goto statement considered harmful," which in later years would be most frequently referenced, regrettably, however, often by authors who had seen no more of it than its title, which became a cornerstone of my fame by becoming a template [....] But what had happened? I had submitted a paper under the title "A case against the goto statement," which in order to speed up its publication, the editor had changed into a "Letter to the Editor," and in the process he had given it a new title of his own invention! The editor was Niklaus Wirth.
https://www.cs.utexas.edu/users/EWD/ewd13xx/EWD1308.PDF (In Dijkstra's own, very beautiful print hand!)
It's fine to be opposed to regulatory or cost models but saying won't work masks the real issue: don't want.
It's been used as a put down by the email cabal for over two decades. Ietf grey and whitebeards. It's just a mechanistic formalism to define an ingroup and an outgroup now. I whine about it on mail related lists and forums from time to time and have done since it first emerged. Dealing with bad ideas is important, putting new entrants into the problem space off by being patronising is really asocial.
The irony is that centralisation of mail into a parallel cabal of Google, O365 and a small number of others is probably altering the surface of email problems by ignoring the list, and doing what they do, for money, and under regulatory pressure.
Many of the "it won't work" mob are now finding running a full stack, ipv6 enabled SMTP sender next to impossible. Dkim and spf won't stop reputation agents dismissing them as "bad"
"X Considered Harmful" lets the reader know very precisely what it is they're about to read: a warning about a particular pattern or behavior that is common but tends to backfire. This goes for all meme-ified headlines ("X I love you but you're bringing me down", "Unreasonable Effectivenes of X", etc etc)
It's important to bring nuance to a discussion rather than taking an extremist position, and I think that's the author's main gripe. But nuance also adds confusion and waters down the message. Sometimes it's better to stake a clear position at the outset, and then address the nuances.
You can't just have balance; you have to balance balance with imbalance, balancedly [2]
If your "clear position" truly has any legs, it will stand without having to resort to "harmful" clichés as a lure.
[1] http's://news.ycombinator.com/item?id=35906505
The point is, we have to do our part in resisting the impulse to add to the pile-of-poo (which is most of the internet).
You made a separate point from my own comment, and your point is very true!
Why? Because the author of this essay is a hypocrite. He specifically disclaims his own essay from consideration:
> For example, a piece titled “‘Considered Harmful’ Essays Considered Harmful” would very likely be a case of using the “considered harmful” format to draw attention for its own sake. We will ignore such essays in this commentary.
But in so doing, he claims that using "Considered Harmful" to draw attention to the essay is fine. That's why I used it, and it worked. [2]
He also says they are typically used by someone with an axe to grind. This is true. To combat this, I took a mellow tone in my essay, as compared to the inflammatory post I originally wrote on the same topic. [3]
And yet, he transparently has an axe to grind against "Considered Harmful" essays because he does not allow nuance:
> It would therefore seem obvious that the only intelligent course of action is to abandon their use entirely, and instead look to more constructive forms of essay writing in the support of debate positions.
Basically, he says that use of "Considered Harmful" essays must be abandoned completely because they don't support their intended positions well.
If so, why did he write one of his own? Is it parody or actually serious? I can't tell.
But sometimes, "Considered Harmful" is the best way to express something. In that case, use it. But IMO, you should only do it after careful consideration, like what I did for my essay.
Don't hamstring your writing by restricting your expression, and don't be a hypocrite. But do be careful and mellow.
[1]: https://gavinhoward.com/2021/10/static-linking-considered-ha...
[2]: https://news.ycombinator.com/item?id=28736238
[3]: https://gavinhoward.com/2021/01/dynamic-linking-needs-to-die...
I think if the essay were "Why I don't like <x> in language <y>", that would be a much more honest title.
So it's funny when people rigidly adhere to the goto ban while simultaneously littering a bunch of tiny single use functions and classes all over their supposedly well-designed code.
I got home the set of textbooks for BASIC programming language from the institute -- the classes had not yet started. So I knew next to zero about programming and barely touched a computer.
I sat down and read through the books. They were all well-written and most of it made sense (whatever I could make sense of -- having never written a program before)
All commands seemed to have some logical names : LET, IF ... THEN ..ELSE, FOR, PRINT, INPUT, etc.
But one command stumped me.
GOTO.
I was not a native speaker of English and wondered if it is an obscure english word.
(My mind defaulted to sounding it as a single word, "lotto" with a G)
I read the explanation and that sounded okayish -- make the program execution jump to a line number specified after the GOTO command.
But what the hell was "GOTO" -- why did they name it that -- I had no clue.
It took embarassingly long for me to realize that it was a rare command (the only one perhaps?) in BASIC language that is not a single English word but simply a combination of the simple words 'go' and 'to' :)
So I have a special place in my heart for this command :)
You're fighting yesterday's battle, and you're siding with the losing side. The ideas from this article have been the trend for new programming language innovations for several decades now, and it has yet to cause any harm.
1. Sometimes more efficient code (state machines can make really good use of this pattern)
2. There is no structured programming equivalent or no good structured programming equivalent within the language.
For (2), you see it a lot in the Linux kernel (and similar) code where it's utilized for early exits. Where a language like Go might use a defer statement or Java and similar might use a try/catch/finally and exceptions, C would put a bunch of clean up statements after one or more labels at the end of the function before the single return. Which label you go to (if you use more than one) would depend on how far into the function you've gotten.
My emphasis. C is barely younger than Dijkstra's letter, and by comparison to a modern language it is impoverished when it comes to structural flow control. Still, you won't find modern C programmers arguing that they don't see any use for while loops, or that switch is pointless because they could just use longjmp.
when used properly it should be really obvious what it's doing, where it's going, and shouldn't produce any weird side effects. jumping into another function or module or file isn't good.
Otherwise you have to free all the buffers in every place where an error might happen, and you will most likely forget to free some or double-free.
Structured programming won.
Ted in Marketing insists on a last name. That field is how the cold callers sort.
Your boss' boss made promises, there's no time to cover all of these edge cases you keep talking about.
Shipping says we don't serve India, anyway, so why are you making us go through this?
I actually think I could write a LISP out of this.
(...) considered harmful
(...) is a fractal of bad design
Positive cliches:
And now for something completely different
New directions in (supersede) topic
I hate to see some low-quality articles which just repeat some extraordinary good documents. All these examples I have seen in a short period of time such as one week.
For some reason it is meant to bestow gravitas to the topic.