logoalt Hacker News

It's OK to hardcode feature flags (2025)

59 pointsby biscuits1today at 11:00 AM34 commentsview on HN

Comments

jamesharttoday at 12:21 PM

In my experience these (configuration based feature flags and feature flag services) are actually two complimentary capabilities that solve two completely different problems but that happen to share the same name: feature flags.

The config approach is critical for using feature flags as a software development lifecycle tool. It is how you manage having a codebase which contains the unfinished code for new feature x, but can still be deployed and pass all tests without feature x being turned on.

In this model you need a mechanism which allows a developer who is working on feature x to enable it for local testing, and for your CI system to be able to interact with the flag system to test that the application works in both states - with x turned on and off.

This is ideal for trunk based development models; feature branches are an alternative approach that doesn’t really benefit from this (indeed it adds complexity to working in feature branches).

Meanwhile feature flag services are to solve the problem that different people using the same software need different features turned on. That can be as simple as internal testers or beta users, it can be holding features to roll out in fixed update windows per tenant, or it can be part of a risk management strategy where features are rolled out through progressive exposure.

It can also be tempting to mix up your feature flags system with an A/B testing system - you can use a feature flag service to expose a feature to a test cohort and measure performance changes.

There can be reasons for doing that but it’s really important not to tie all these things together: not every development lifecycle change is an ab test hypothesis. Not every ab test hypothesis is a development lifecycle change (often it is really about testing changes in data, and feature config is just one piece of data you might want to change). Similarly some other data changes than code changes need to roll out progressively to mitigate risk.

So all these things might be feature-flag shaped, but that doesn’t mean you can substitute different feature flag solutions in and solve the same problems.

This post is saying ‘it’s okay not to have an exposure control solution; you can have a config file’ - which is obviously true, if what you have is a config management problem, not an exposure control problem.

show 2 replies
jdwyahtoday at 12:19 PM

I am on my second feature flag startup, but I also somewhat agree with this.

Every project should have flags, but many projects need just the basics and a service is overkill.

Rolling your own JSON still feels like something we ought avoid though. Yes to start out it’s 95% booleans. But then you want a rollout. And then you want some targeting rules. And then you want non booleans… maybe some json. Oo wouldn’t it be nice if the json could conform to a schema… and then eventually you are like damn I really want to change these without deploying. Or you want to read the same flag from multiple services.

I’ve tried to incorporate this lowest common denominator into https://quonfig.com Use it totally free & open source as SDK, and it’s just loading JSON that you can track in git. Agents love it, hot reloads, SDK in lots of languages. But vs rolling your own you’ve got a lot of headroom on the design. A bunch of targeting operators. Segments etc. And then if you do want to get a nice UI / delivery network for real time updates, then you can use the paid side of things.

Local use description: https://docs.quonfig.com/docs/how-tos/open-source-local

show 1 reply
jjicetoday at 3:04 PM

The biggest problem I've found with feature flags of this nature (mostly for internal testing and the like) is that they can easily live too long and bloat code. This is also very dependent on what the feature flag on/off code paths do.

1. For reducing outliving, I always create a ticket to remove the flag at the same time it gets added in. This way there's documented work that will get scheduled. YMMV depending on how your team does planning.

2. For flag branch implementations, it's often fine to do an if/else, but I've seen this blow up into a real headache. When I can, I like having two implementations of an interface that get swapped between. Code calls the interface as normal the the underlying implementation is the same. Works for React components and larger implementations/changes that already have an interface. Don't want to force an interface where it feels wrong.

maxidogtoday at 12:13 PM

I’m currently reverse engineering a large enterprise app and the feature flag bloat is truly astounding. Imho excessive feature flag complexity is a symptom of management who are indecisive and mistrusted by the developers.

show 3 replies
torginustoday at 3:23 PM

