Just patched yet another project to delete a “-Werror” just so it would build on my computer and I think I’ve finally come to the conclusion that we have *really* failed at explaining why compiler warnings exist to an entire segment of programmers. We need to fix this.
The problem has gotten so bad that some of these people are *working on compilers* right now! They are literally encoding these assumptions into programming languages millions of people use. The productivity cost is real–if you use Swift or Go, you’re already living through it.
As a concept, warnings are pretty simple! They’re not that hard to understand if you approach them from the bottom up. The problems arise when you look at them in the opposite direction, without really understanding why they exist. Here, I can go through them now:
A lot of times the compiler knows what you are doing is wrong. It doesn't really know what you mean, or you’re doing something clearly invalid, so it can’t proceed. That’s when the compiler will produce an error and they’re always fatal, because there is no way forward.
Errors are all the feedback a compiler is *required* to give you. But sometimes you might write code that is valid but is not typically written: perhaps you are using an assignment for its return value, or you have written a function whose body doesn’t use all its parameters.
These are valid programs! But they might hide bugs, so the compiler can opt to provide you feedback. In most cases, you should look at what it’s saying, but the compiler can’t always get it right. Sometimes you’re going to write programs that look “fishy” but are what you wanted.
There’s a lot of reasons this can happen. The most common is that you’re in the process of iterative development, where your code is not necessarily “perfect” all the time. You’re going to be commenting things out and writing exploratory code. The compiler can’t really see this.
Development code gets deleted, though. But sometimes you really need to write programs that the compiler is going to warn about–they are legal, after all. Again, the compiler isn’t perfect, and often you have more information than it does about what you’re trying to do.
Conflating warnings and errors (as -Werror does) is wrong for both of these! For the first, you do want to see the warnings so you don’t accidentally leave ship the bad code. But while you’re developing, blocking the build until you fix evertything is a productivity drain.
For the latter, you actually do want to ship that code. What you need is a way to tell the compiler that you really *do* mean what you wrote–warning *suppression*, in other words. This lets the other warnings you actually care about not be buried in the noise.
Go does this wrong because commenting out code might mean it stops compiling, because your import is no longer used. While developing this really hurts, so much so that I know people that use a patched Go compiler locally just to get around this issue.
Swift doesn’t let you suppress warnings: what this means in practice is that people have codebases with legitimate code that has a bunch of useless warnings, or they write that code *in an entirely different language* just to escape the compiler yelling at them :/
And, as I mentioned upthread, turning on -Werror just means that your code is not going to compile on my computer when I download it, even when it is correct. The nature of warnings is that different tools can warn on different things!
The argument I get most often is “people ignore warnings if we don’t make them errors”. My response is: yes, that’s exactly what they’re for! They are informative, not prescriptive; you are meant to ignore them when they are not relevant.
The way you “ignore” them differs based on context: during development you can literally just let them be. When they appear on code you want to keep, you should suppress them so that other warnings can be more prominent.
Does this mean -Werror is useless? No, otherwise it wouldn’t exist. It’s there for contexts where you don’t actually want warnings, and the one you probably want is your main repository. It’s great for CI: you control the environment and it doesn’t affect local development.
Anyways, a TL;DR of the right way to do things:

* If you’re a language designer, allow for suppressing warnings, and don’t make things that are obviously warnings into errors
* If you maintain a project, -Werror your CI or precommit hook, not local builds

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Saagar Jha

Saagar Jha Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @_saagarjha

24 Aug
I am so tired of watching people continue to juice numbers by doing things to boost short-term growth and causing attrition in places that are not tracked–spelling disaster in the long term. As an industry, we have really failed in creating "sustainable metrics".
The funny thing is that we all kind of already know exactly where these blinds spots are: if you are measuring engagement, it's easy to boost that by giving people things that keep them addicted to the platform. So you want to counterbalance by measuring conversation health.
If you're looking at new signups: you can easily boost this by putting a thing in everyone's face to ask for that. Obviously, you want to make sure that the people who are doing this actually stick around, rather than are just making a throwaway because you forced it on them.
Read 4 tweets
11 Aug
My “We aren’t going to look at your non-CSAM pictures and messages” T-shirt has people asking a lot of questions already answered by my shirt.
Jokes aside, though, as engineers we regularly deal with complex systems that can be difficult for our users to understand. Having a hard time explaining how they work is one thing, but regardless of your position on this technology @Apple’s messaging has been unacceptable.
Their reluctance to clearly describe how the software works, their seeming inability to be straightforwards with the fact that it fundamentally detects CSAM using filters that they control and uploads it to them, is very concerning. This isn’t how you inspire trust.
Read 7 tweets
12 Jul
@pcwalton @iSH_app While constrained slightly differently (OSR requirements, usually tiered up to a JIT, etc.) JavaScript engine bytecodes are probably what you want to look at. Some certainly look a bit like what you’ve described.
@pcwalton @iSH_app For @iSH_app compatibility is very important, so the frontend is probably always going to accept an ISA with actual software compiled against it (and, soon, we’ll be limited to ones supported by Linux).
@pcwalton @iSH_app We emulate x86 on x86_64/arm64 so the interpreter is able to pin all the registers, at least: github.com/ish-app/ish/bl…. So we get that “for free”, at least. The instructions are still annoying to decode, though, so we cache those.
Read 4 tweets
12 Jun
The news is just as shocking today as it was three months ago. How we deal with mental health is still something that we need to learn to handle better together. This is especially true in situations such as open source that are nominally technical but in reality heavily social.
That being said, in situations like these it’s especially important to remember that people’s mental state is often the result of complex circumstances that may be entirely out of your control. You can be talking to someone about programming one day and they’ll be gone the next.
I have nothing to suggest except having empathy whenever and wherever possible. You can’t fix everyone’s situation, but you can certainly do your best to provide support from your side. We might not have a magic solution for dealing with mental health but we know that this helps.
Read 5 tweets
9 Apr
It seems like it’s about that time of year when people try to impute meaning to Apple’s marketing version numbers and use them to form conclusions of internal development processes. Here’s a thread to demystify them to the best of my knowledge (would be glad to hear corrections!)
First, a couple of clarifications so we can talk about this consistently: if x is the major version, y the minor and z the patch, then for iOS/watchOS/tvOS, the marketing version number is of the form x.y.z. For macOS pre-Big Sur, it’s 10.x.y; it now seems to be x.y.z.
Myth #1: marketing minor versions and patch versions match internal development or have some other useful meaning.

AFAIK, these are mostly decided arbitrarily, hence why I call them “marketing”. The major version matters (updated yearly) but the others just increment on chance.
Read 16 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(