News for hackers. Stuff that matters.
Re:In Praise Of –Dry-Run by arjie on Saturday January 31, 2026 @07:32PM (#46842417)
In order to make it work without polluting the code-base I find that I have to move the persistence into injectable strategy, which makes it good anyway. If you keep passing in `if dry_run:` everywhere you're screwed.

Also, if I'm being honest, it's much better to use `--wet-run` for the production run than to ask people to run `--dry-run` for the test run. Less likely to accidentally fire off the real stuff.

Re:In Praise Of –Dry-Run by segmondy on Saturday January 31, 2026 @07:45PM (#46842503)
this is where design patterns come in handy even tho folks roll their eyes at it.
Re:In Praise Of –Dry-Run by cake-rusk on Saturday January 31, 2026 @08:06PM (#46842620)
Design patterns exist to paper over language deficiencies. Use a language which is not deficient.
Re:In Praise Of –Dry-Run by antinomicus on Saturday January 31, 2026 @08:28PM (#46842744)
Like what?
Re:In Praise Of –Dry-Run by frogulis on Sunday February 01, 2026 @02:38AM (#46844306)
First class functions and iterators are probably examples of what they mean, in terms of language features that obsolete (GoF) design patterns
Re:In Praise Of –Dry-Run by cake-rusk on Sunday February 01, 2026 @04:41AM (#46844853)
Re:In Praise Of –Dry-Run by WCSTombs on Saturday January 31, 2026 @08:58PM (#46842918)
There's some truth to this, since some design patterns can simply be implemented "for good" in a sufficiently powerful language, but I don't find it's true in general. Unfortunately, it has become something of a thought-terminating cliché. Some common design patterns are so flexible that if you really implemented them in full generality as, say, some library function, its interface would be so complex that it likely wouldn't be a net win.
Re:In Praise Of –Dry-Run by cake-rusk on Sunday February 01, 2026 @04:43AM (#46844869)
> Some common design patterns are so flexible that if you really implemented them in full generality as, say, some library function, its interface would be so complex that it likely wouldn't be a net win

Then I would say you have not arrived at the optimal solution. Keep looking.

Re:In Praise Of –Dry-Run by awesome_dude on Saturday January 31, 2026 @09:57PM (#46843211)
Just my two cents - but a general purpose language is going to need to be coupled with design patterns in order to be useful for different tasks.

I'm using MVC design patterns for some codebases, I'm using DDD plus Event sourcing and Event Driven for others.

I suspect that you are thinking of a small subset of design patterns (eg. Gang of Four derived patterns like Visitor, Strategy, or Iterator )

Re:In Praise Of –Dry-Run by cake-rusk on Sunday February 01, 2026 @04:40AM (#46844847)
> I'm using MVC design patterns for some codebases, I'm using DDD plus Event sourcing and Event Driven for others.

All examples of OO nonsense. There is only one pattern you need (functions) (tongue-in-cheek): https://fsharpforfunandprofit.com/fppatterns/

Edit: Also consider using the ELM architecture instead of MVC: https://guide.elm-lang.org/architecture/

Re:In Praise Of –Dry-Run by awesome_dude on Sunday February 01, 2026 @01:24PM (#46848128)
I typically reach for Go when I am building things, bubbletea, a TUI library uses the Elm architecture and enforces it on people using it.

Did not like, Won't use again.

MVC is well understood and works perfectly in my experience.

edit:

Even though you were tongue in cheek about F# - this stood out on the page

> The functional programming community has design patterns and principles as well.

Re:In Praise Of –Dry-Run by cake-rusk on Monday February 02, 2026 @02:27AM (#46853388)
IMO the ELM architecture only works with pure functions. It doesn't work with languages which cannot provide this compile time guarantee. Also functional programming needs a different mindset / training. You won't benefit from it until you understand what it actually brings to the table (and what it leaves out).
Re:In Praise Of –Dry-Run by awesome_dude on Wednesday February 04, 2026 @02:39PM (#46890593)
I have to ask - I like some of the paradigms of Functional programming (IMO it makes concurrent programming a lot easier because state is never shared)

Why hasn't it cut through, like OO did?

and

Beam has been around since the 90s, had a good marquee project (RabbitMQ) but still has low adoption

Re:In Praise Of –Dry-Run by cake-rusk on Thursday February 05, 2026 @08:38AM (#46899513)
I am not sure I if I can speak to that in general but personally I discovered functional programming late. Object oriented programming was all the rage when I got initiated and that is all that was taught in colleges.
Re:In Praise Of –Dry-Run by esafak on Sunday February 01, 2026 @06:01PM (#46850281)
Re:In Praise Of –Dry-Run by cake-rusk on Monday February 02, 2026 @02:20AM (#46853349)
I agree. Doesn't contradict anything I said. So I will assume you posted the link in support of my argument :)
Re:In Praise Of –Dry-Run by nstart on Saturday January 31, 2026 @09:46PM (#46843156)
Design patterns are one of those things where you have to go through the full cycle to really use it effectively. It goes through the stages:

no patterns. -> Everything must follow the gang of four's patterns!!!! -> omg I can't read code anymore I'm just looking at factories. No more patterns!!! -> Patterns are useful as a response to very specific contexts.

I remember being religious about strategy patterns on an app I developed once where I kept the db layer separated from the code so that I could do data management as a strategy. Theoretically this would mean that if I ever switched DBs it would be effortless to create a new strategy and swap it out using a config. I could even do tests using in memory structures instead of DBs which made TDD ultra fast.

DB switchover never happened and the effort I put into maintaining the pattern was more than the effort it would have taken me to swap a db out later :,) .

Re:In Praise Of –Dry-Run by tbossanova on Sunday February 01, 2026 @12:31AM (#46843900)
What about the productivity gains from in memory db for tests though? Hard to measure I guess
Re:In Praise Of –Dry-Run by guhidalg on Sunday February 01, 2026 @03:32PM (#46849093)
In my experience, there is no in-memory database replacement that correctly replicates the behavior of your database. You need to use a real database, or at least an emulator of one.

For example, I have an app that uses Postgres as the database. I have a lot of functions, schemas, triggers, constraints in Postgres for modifying database state, because the database is 100x faster at this than my application will ever be. If I have an in-memory version of Postgres, it would need to replicate those Postgres features, and at that point I really should just be standing up a database and testing against it.

I have worked with people claiming that unit tests need to hermetically run in-memory, because reasons. Ok, I don't disagree, but if my bug or feature requires testing that the database is modified correctly, I need to test against a real database! Your in-memory mock will not replicate the behavior of a database _ask me how I know_ ...

These days, Docker makes this so easy that it's just lazy to not standup a database container and write tests againts it.

Re:In Praise Of –Dry-Run by GreenWatermelon on Tuesday February 03, 2026 @02:23AM (#46867677)
Haha you're describing implementing an ORM! It's essentially that: a unified interface over multiple DB adapters.
Re:In Praise Of –Dry-Run by wging on Saturday January 31, 2026 @08:57PM (#46842909)
One nice way to do things, if you can get away with it, is to model the actions your application takes explicitly, and pass them to a central thing that actually handles them. Then there can be one place in your code that actually needs to understand whether it's doing a dry run or not. Ideally this would be just returning them from your core logic, "functional core, imperative shell" style.
Re:In Praise Of –Dry-Run by WCSTombs on Saturday January 31, 2026 @09:02PM (#46842934)
I totally agree with both this and the comment you replied to. The common thread is that you can architect the application in such a way that dry vs. wet running can be handled transparently, and in general these are just good designs.
Re:In Praise Of –Dry-Run by IgorPartola on Saturday January 31, 2026 @09:56PM (#46843201)
That’s what I prefer as well. A generation step and an execution step where the executor can be just a logger or the real deal.
Re:In Praise Of –Dry-Run by clawsyndicate on Sunday February 01, 2026 @07:32AM (#46845776)
we rely on this separation for our agents. the llm outputs a declarative json plan that gets validated against security policies before the runtime executes any side effects. catching a bad command during validation is way cheaper than rolling back a container.
Re:In Praise Of –Dry-Run by sh-run on Saturday January 31, 2026 @09:02PM (#46842931)
I don't like the sound of `--wet-run`, but on more than one occasion I've written tools (and less frequently services) that default to `dry-run` and require `--no-dry-run` to actually make changes.

For services, I prefer having them detect where they are running. Ie if it's running in a dev environment, it's going to use a dev db by default.

Re:In Praise Of –Dry-Run by ryandrake on Saturday January 31, 2026 @09:08PM (#46842957)
I don't want to have to type rm --wet-run tempfile.tmp every time, or mkdir -p --yes-really-do-it /usr/local/bin

The program should default to actually doing whatever thing you're asking it to do.

On the other hand it would be great if every tool had an --undo argument that would undo the last thing that program did.

Re:In Praise Of –Dry-Run by homebrewer on Saturday January 31, 2026 @09:15PM (#46842993)
That undo program is called nilfs2, which unfortunately never became popular. I'll simply quote the kernel docs:

> NILFS2 is a log-structured file system (LFS) supporting continuous snapshotting. In addition to versioning capability of the entire file system, users can even restore files mistakenly overwritten or destroyed just a few seconds ago.

https://docs.kernel.org/filesystems/nilfs2.html

https://wiki.archlinux.org/title/NILFS2

https://en.wikipedia.org/wiki/NILFS

Re:In Praise Of –Dry-Run by aappleby on Saturday January 31, 2026 @09:17PM (#46843001)
Sure, in those cases - but if a command has a chance of nuking prod, you want some extra step in there. Preferably something that can't be muscle-memoried through.
Re:In Praise Of –Dry-Run by arjie on Sunday February 01, 2026 @03:45AM (#46844585)
No rule is ironclad. I think matching risk to functionality is usually a good idea. For example, most modern Linuxen carry `rm` protected against root removal with `--no-preserve-root`. That is indeed `rm --wet-run` by a different name in the dangerous case.