I just wanted to say I haven't been doing C# dev until as of late, and I forgot how flipping amazing the tooling is. One of the things the C# compiler (which is used for IDE tooling) can do out of the box is it can compile multiple versions of the file (syntax, and symbol resolution included), meaning you can still make sure the statically disabled codepaths are still valid, and all the symbols are consistently available in every feature flag combo.

When something does go wrong, the compiler degrades gracefully, and still can make sense of most of the code.

MS gets a lot of flak (sometimes deservedly so), but they can sometimes also show what a large organization of skilled individuals working under consistent direction is capable of.

alexpotatotoday at 2:08 PM

Speaking as a SRE/DevOps guy with almost 20 years of experience:

There are no solutions, only tradeoffs.

I'll give some examples:

Firm 1 had a single server running tron [0] for ALL scheduling of processes.

Pros: very easy to see what should run when and made audits a breeze

Cons: the central server died and it was a giant outage response to make sure that when the server came up it didn't start killing processes that should be running

Firm 2 used a management gui to create custom cron entries on each machine

Pros: each node had a local copy of the schedule and could keep going even if the central system died

Cons: each node had a local copy of the schedule which could "drift" from other nodes, a node could be forgotten etc

So, more generally, I agree that it's good to label things as "ok" so that we don't get into flame wars etc. That being said, the more important point is to say that if you are going to pick a strategy, do the work to support, build tooling and plan for outages related to that strategy.

gps372today at 12:41 PM

Hardcoded feature flags becomes a big issue if your release process is long and error prone. Original article also suggest to enhance incrementally. But you don't want the interval between increments to be too big.

aksappytoday at 12:09 PM

Unclear how the arguments against feature flags can be used to justify hardcoding them or using a JSON file to manage them. Feature flag decisions are at the end of the day, tradeoffs to solve a problem that may occur for another person at a different place/time. If you are a solo developer, hardcode, use bytes or mail your feature flags - it does not matter. If you are not, there is a lot to take care of beyond a single hardcoded json file.

gwbas1ctoday at 1:09 PM

> Hardcoded feature flags ... start with a simple JSON file

Any configuration read out of a JSON file is not hardcoded. Hardcoded means you need to recompile to change it.

(And yes, hardcoded, as in flags set with #define or equivalent, are totally fine depending on what you're doing.)

show 2 replies
PaulHouletoday at 1:16 PM

Brother

   The blogspam marketing behind them is so strong
Yep, right up there with Triplebyte back in the day and the drumbeat about "it's so hard to bill customers" and "JWT sucks"
cassianolealtoday at 12:12 PM

Why wouldn't it be? The post does a good job explaining why not only it's not a problem, but also likely desirable in many (I'd wager the vast majority) of circumstances.

Simple, effective, cheap, easy to understand and manage. Not dependent on an external service, not dependent on a third-party.

drdexebtjltoday at 12:28 PM

To do safe deployments, you must have a way to run versions X and X+1 side by side serving an arbitrary proportion of your users while you inspect metrics.

That covers a lot of uses of feature flags without the bloat.

Xirdustoday at 12:07 PM

Hardcoding feature flags prevents you from deploying the same build with different flag sets side by side and comparing results. Depending on the nature of the project, it might be irrelevant or it might be a deal breaker. Especially in cloud environments, it's usually the latter. And everything is in the cloud nowadays.

jasonjayrtoday at 12:15 PM

Do all modern compilers do tree-shaking at this point? Unless you use compiler-based flags, If you hard code them into your code, the dead code paths may still be in the shipped binary. Depending on what you are doing, the security issues mentioned in the article are still present, or you may prematurely reveal an upcoming feature.

andy_ppptoday at 12:40 PM

I've never found feature flag systems complex and you can build one yourself in a few functions. The services I have used in the past were extremely simple to integrate so I don't understand the issue either way honestly.

floki165today at 1:50 PM

[flagged]

michael_luogtoday at 11:14 AM

[dead]

devecycle-marketoday at 12:02 PM

[flagged]

mhog_hntoday at 11:52 AM

note that this is a "pre-november 2025 opus 4.5" post folks